下面将介绍下FastDFS在rhel上的部署过程
tracker server IP:192.168.1.70
str1grp1 server IP:192.168.1.68
str2grp2 server IP:192.168.1.69
【前提条件】
关闭防火墙
关闭SElinux
FastDFS介绍这里不再作描述,有关详细介绍自已去百度查找资料
【安装编译工具】(所有机器)
# yum -y install gcc gcc-c++ pcre pcre-devel automake autoconf libtool make zlib openssl openssl-devel
【创建目录,用于记录tracker日志、storage server等信息】(所有机器)
#mkdir -m 777 -p /www/fastDFS
【编译安装libfastcommon】(所有机器)
# unzip libfastcommon-master.zip
# cd libfastcommon-master
# ./make.sh
# ./make.sh install
【安装FastDFS】(所有机器)
1)但是FastDFS主程序设置的lib目录是/usr/local/lib,所以需要创建软链接.
# ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
# ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
# ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
# ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
2)安装FastDFS主程序
# tar zxf FastDFS_v5.05.tar.gz
# cd FastDFS
# ./make.sh
# ./make.sh install
【配置Tracker服务器】(192.168.1.70)
1)打开Tracker配置文件,修改如下内容
# cd /etc/fdfs/;ls
# cp tracker.conf.sample tracker.conf
# vim tracker.conf
...
22 base_path=/tracker
...
2)启动服务
# fdfs_trackerd /etc/fdfs/tracker.conf
# netstat -ntpl |grep fdfs
【配置Storage服务器】(192.168.1.68,192.168.1.69)
1)打开Storage配置文件,修改如下内容
# cd /etc/fdfs/;ls
# vim /etc/fdfs/storage.conf
...
11 group_name=group1 #str1grp1无须修改此项,str2grp2将此项改为group2
...
41 base_path=/www/fastDFS
...
109 store_path0=/www/fastDFS
...
118 tracker_server=192.168.1.70:22122
...
2)启动服务
# fdfs_storaged /etc/fdsfs/storage.conf
# netstat -ntpl | grep fdfs
3)查看tracker与storage连接情况
# netstat -tnlpa| grep 22122
【配置Client】(192.168.1.69)-》在用str2grp2做客户端
1)修改client.conf文件
# cd /etc/fdfs;ls
# cp client.conf.sample client.conf
# vim /etc/fdfs/client.conf
...
10 base_path=/www/fastDFS
...
14 tracker_server=192.168.1.70:22122
...
2)测试文件上传
# fdfs_upload_filet /etc/fdfs/client /etc/passwd
3)查看上传文件
# cd /www/fastDFS/data/00/00;ls
【FastDFS与Nginx的整合配置】(所有机器)
1)修改fastdfs-nginx-module的config文件
# tar zxf fastdfs-nginx-module_v1.16.tar.gz
# cd fastdfs-nginx-module/src
# vim config
...
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon"
...
2)安装nginx
# tar zxf nginx-1.8.0.tar.gz
# cd nginx-1.8.0
# ./configure --prefix=/usr/local/nginx --add-module=/tmp/fastdfs-nginx-module/src --without-http_gzip_module
# make && make install
3)修改mod_fastdfs.com配置文件
# cp /tmp/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
# cp /tmp/FastDFS/conf/http.conf /etc/fdfs/
# cp /tmp/FastDFS/conf/mime.types /etc/fdfs
# vim /etc/fdfs/mod_fastdfs.conf
...
3 connect_timeout=20 #默认2秒有点小,可改可不改
...
10 base_path=/www/fastDFS
...
40 tracker_server=192.168.1.70:22122 #根据自己的IP
...
47 group_name=group1 #tracker和str1grp1无须修改此项,str2grp2将此项改为group2
...
53 url_have_group_name = true #使用浏览器访问的时候,需要添加上组名称
...
62 store_path0=/www/fastDFS
...
4)创建软链接
# ln -s /www/fastDFS/data /www/fastDFS/data/M00
5)编辑nginx.conf配置文件
# cd /usr/local/nginx/conf;vim nginx.conf
在server段添加如下内容:
...
location /group1/M00{ #192.168.1.69需要修改此项为group2
alias /www/fastDFS/data/;
ngx_fastdfs_module;
}
...
6)启动服务
#/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#/usr/local/nginx/sbin/nginx -t stop
#/usr/local/nginx/sbin/nginx
7)客户端访问
http://192.168.1.70/group1/M00/00/00/wKgpolFwG-WANaKzAAAADVt_Kt4300_big.txt