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

Fastdfs group同步及一台服务器部署两个storage_第1张图片

Fastdfs group同步及一台服务器部署两个storage_第2张图片

Fastdfs group同步及一台服务器部署两个storage_第3张图片

你可能感兴趣的:(Fastdfs,fastdfs,group同步)