FastDFS文件服务器安装

  1. 环境准备:

    ubuntu16.0.04

    nginx1.10.0

    FastDFS5.08

  2. jar包准备:

    1)libfastCommonhttps://github.com/happyfish100/libfastcommon/tree/V1.0.36

    2)fastDFShttps://github.com/happyfish100/fastdfs/tree/V5.11

    3)nginxhttps://github.com/happyfish100/fastdfs/tree/V5.11

    4)fastdfs-nginx-moudlehttps://github.com/happyfish100/fastdfs-nginx-module //将请求代理交给nginx管理

  3. 环境搭建

    1)编译安装libfastCommon

            ./make.sh   #编译  

           ./make.sh install   # 安装   

            ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so   #创建符号链接

       2)编译安装fastDFS

           ①配置tracker.conf

           cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf

      vim /etc/fdfs/tracker.conf           修改内容:存储路径       base_path=/ev/fdfs/tracker

     ​ ②配置storage.conf

            cp /etc/fdfs/storage.conf.sample  /etc/fdfs/storage.conf

            vim /etc/fdfs/storage.conf

               修改内容:

              base_path=/ev/fdfs/storage  

              tracker_server=39.108.254.46:22122

              store_path0=/ev/fdfs/storage

            ③配置http.conf  mine.types      

              cp fastdfs-5.11/conf/http.conf /etc/fdfs/  

              cp fastdfs-5.11/conf/mime.types /etc/fdfs/

      ④配置client.conf

              cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf   

              vim /etc/fdfs/client.conf

                ​修改内容:

              base_path=/tmp #存放日志

              tracker_server=39.108.254.46:22122

              include http.conf   #打开该行代码  默认是注释掉的

             ⑤安装nginx

                     apt-get install libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev 

                     tar -zxvf /home/ubuntu/source/nginx-1.10.0.tar.gz

                     cd /home/ubuntu/source/nginx

                   ./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src/  # --prefix:安装目录;--add-                                          ​    ​    ​                        module:fastdfs-nginx-module文件路径

                    make  && make install# 编译 安装 

                    vi /usr/local/nginx/conf/nginx.conf #添加文件服务站点配置

                    添加内容如下

                             server {

                              listen       80;

                              server_name  39.108.254.46;

                          # 监听域名中带有group的,交给FastDFS模块处理

                              location ~/group([0-9])/ {

                                  ngx_fastdfs_module;

                              }

                          }

        4启动

        启动tracker:

               /etc/init.d/fdfs_trackerd start

            其他命令

            /etc/init.d/fdfs_trackerd stop #停止

            /etc/init.d/fdfs_trackerd restart #重启

        启动storage      

            /etc/init.d/fdfs_storaged start  

            其他命令

            /etc/init.d/fdfs_storaged stop #停止

            /etc/init.d/fdfs_storaged restart #重启

        查看是否启动

             ps -aux|grep fdfs

        测试fastDFS安装情况

         fdfs_test   /etc/fdfs/client.conf upload   /tmp/1.png  

        会出现这么一段

            FastDFS may be copied only under the terms of the GNU General

            Public License V3, which may be found in the FastDFS source kit.

            Please visit the FastDFS Home Page http://www.csource.org/ 

            for more detail.

            [2019-07-22 09:23:21] DEBUG - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=1,                         anti_steal_token=0, anti_stea

            l_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

            tracker_query_storage_store_list_without_group: 

                    server 1. group_name=, ip_addr=39.108.254.46, port=23000

            group_name=group1, ip_addr=39.108.254.46, port=23000

            storage_upload_by_filename

            group_name=group1, remote_filename=M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289.png

            source ip address: 172.18.38.17

            file timestamp=2019-07-22 09:23:23

            file size=364532

            file crc32=4124149981

            example file url: http://39.108.254.46/group1/M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289.png

            storage_upload_slave_by_filename

            group_name=group1, remote_filename=M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289_big.png

            source ip address: 172.18.38.17

            file timestamp=2019-07-22 09:23:25

            file size=364532

            file crc32=4124149981

            example file url: http://xx.xx/group1/M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289_big.png

            启动nginx:

            cd /usr/local/nginx/sbin/

              ./nginx

              /usr/local/nginx/sbin/nginx -s stop #停止

       /usr/local/nginx/sbin/nginx -s reload #重新加载配置文件

            启动成功后有这么一段

            root@iZwz97wxeq8a2n8v9yneogZ:/usr/local/nginx/sbin# ./nginx 

            ngx_http_fastdfs_set pid=4840

            然后测试刚才测试上传的图片

             http://xx.xx/group1/M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289_big.png

            tracker端口:22122

            storage端口:23000

            naginx 80

            安装过程中,可修改自己安装位置,但一定要记住安装在哪

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章