CentOS7.X安装FastDFS-5.10

缺乏、安全感 2021-12-24 16:45 285阅读 0赞
  1. 安装准备

    1. yum install \
    2. vim \
    3. git \
    4. gcc \
    5. gcc-c++ \
    6. wget \
    7. make \
    8. libtool \
    9. automake \
    10. autoconf \
    11. -y \
  2. 安装libfastcommon

    1. cd /root git clone https://github.com/happyfish100/libfastcommon.git cd libfastcommon/ ./make.sh ./make.sh install
  3. 安装fastdfs

    1. cd /root wget https://github.com/happyfish100/fastdfs/archive/V5.10.tar.gz tar -zxvf V5.10.tar.gz cd fastdfs-5.10 ./make.sh ./make.sh install
  4. 如果只想安装FastDFS php客户端,请直接向下,找到php安装FastDFS扩展
  5. 创建目录

    1. mkdir /data/ mkdir /data/fdfs # 代码服务器执行 mkdir /data/fdfs/client # 存储服务器执行 mkdir /data/fdfs/storage # 跟踪服务器执行 mkdir /data/fdfs/tracker
  6. 配置的建议

    1. 每一台client配置上所有tracker服务器地址
    2. 每一台storage配置上所有tracker服务器地址
    3. 每一个group至少有2个storage服务互为备份机
    4. group name建议从group0开始命名(兼容FastDHT)
  7. 配置client(在client服务器[代码服务器])

    1. cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf vim /etc/fdfs/client.conf base_path=/data/fdfs/client tracker_server=192.168.1.101:22122 #tracker服务器1 ip地址 tracker_server=192.168.1.102:22122 #tracker服务器2 ip地址 ESC :wq
  8. 配置storage(在storage服务器)

    1. cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
    2. vim /etc/fdfs/storage.conf
    3. group_name=group0
    4. base_path=/data/fdfs/storage
    5. #这样配置只有M00 store_path0=/data/fdfs/storage #这样配置就有M01(一般用于磁盘挂载的情况) #store_path1=/mnt/fdfs/storage #设置storage最大连接数 max_connections=1024 #tracker服务器1 ip地址 tracker_server=192.168.1.101:22122 #只有一台tracker不要增加这条↓!!!!!!!! #tracker_server=192.168.1.102:22122 #tracker服务器2 ip地址 #以下配置安装FastDHT才配置!!!!!!!! #以下配置安装FastDHT才配置!!!!!!!! #以下配置安装FastDHT才配置!!!!!!!! check_file_duplicate=1 key_namespace=FastDFS keep_alive=1 #include /etc/fdht/fdht_servers.conf ESC :wq
  9. 配置tracker(在tracker服务器)

    1. cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
    2. vim /etc/fdfs/tracker.conf
    3. bind_addr=192.168.1.101
    4. base_path=/data/fdfs/tracker
    5. # 0轮询 1指定组 2最大剩余空间 store_lookup=2 max_connections=1024 # work_threads <= max_connections work_threads=16 ESC :wq
  10. 启动及测试【注意】

    1. # 如果storage.conf做了FastDHT配置,一定要先安装FastDHT
  11. 启动tracker和storage

    1. # 用来做tracker的服务器执行 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf # 用来做storage的服务器执行 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
  12. 启动与停止

    1. # 只能在对应服务器上进行对应操作!!!!!!!! # 只能在对应服务器上进行对应操作!!!!!!!! # 只能在对应服务器上进行对应操作!!!!!!!! # 启动 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf /usr/bin/fdfs_storaged /etc/fdfs/storage.conf # 关闭 /usr/bin/stop.sh /usr/bin/fdfs_trackerd /usr/bin/stop.sh /usr/bin/fdfs_storaged # 重启 /usr/bin/restart.sh /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf /usr/bin/restart.sh /usr/bin/fdfs_storaged /etc/fdfs/storage.conf # 查看集群storage分布(在storage服务器执行) /usr/bin/fdfs_monitor /etc/fdfs/storage.conf # 删除某个group中的一个storage(在storage服务器执行) /usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf delete [group name] [ip address]
  13. 开机启动

    1. # 用来做tracker的服务器执行 vim /etc/rc.local /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf ESC :wq chmod +x /etc/rc.local # 用来做storage的服务器执行 vim /etc/rc.local /usr/bin/fdfs_storaged /etc/fdfs/storage.conf ESC :wq chmod +x /etc/rc.local
  14. 可通过日志查看是否启动成功

    1. # 用来做storage的服务器执行 cat /data/fdfs/storage/logs/storaged.log|grep ERROR cat /data/fdfs/storage/logs/storaged.log|grep WARNING # 用来做tracker的服务器执行 cat /data/fdfs/tracker/logs/trackerd.log|grep ERROR cat /data/fdfs/tracker/logs/trackerd.log|grep WARNING # 在storage服务器创建软连接 # 配置Nginx才添加!!!!!!!! # 配置Nginx才添加!!!!!!!! # 配置Nginx才添加!!!!!!!! mkdir /www/fastdfs/group0 ln -s /data/fdfs/storage/data/ /www/fastdfs/group0/M00
  15. 防火墙相关配置

    1. yum install firewalld systemctl enable firewalld systemctl start firewalld firewall-cmd --zone=public --add-port=11411/tcp --permanent firewall-cmd --zone=public --add-port=22122/tcp --permanent firewall-cmd --zone=public --add-port=23000/tcp --permanent firewall-cmd --reload
  16. 测试功能是否正常

    1. mkdir /test cd /test vim test.txt This is a test file. ESC :wq #上传 /usr/bin/fdfs_test /etc/fdfs/client.conf upload /test/test.txt #下载 /usr/bin/fdfs_download_file /etc/fdfs/client.conf group0/M00/00/00/xxx.txt #查看下载文件 ll /test #删除下载文件 rm /xxx.txt #删除 /usr/bin/fdfs_delete_file /etc/fdfs/client.conf group0/M00/00/00/xxx.cfg
  17. 为php安装fastdfs_client扩展

    1. cd /root/fastdfs-5.10/php_client phpize ./configure make make install cat /root/fastdfs-5.10/php_client/fastdfs_client.ini >> /usr/local/php/lib/php.ini kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
  18. 为php安装fastcommon扩展

    1. cd /root/libfastcommon/php-fastcommon phpize ./configure make make install vim /usr/local/php/lib/php.ini extension=fastcommon.so ESC :wq kill -USR2 `cat /usr/local/php-7.1.4/var/run/php-fpm.pid`

转载于:https://www.cnblogs.com/valu/p/10836143.html

发表评论

表情:
评论列表 (有 0 条评论,285人围观)

还没有评论,来说两句吧...

相关阅读