CentOS7.X安裝FastDFS-5.10

  1. 安裝準備php

    yum install \
    vim \
    git \
    gcc \
    gcc-c++ \
    wget \
    make \
    libtool \
    automake \
    autoconf \
    -y \
  2. 安裝libfastcommonnginx

    cd /root git clone https://github.com/happyfish100/libfastcommon.git cd libfastcommon/ ./make.sh ./make.sh install
  3. 安裝fastdfsc++

    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. 建立目錄git

    mkdir /data/ mkdir /data/fdfs # 代碼服務器執行 mkdir /data/fdfs/client # 存儲服務器執行 mkdir /data/fdfs/storage # 跟蹤服務器執行 mkdir /data/fdfs/tracker
  6. 配置的建議github

    1. 每一臺client配置上全部tracker服務器地址
    2. 每一臺storage配置上全部tracker服務器地址
    3. 每個group至少有2個storage服務互爲備份機
    4. group name建議從group0開始命名(兼容FastDHT)
  7. 配置client(在client服務器[代碼服務器])sql

    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服務器)apache

    cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
    vim /etc/fdfs/storage.conf
    
    group_name=group0
    base_path=/data/fdfs/storage
    #這樣配置只有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服務器)vim

    cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
    vim /etc/fdfs/tracker.conf
    
    bind_addr=192.168.1.101
    base_path=/data/fdfs/tracker
    # 0輪詢 1指定組 2最大剩餘空間 store_lookup=2 max_connections=1024 # work_threads <= max_connections work_threads=16 ESC :wq
  10. 啓動及測試【注意】bash

    # 若是storage.conf作了FastDHT配置,必定要先安裝FastDHT
  11. 啓動tracker和storage服務器

    # 用來作tracker的服務器執行 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf # 用來作storage的服務器執行 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
  12. 啓動與中止

    # 只能在對應服務器上進行對應操做!!!!!!!! # 只能在對應服務器上進行對應操做!!!!!!!! # 只能在對應服務器上進行對應操做!!!!!!!! # 啓動 /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. 開機啓動

    # 用來作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. 可經過日誌查看是否啓動成功

    # 用來作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. 防火牆相關配置

    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. 測試功能是否正常

    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擴展

    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擴展

    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`
相關文章
相關標籤/搜索