FastDFS安置文档


3台服务器,均可做负载、转发。

192.168.68.134

192.168.68.140

192.168.68.141


版本:

fastdfs              5.0.8

libfastcommon        1.0.29

nginx                1.8

fastdfs-nginx-module 1.16




# yum -y install pcre-devel

# groupadd CACC

# useradd -g CACC CACC

# mkdir -pv /app/soft

# chown CACC {/app,/app/soft}

# chgrp CACC {/app,/app/soft}

# cd /app/soft

# git clone https://github.com/happyfish100/libfastcommon.git

# cd libfastcommon/

# ./make.sh && ./make.sh install


# su - CACC

$ cd /app/soft

$ git clone https://github.com/happyfish100/fastdfs-nginx-module.git

$ wget http://nginx.org/download/nginx-1.8.0.tar.gz

$ git clone https://github.com/happyfish100/fastdfs.git

$ cd fastdfs

 修改安装、配置文件路径:

$ vim make.sh

      TARGET_PREFIX=/app/fastdfs

      TARGET_CONF_PATH=/app/fastdfs/etc

#     TARGET_INIT_PATH=/fastdfs/etc/init.d

      if [ ! -d /app/fastdfs/etc ]; then

           mkdir -p /app/fastdfs/etc

#       mkdir -p $TARGET_INIT_PATH

#      cp -f init.d/fdfs_trackerd $TARGET_INIT_PATH

#      cp -f init.d/fdfs_storaged $TARGET_INIT_PATH



$ mkdir -pv /app/fastdfs/etc

$./make.sh

$./make.sh install

$ cd /app/fastdfs/etc

$ cp tracker.conf.sample tracker.conf

$ cp storage.conf.sample storage.conf

$ cp client.conf.sample client.conf


修改配置文件:

$ vim /app/fastdfs/etc/client.conf

        base_path=/app/fastdfs/data

        tracker_server=192.168.68.134:22122


$ vim /app/fastdfs/etc/tracker.conf

        base_path=/app/fastdfs/data


$ vim /app/fastdfs/etc/storage.conf

        base_path=/app/fastdfs/data

        store_path_count=1 

        store_path0=/app/fastdfs/data/storage

        tracker_server=192.168.68.134:22122

      


$  mkdir -pv /app/fastdfs/data/storage



启动服务:

 $ /app/fastdfs/bin/fdfs_trackerd /app/fastdfs/etc/tracker.conf

 $ /app/fastdfs/bin/fdfs_storaged /app/fastdfs/etc/storage.conf

 $  ln -sv /app/fastdfs/data/storage/data/ /app/fastdfs/data/storage/data/M00

上传:

 $ /app/fastdfs/bin/fdfs_upload_file /app/fastdfs/etc/client.conf /app/fastdfs/test



 做tracker反向代理nginx:

 $ cp /app/soft/fastdfs/conf/{http.conf,mime.types} /app/fastdfs/etc

 


 $ vim /app/soft/fastdfs-nginx-module/src/mod_fastdfs.conf

         base_path=/app/fastdfs/data

         tracker_server=192.168.1.64:22122

         url_have_group_name = true  #此项须为true,即亲求的url带有组名

         store_path0=/app/fastdfs/data/storage #需要和storage.conf的配置一致


 $ cp /app/sofft/fastdfs-nginx-module/src/mod_fastdfs.conf /app/fastdfs/etc


 $ vim /app/soft/fastdfs-nginx-module/src/config

      CORE_INCS="$CORE_INCS /app/fastdfs/include/fastdfs /usr/include/fastcommon/"


       -DFDFS_MOD_CONF_FILENAME=\"/app/fastdfs/etc/mod_fastdfs.conf\"'




# ln -sv /app/fastdfs/lib/libfdfsclient.so  /usr/lib/libfdfsclient.so 

# ln -sv /app/fastdfs/lib64/libfdfsclient.so  /usr/lib64/libfdfsclient.so

 


 $ cd /app/soft/nginx-1.8.0

 $ ./configure --prefix=/app/nginx  --with-pcre --add-module=/app/soft/fastdfs-nginx-module/src


 $ make && make install


 $ vim /app/nginx/conf/nginx.conf


   upstream fdfs_group1 {  

        server 192.168.1.64:8090 weight=1 max_fails=2 fail_timeout=30s;  

        

  }

   server {

        listen       8090;

        server_name  localhost;


    location /group1/M00 {

         root /app/fastdfs/data/storage;

         proxy_pass http://fdfs_group1;  

         ngx_fastdfs_module;

  } }


启动nginx:

/app/nginx/sbin/nginx


上传

 /app/fastdfs/bin/fdfs_upload_file /app/fastdfs/etc/client.conf /usr/share/backgrounds/default_1920x1200.png