Fastdfs group同步及一臺服務器部署兩個storage

  背景:

      1921.68.0.164 上已經有一個storage ,組名:group1;   192.168.0.171上有tracker(單tracker),一個storage,組名:group0;

       現在要做的工作是:在164上再起一個storage,設置組名爲group0(與171上的goup0 互爲備份) ,將171上的group0 文件同步到164 group0上 

1、 在164上新啓動一個storage

  •   複製一份171上的storage.conf到164上,改名爲  storage_group0.conf ,放到 /etc/fdfs/ 目錄下
  • vim  /etc/fdfs/storage_group0.conf  修改個別參數

storage_group0.conf 參數配置

group_name=group0

 

#根據當前環境制定目錄,別和已經存在的storage重複即可

base_path=/usr/local/fastdfs/fdfs_storage_group0

 

 

#(重要)存儲目錄,根據當前環境制定目錄,別和已經存在的storage重複即可

store_path0=/usr/local/fastdfs/fdfs_storage_group0

 

 

#其他參數都不用修改:包括端口,因爲要和171的storage保持一致,如果164上已經存在的storage端口和新發起storage端口有重複,修改調整已經存在的storage端口參數

  • 啓動新配置的storage(先測試是否能正常啓動,全部調試好之後,將所有storage,tracker、nginx全部跳掉,然後按啓動步驟啓動,先起tracker,然後storage,再然後nginx)

       /usr/bin/fdfs_storaged /etc/fdfs/storage_group0.conf

  •   參看啓動狀態  :是否有兩個storage線程

         ps aux|grep storage

2、配置mod_fastdfs.conf,一臺服務器上有多個storage的配置方式與單storage配置方式有很大去別

mode_fastdfs.conf 配置多個storage

?

base_path=/usr/local/fastdfs/

 

 

load_fdfs_parameters_from_tracker=true

 

 

storage_sync_file_max_delay = 86400

 

 

use_storage_id = false

 

 

storage_ids_filename = storage_ids.conf

 

 

tracker_server=192.168.0.171:22122

 

 

url_have_group_name = true

 

 

log_level=info

 

 

 

 

# set the group count

# set to none zero to support multi-group

# set to 0  for single group only

# groups settings section as [group1], [group2], ..., [groupN]

# default value is 0 # since v1.14

 

 

#經測試得出:如果group從0開始即group0\goup1 ,則group_count=1,如果group1\goup2  則group_count=2 ,後續進步一論證下

group_count = 1

 

 

 

 

[group0]

group_name=group0

storage_server_port=23000

store_path_count=1

store_path0=/usr/local/fastdfs/fdfs_storage_group0

 

 

[group1]

group_name=group1

storage_server_port=23001

store_path_count=1

store_path0=/usr/local/fastdfs/fdfs_storage

3、164上的nginx.conf需要調整

nginx配置調整

?

server {        

    listen       8288;        

    server_name  192.168.0.164,localhost; 

    location /group0/M00/{            

        root /usr/local/fastdfs/fdfs_storage_group0/data;            

        ngx_fastdfs_module;            

     }

  location /group1/M00/{            

        root /usr/local/fastdfs/fdfs_storage/data;            

        ngx_fastdfs_module;     

          }

}

4、171 nginx.conf配置調整,171 作爲http請求圖片的總入口需要重新做代理配置

171 nginx總入口配置調整

?

http {    

    include       mime.types;    

    default_type  application/octet-stream;

     

        sendfile        on;    

        # 192.168.0.164 storage group1 

    upstream fdfs_group1_164 { 

        server 192.168.0.164:8288 weight=1 max_fails=2 fail_timeout=30s; 

    }

    upstream fdfs_group0_proxy { 

        server 192.168.0.164:8288 weight=1 max_fails=2 fail_timeout=30s;

        server 192.168.0.171:8288 weight=1 max_fails=2 fail_timeout=30s;

    }

 

 

 

 

 

server {        

    listen       8070;        

    server_name  localhost,192.168.0.171;

    location / {            

        root   html;            

        max_ranges 1;            

        index  index.html index.htm;        

    }

    location ~* /group0/(M00|M01) { 

        proxy_next_upstream http_502 http_504 error timeout invalid_header; 

        proxy_pass http://fdfs_group0_proxy; 

        expires 30d;    }  

 

 

    location ~* /group1/(M00|M01) { 

        proxy_next_upstream http_502 http_504 error timeout invalid_header; 

        proxy_pass http://fdfs_group2_164;  expires 30d; 

    }

 

 

 

}

 

 

 

 

server {        

    listen       8288;        

    server_name  localhost,192.168.0.171;       

    location / {            

        root   html;           

         max_ranges 1;            

        index  index.html index.htm;        

    }      

    location /group0/M00{            

        root /data/fastdfs/storage/data;            

        ngx_fastdfs_module;

    }

}

4、按順序重新啓動tracker、 171storage、 164 兩個storage 、 171 nginx 、 164nginx

查看 storage 狀態

執行: /usr/local/fastdfs-5.09/bin/fdfs_monitor  /etc/fdfs/client.conf

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章