侧边栏壁纸
博主头像
★街角晚灯★ 博主等级

博观而约取 厚积而薄发

  • 累计撰写 468 篇文章
  • 累计创建 185 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

CentOS7搭建FastDFS V5.11分布式文件系统

WinJay
2019-04-29 / 0 评论 / 0 点赞 / 148 阅读 / 0 字 / 正在检测是否收录...

http://www.cnblogs.com/guigujun/p/7804688.html

[root@AnHui ~]# yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y

[root@AnHui tools]# unzip libfastcommon-master.zip 


2.安装Fastdfs

[root@AnHui fdfs]# cp client.conf.sample client.conf
[root@AnHui fdfs]# cp storage.conf.sample storage.conf
[root@AnHui fdfs]# cp tracker.conf.sample tracker.conf

3.安装tracker

[root@AnHui opt]# service fdfs_trackerd start
Reloading systemd:                                         [  OK  ]
Starting fdfs_trackerd (via systemctl):                    [  OK  ]
[root@AnHui opt]# echo "service fdfs_trackerd start" |tee -a /etc/rc.d/rc.local
service fdfs_trackerd start

查看一下tracker的端口监听情况:

[root@AnHui opt]# netstat -unltp|grep fdfs
tcp        0      0 0.0.0.0:22122           0.0.0.0:*               LISTEN      63117/fdfs_trackerd

注:

[root@AnHui fdfs]# grep -Ev "^#|^$" tracker.conf
disabled=false
bind_addr=0.0.0.0
port=22122
connect_timeout=10
network_timeout=60
base_path=/opt/fastdfs_tracker
max_connections=1024
accept_threads=1
work_threads=4
min_buff_size = 8KB
max_buff_size = 128KB
store_lookup=2
store_group=group2
store_server=0
store_path=0
download_server=0
reserved_storage_space = 10%
log_level=info
run_by_group=
run_by_user=
allow_hosts=*
sync_log_buff_interval = 10
check_active_interval = 120
thread_stack_size = 64KB
storage_ip_changed_auto_adjust = true
storage_sync_file_max_delay = 86400
storage_sync_file_max_time = 300
use_trunk_file = false 
slot_min_size = 256
slot_max_size = 16MB
trunk_file_size = 64MB
trunk_create_file_advance = false
trunk_create_file_time_base = 02:00
trunk_create_file_interval = 86400
trunk_create_file_space_threshold = 20G
trunk_init_check_occupying = false
trunk_init_reload_from_binlog = false
trunk_compress_binlog_min_interval = 0
use_storage_id = false
storage_ids_filename = storage_ids.conf
id_type_in_filename = ip
store_slave_file_use_link = false
rotate_error_log = false
error_log_rotate_time=00:00
rotate_error_log_size = 0
log_file_keep_days = 0
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.server_port=8080
http.check_alive_interval=30
http.check_alive_type=tcp
http.check_alive_uri=/status.html

4。安装storage

[root@AnHui opt]# mkdir fdfs_storage_data
[root@AnHui opt]# mkdir fdfs_storage

[root@AnHui fdfs]# ln -s /usr/bin/fdfs_storaged /usr/local/bin/
[root@AnHui fdfs]# service fdfs_storaged start 
Starting fdfs_storaged (via systemctl):                    [  OK  ]
[root@AnHui fdfs]# echo "service fdfs_storaged start" |tee -a /etc/rc.d/rc.local
service fdfs_storaged start

注:

### 校验整合

到这里,fastdfs的东西都已安装完成,最后我们还要确定一下,storage是否注册到了tracker中去。
查看命令:

/usr/bin/fdfs_monitor /etc/fdfs/storage.conf

成功后可以看到:

ip_addr = 202.205.161.XXX (localhost.localdomain) ACTIVE 

一、测试

1. 配置客户端

注:

2. 模拟上传

[root@Nerc fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/timg.jpg
NercFastDFS/M00/00/00/ys2hX1zFTuWAIv1YAAMEQ5Za9OI863.jpg
[root@Nerc fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/timg1.jpg
NercFastDFS/M00/00/00/ys2hX1zFTvGAZDooAAFUDnA3bZg936.jpg

二、FastDFS的nginx模块安装

1.安装nginx并添加fastdfs-nginx-module
Nginx安装:https://www.winjay.cn/?p=1056

[root@Nerc fdfs]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz

[root@Nerc fdfs]# nginx -V
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: –prefix=/etc/nginx –sbin-path=/usr/sbin/nginx –modules-path=/usr/lib64/nginx/modules –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp –http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=nginx –group=nginx –with-compat –with-file-aio –with-threads –with-http_addition_module –with-http_auth_request_module –with-http_dav_module –with-http_flv_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_mp4_module –with-http_random_index_module –with-http_realip_module –with-http_secure_link_module –with-http_slice_module –with-http_ssl_module –with-http_stub_status_module –with-http_sub_module –with-http_v2_module –with-mail –with-mail_ssl_module –with-stream –with-stream_realip_module –with-stream_ssl_module –with-stream_ssl_preread_module –with-cc-opt=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC’ –with-ld-opt=’-Wl,-z,relro -Wl,-z,now -pie’

解压 fastdfs-nginx-module

下载Nginx安装包,准备编译安装模块:
wget http://nginx.org/download/nginx-1.16.0.tar.gz

解压Nginx安装包并进入目录


开始编译安装fastdfs-nginx模块:

======有报错信息=======
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC’ --with-ld-opt=’-Wl,-z,relro -Wl,-z,now -pie’ --add-module=/root/tools/fastdfs-nginx-module-master/src

[root@Nerc nginx-1.16.0]#make && make install

在此编译安装时会有报错信息:


可参考 https://blog.csdn.net/zzzgd_666/article/details/81911892 予以解决。

需要修改如下:

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

修改完成后重新编译安装即可正常。

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/root/tools/fastdfs-nginx-module-master/src

编译安装完成:

3.配置storage nginx

# 新增storage配置文件:
[root@Nerc nginx-1.16.0]# vim /etc/nginx/conf.d/storage.conf


注:

server {
        listen       9991;
        server_name  localhost;


        location / {
            root   html;
            index  index.html index.htm;
        }
    
        location ~/NercFastDFS/M00 {
            root /opt/fastdfs_storage/data;
            ngx_fastdfs_module;
        }
    
        location = /50x.html {
            root   html;
        }

}


注:

[group1]
group_name=NercFastDFS
storage_server_port=23000
store_path_count=1
store_path0=/opt/fastdfs_storage_data

测试nginx状态:

4.配置tracker nginx

# 新增tracker.conf配置文件:
[root@Nerc fdfs]# vim /etc/nginx/conf.d/tracker.conf
upstream fdfs_NercFastDFS {
        server 127.0.0.1:9991;
    }
   server {
        listen       80;
        server_name  localhost;
       location /NercFastDFS/M00 {
            proxy_pass http://fdfs_NercFastDFS;
        }
      error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

重启Nginx.

5.HTTP测试

这个时候已经能成功访问。FastDFS已部署完成。

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区