FastDFS(分布式文件系统)高可用集群

1、环境介绍:虚拟机A(tracker服务1 + nginx负载均衡 + keepalived双活)

                          虚拟机B(tracker服务2 + nginx负载均衡 + keepalived双活)

                         虚拟机C(storage服务1 + nginx  http服务)

                         虚拟机D(storage服务2 + nginx  http服务)

                        虚拟机E(storage服务3 + nginx  http服务)

                        虚拟机F(storage服务4 + nginx  http服务)


2、搭建FastDFS集群:将需要的安装包都拷贝到/usr/local/software文件夹

                                         给虚拟机A和虚拟机B安装tracker服务(安装前置环境、安装libfastcommon-master、安装FastDFS-tracker)

                                        给虚拟机C、D、E、F分别安装storage服务(差异、查看启动日志)

                                       给虚拟机C、D、E、F分别安装nginx提供HTTP服务(安装nginx插件fastdfs-nginx-module、安装nginx)


3、安装分布式文件系统客户端FastDFS-client(任选一台tracker服务器搭建client)


注释:安装前置环境 - (1)     安装libfastcommon-master - (2)       安装FastDFS-tracker - (3)    

          差异 -   (4)             查看启动日志 -  (5)

         安装nginx插件fastdfs-nginx-module -  (6)             安装nginx -  (7)       

        任选一台tracker服务器搭建client - (8)

(1)(安装前置环境)安装gcc     命令是:yum -y install gcc-c++           安装libevent,命令是:yum -y install libevent           

        。

(2)(安装libfastcommon-master )解压:[root@localhost software]#   tar -zxf libfastcommonV1.0.7.tar.gz           编译:命令:./make.sh       安装:命令:./make.sh instal

          创建软链接:命令:ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommom.so     

      。

(3)(安装FastDFS-tracker)解压:tar -zxf FastDFS_v5.05.tar,gz        编译:命令:先进入安装路径,cd FastDFS  ,再进行编译:./make.sh      安装:命令:./make.sh install

          将安装目录下的conf下的文件拷贝到/etc/fdfs下:cd FastDFS     、    cd conf     、   cp  *  /etc/fdfs        修改服务启动文件:vim  /etc/init.d/fdfs_trackerd

          执行命令,将local/  替换成空    命令::%s/local\///g     也可以手动把local删掉         修改tracker配置文件:  vim  /etc/fdfs/tracker.conf

         修改的内容:base_path=/usr/local/software/FastDFS/tracker        store_lookup=0       看不懂可以看接下来的代码:

 # the base path to store data and log files
base_path=/usr/local/software/FastDFS/tracker

# the method of selecting group to upload files
# 0: round robin
# 1: specify group
# 2: load balance, select the max free space group to upload file
#0 - 轮询 1 - 指定组 2 - 负载均衡, 设置为0便于测试,工作环境应该设置为2
store_lookup=0
      设置防火墙,把22122端口设置进白名单。   vim  /etc/sysconfig/iptables      加入:-A  INPUT  -m  state  --STATE  NEW  -m  tcp  -p  tcp  --dport  22122 -j  ACCEPT
    重启防火墙:service  iptables  restart                  启动tracker服务:service  fdfs_trackerd start
         。

(4)(差异)修改服务启动文件:vim  /etc/init.d/fdfs_storaged   执行命令,将local/  替换成空    命令::%s/local\///g     也可以手动把local删掉 

 修改storage配置文件:
[root@localhost fdfs]# vim /etc fs/storage.conf

修改的内容:
#指定该storage所在的组名,另外E、F两个虚拟机应该设置为group2组
group_name=group1

# the base path to store data and log files
base_path=/usr/local/software/FastDFS/storage

# the paths must be exist
store_path0=/usr/local/software/FastDFS/storage

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server= 192.168.101.137:22122 

tracker_server= 192.168.101.138:22122 

 设置防火墙:
vim /etc/sysconfig/
加入:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT
重启防火墙:
service iptables restart

(5)(查看启动日志)/usr/local/software/FastDFS/storage/logs/storaged.log

(6)(安装nginx插件fastdfs-nginx-module)  解压:tar  -zxf  fastdfs-nginx-module_v1.16.tar.gz     修改配置文件: cd  /usr/local/software/fastdfs-nginx-module/src 

          vim  config      执行命令,将local/  替换成空    命令::%s/local\///g     也可以手动把local删掉       复制配置文件:cp    mod_fastdfs.conf     /etc/fdfs   

 

 修改配置文件:
tracker_server= 192.168.101.137:22122 

tracker_server= 192.168.101.138:22122 


# 设置组名称,默认为group1,第二组的服务需要设置为group2
group_name=group1

#显示组名称
url_have_group_name=true

#
store_path0=/usr/local/software/FastDFS/storage

# 设置组的数量
group_count = 2

#添加组信息
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/usr/local/software/FastDFS/storage

[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/usr/local/software/FastDFS/storage

(7)(安装nginx) 前置环境:安装gcc,命令:yum  install -y gcc-c++          安装pcre,命令:yum install -y pcre pcre-devel

                                                       安装zlib,命令:yum install -y zlib zlib-devel     安装openssl,命令:yum install -y openssl openssl-devel

      安装nginx:安装包拷贝,将安装包放在/usr/local路径下。  解压:tar -zxf nginx-1.8.1.tar.gz    进入安装目录:cd nginx-1.8.1

                          创建软链接:ln -s /usr/lib64/libfdfsclient.so   /usr/lib/libfdfsclient.so                  

                          配置:./configure   --add-module=/usr/local/software/fastdfs-nginx-module/src

                          编译:make            安装:make  install

  配置nginx:vim   /usr/local/nginx/conf/nginx.conf                         

                       添加如下配置:
                         location ~/group([0-9])/M00 {
                                         ngx_fastdfs_module;
                         }
  启动nginx:cd  /usr/local/nginx /sbin                执行命令:./nginx
查看进程:   ps -aux | grep nginx
                        root     12100  0.0  0.0   5340   640 ?        Ss   12:11   0:00 nginx: master process . inx
                        nobody   12101  0.0  0.0   5544   992 ?        S    12:11   0:00 nginx: worker process
停止/重启nginx服务:重启:./nginx  -s  reload                停止:./nginx     -s    stop

(8)(任选一台tracker服务器搭建client )  修改配置文件:vim  /etc/fdfs/client.conf

base_path=/usr/local/software/FastDFS/tracker

tracker_server=192.168.233.132:22122

tracker_server=192.168.233.133:22122

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值