FastDFS安装接配置:PHP扩展

本文详细介绍如何搭建FastDFS分布式文件管理系统集群,包括硬件准备、软件安装、配置步骤及启动方法,并提供测试指令确保部署成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

FastDFS分布式文件管理系统集群

  1. 硬件准备

    2台tracker跟踪服务器
    192.168.1.101
    192.168.1.102
    
    4台storage存储服务器
    192.168.1.201
    192.168.1.202
    192.168.1.203
    192.168.1.204
  2. 安装准备

    yum -y groupinstall 'Development Tools'
    yum -y install wget
  3. 安装libfastcommon

    cd ~
    git clone https://github.com/happyfish100/libfastcommon.git
    cd libfastcommon/
    ./make.sh
    ./make.sh install
  4. 安装fastdfs

    cd ~
    wget https://github.com/happyfish100/fastdfs/archive/V5.08.tar.gz
    tar -zxvf V5.08.tar.gz
    cd fastdfs-5.08
    ./make.sh  
    ./make.sh install
  5. 创建目录

    mkdir /data/
    mkdir /data/fdfsd
    mkdir /data/fdfsd/client
    mkdir /data/fdfsd/storage
    mkdir /data/fdfsd/tracker
  6. 配置client(在storage服务器)

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

    cp /etc/fdfsd/storage.conf.sample /etc/fdfsd/storage.conf
    vim /etc/fdfsd/storage.conf
    
    base_path=/data/fdfsd/storage
    store_path0=/data/fdfsd/storage #这样配置只有M00
    tracker_server=192.168.1.101:22122 #tracker服务器1 ip地址
    tracker_server=192.168.1.102:22122 #tracker服务器2 ip地址
    group_name=group0
    
    
    #以下配置安装FastDHT才配置
    
    check_file_duplicate=1
    key_namespace=FastDFS
    keep_alive=1
    
    #include /etc/fdht/fdht_servers.conf
    
    
    ESC
    :wq
  8. 配置tracker(在tracker服务器)

    cp /etc/fdfsd/tracker.conf.sample /etc/fdfsd/tracker.conf
    vim /etc/fdfsd/tracker.conf
    
    base_path=/data/fdfsd/tracker
    
    # 0轮询 1指定组 2最大剩余空间
    
    store_lookup=2
    
    ESC
    :wq
  9. 启动tracker和storage

    
    # 用来做storage的服务器执行
    
    /usr/bin/fdfsd_storaged /etc/fdfsd/storage.conf
    
    # 用来做tracker的服务器执行
    
    /usr/bin/fdfsd_trackerd /etc/fdfsd/tracker.conf
  10. 开机启动

    
    # 用来做storage的服务器执行
    
    vim /etc/rc.local
    /usr/bin/fdfsd_storaged /etc/fdfsd/storage.conf
    ESC
    :wq
    
    
    # 用来做tracker的服务器执行
    
    vim /etc/rc.local
    /usr/bin/fdfsd_trackerd /etc/fdfsd/tracker.conf
    ESC
    :wq
  11. 可通过日志查看是否启动成功

    
    # 用来做storage的服务器执行
    
    tail -f /data/fdfsd/storage/logs/storaged.log
    
    
    # 用来做tracker的服务器执行
    
    tail -f /data/fdfsd/tracker/logs/trackerd.log
    
    
    #在storage服务器创建软连接
    
    ln -s /data/fdfsd/storage/data/ /data/fdfsd/storage/data/group0/M00
  12. 停止(不要执行)

    
    # 用来做storage的服务器执行
    
    pkill fdfsd_storaged
    
    
    # 用来做tracker的服务器执行
    
    pkill fdfsd_trackerd
  13. 防火墙相关配置

    yum install firewalld
    systemctl enable firewalld
    systemctl start firewalld
    #开启 8888 22122 23000 端口
    firewall-cmd --zone=public --add-port=8888/tcp --permanent
    firewall-cmd --zone=public --add-port=22122/tcp --permanent
    firewall-cmd --zone=public --add-port=23000/tcp --permanent
    systemctl restart firewalld
  14. 测试功能是否正常

    cd /
    
    #上传
    
    /usr/bin/fdfsd_test          /etc/fdfsd/client.conf upload /root/anaconda-ks.cfg
    
    
    #下载
    
    /usr/bin/fdfsd_download_file /etc/fdfsd/client.conf group1/M00/00/00/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cfg
    
    #查看下载文件
    
    ll /
    
    #删除下载文件
    
    rm /xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cfg
    
    
    #删除
    
    /usr/bin/fdfsd_delete_file   /etc/fdfsd/client.conf group1/M00/00/00/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cfg
  15. 为php安装fastdfs_client扩展

    进入扩展源码目录
    cd /root/fastdfs-5.08/php_client
    初始化
    /usr/local/php-7.0.13/bin/phpize
    配置
    ./configure --with-php-config=/usr/local/php-7.0.13/bin/php-config
    安装
    make
    make install
    增量配置
    cat /root/fastdfs-5.08/php_client/fastdfs_client.ini >> /usr/local/php-7.0.13/lib/php.ini
    重启php-fpm
    kill -USR2 `cat /usr/local/php-7.0.13/var/run/php-fpm.pid`
  16. 为php安装fastcommon扩展

    进入扩展源码目录
    cd /root/libfastcommon/php-fastcommon
    初始化
    /usr/local/php-7.0.13/bin/phpize
    配置
    ./configure --with-php-config=/usr/local/php-7.0.13/bin/php-config
    安装
    make
    make install
    vim /usr/local/php-7.0.13/lib/php.ini
    extension=fastcommon.so
    ESC
    :wq
    重启php-fpm
    kill -USR2 `cat /usr/local/php-7.0.13/var/run/php-fpm.pid`
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值