FastDFS搭建分布式文件存储系统

[[doc]]

# 安装FastDFS

  1. 安装fastlibcommon
git clone https://gitee.com/fastdfs100/libfastcommon.git
cd libfastcommon; git checkout V1.0.47
./make.sh clean && ./make.sh && ./make.sh install
  1. 安装fastdfs
   git clone https://github.com/happyfish100/fastdfs.git
   cd fastdfs; git checkout V6.07
   ./make.sh clean && ./make.sh && ./make.sh install
  1. 安装配置文件

    ./setup.sh /etc/fdfs
    
  2. 编辑配置文件

    1. storage.conf

      base_path = /opt/storage/fastdfs
      store_path0 = /opt/storage/fastdfs
      tracker_server = 8.142.122.54:22122
      tracker_server = 39.103.203.215:22122
      
    2. tracker.conf

      base_path = /opt/tracker/fastdfs
      
    3. Storage_ids.conf

      100001   group1  8.142.122.54
      100002   group1  39.103.203.215
      
    4. client.conf

      tracker_server = 8.142.122.54:22122
      tracker_server = 39.103.203.215:22122
      
    5. 创建文件夹

      mkdir -p /opt/storage/fastdfs
      mkdir -p /opt/tracker/fastdfs
      
    6. 先启动tracker 再启动storage

    /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
    
  3. 监控

 /usr/bin/fdfs_monitor /etc/fdfs/client.conf
  1. 测试

    fdfs_test /etc/fdfs/client.conf upload 文件

# 安装Nginx(Openresty)

下载fastdfs-nginx-module

git clone https://github.com/happyfish100/fastdfs-nginx-module.git
mv fastdfs-nginx-module  /usr/local/

安装openresty

   wget https://openresty.org/download/openresty-1.19.9.1.tar.gz
   tar -zxf openresty-1.19.9.1.tar.gz 
   cd openresty-1.19.9.1/
   sudo ./configure --prefix=/usr/local/openresty  --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include'  --add-module=/usr/local/fastdfs-nginx-module/src/ --with-http_ssl_module --with-http_stub_status_module
   make && make install

# 修改配置文件

  1. nginx.conf 添加
  location ~/group[0-9]/M00 {
       #root /opt/storage/fastdfs/data;
       ngx_fastdfs_module;
 }

cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

  1. 修改mod_fastdfs.conf
# the base path to store log files
base_path=/opt/nginx_mode/fastdfs

tracker_server=39.103.203.215:22122
tracker_server=8.142.122.54:22122

# must same as storage.conf
store_path0=/opt/storage/fastdfs
  1. start or restart openresty
 sudo systemctl start openresty

# 未完 待补充