FastDFS集群安装
2016-12-19 本文已影响0人
StonyBlue
1. 安装编译环境
yum install -y zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip
useradd -s /sbin/nologin fastdfs
mkdir -p /export/fastdfs/{storage,tracker,mod}
ll /export/fastdfs
chown -R fastdfs: /export/fastdfs
2. 下载最新版FastDFS
wget https://github.com/happyfish100/libfastcommon/archive/master.zip
unzip master.zip
cd libfastcommon-master/
./make.sh
./make.sh install
wget http://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.05/FastDFS_v5.05.tar.gz/download
mv download FastDFS_v5.05.tar.gz
tar zxf FastDFS_v5.05.tar.gz && cd FastDFS
./make.sh
./make.sh install
cp pa conf/*.conf /etc/fdfs/
cd /etc/fdfs/
rm -rf *.sample
3. 安装Nginx
wget http://nginx.org/download/nginx-1.8.0.tar.gz
wget http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz/download
mv download fastdfs-nginx-module_v1.16.tar.gz
tar zxf fastdfs-nginx-module_v1.16.tar.gz && tar zxf nginx-1.8.0.tar.gz
cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
4. 安装Nginx扩展
4.0 下扩展
curl -R -L -O http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar zxvf ngx_cache_purge-2.3.tar.gz
curl -R -L -O https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
curl -R -L -O https://github.com/openresty/lua-nginx-module/archive/v0.9.19.tar.gz
4.1 修改模块中对应的路径,要不然模块不能正确安装加载
去掉local,并指定lib64(64系统)
cd fastdfs-nginx-module/src
vi conf
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/lib64 -lfastcommon -lfdfsclient"
ulimit -SHn 102400
useradd -s /sbin/nologin www
cd nginx-1.8.0
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=../fastdfs-nginx-module/src/ --add-module=../ngx_devel_kit-0.2.19/ --add-module=../lua-nginx-module-0.9.19/ --add-module=../ngx_cache_purge-2.3/
make && make install
5. 修改配置文件
5.0 配置Storage
vi /etc/fdfs/storage.conf
group_name=group1
base_path=/export/fastdfs/storage
store_path0=/export/fastdfs/storage
tracker_server=192.168.0.205:22122
tracker_server=192.168.0.206:22122
http.server_port=80
vi /etc/fdfs/tracker.conf
base_path=/export/fastdfs/tracker
http.server_port=84
5.1 配置Tracker
vi /etc/fdfs/tracker.conf
base_path=/export/fastdfs/tracker
http.server_port=84
5.2 配置Mod
vi /etc/fdfs/mod_fastdfs.conf
group_name=group1
base_path=/export/fastdfs/mod
store_path0=/export/fastdfs/storage
tracker_server=10.0.13.27:22122
url_have_group_name=true
group_count = 1
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/export/fastdfs/storage
#store_path1=/home/yuqing/fastdfs1
5.3 配置Client
vi /etc/fdfs/client.conf
tracker_server=192.168.0.205:22122
tracker_server=192.168.0.206:22122
http.tracker_server_port=84
#include http.conf
5.4 配置Nginx
vi /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name 10.0.13.27;
location /group1/M00 {
root /export/fastdfs/storage/data/;
ngx_fastdfs_module;
}
}
6. 启动
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx start
/usr/local/nginx/sbin/nginx -s reload
netstat -npl |grep -E "nginx|fdfs"
7. 测试
/usr/bin/fdfs_test /etc/fdfs/client.conf upload tt.jpg
curl http://10.0.13.27/group1/M00/00/00/CgANG1hJC5SAe37XAAIbCObcUKA197_big.jpg
8. 防火墙
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 22122 -j ACCEPT
#然后保存:
/etc/rc.d/init.d/iptables save
#重启防火墙以便改动生效:(或者直接重启系统)
/etc/init.d/iptables restart
9. 添加nginx 扩展
添加 --add-module=
然后 make
/usr/local/nginx/sbin/nginx -s stop
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
cp ./objs/nginx /usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -V
##如果 error while loading shared libraries
ln -s /usr/local/lib/libluajit-5.1.so.2 /usr/lib/libluajit-5.1.so.2
ldconfig
/usr/local/nginx/sbin/nginx -V