fastdfs集群搭建
需要的软件
fastdfs-nginx-module_v1.16.tar.gz
FastDFS_v5.05.tar.gz
libfastcommon-master.zip
nginx-1.8.0.tar.gz
关闭防火墙
service iptables stop
chkconfig iptables off
vi /etc/selinux/config
永久关闭:selinux=disable
安装运行环境
yum install -y gcc gcc-c++
yum install -y openssl-devel pcre-devel zlib-devel
ln -sv/usr/include/fastcommon /usr/local/include/fastcommon
ln -sv/usr/local/FastDFS/include/fastdfs /usr/local/include/fastdfs
ln -sv/usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -sv/usr/local/FastDFS/lib64/libfdfsclient.so /usr/lib64/libfdfsclient.so
启动tracker配置
/usr/local/FastDFS/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
安装libfastcommon
下载地址:https://github.com/happyfish100
/libfastcommon
unzip libfastcommon-master.zip
cd libfastcommon-master
./make.sh
./make.sh install
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
安装FastDFS
下载地址:
https://sourceforge.net/projects/fastdfs/files/
https://code.google.com/archive/p/fastdfs/downloads
https://github.com/happyfish100/fastdfs
tar zxf FastDFS_v5.05.tar.gz
cd FastDFS
./make.sh
./make.sh install
安装设置tracker
cd /etc/fdfs
mv tracker.conf.sample tracker.conf
vim tracker.conf
base_path=/data/fastdfs
http.server_port=6666
设置执行的软连接
ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/stop.sh /usr/local/bin
ln -s /usr/bin/restart.sh /usr/local/bin
service fdfs_trackerd start
查看trackerd日志
tail -f -n 200 /data/fastdfs/trackerd.log
查看端口
netstat -ntpl | grep fdfs
设置storage
mkdir /data/fastdfs-storage
cd /etc/fdfs/
mv storage.conf.sample storage.conf
vim storage.conf
group_name=group1
base_path=/data/fastdfs-storage
store_path_count=1
store_path0=/data/fastdfs-storage
tracker_server=192.168.116.145:22122
http.server_port=8888
ln -s /usr/bin/fdfs_storaged /usr/local/bin
service fdfs_storaged start
cat /data/fastdfs-storage/logs/storaged.log
cd /etc/fdfs/
mv client.conf.sample client.conf
vim client.conf
base_path=/data/fastdfs-storage
tracker_server=192.168.116.145:22122
http.tracker_server_port=6666
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/214815xnd5dz5t58fndt85.jpg
安装nginx下载地址
:
http://nchc.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
安装fastdfs-nginx-module
tar zxf fastdfs-nginx-module_v1.16.tar.gz
tar zxf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --prefix=/data/nginx --add-module=/data/soft/fastdfs-nginx-module/src
ln -sv /usr/include/fastcommon /usr/local/include/fastcommon
ln -sv /usr/include/fastdfs /usr/local/include/fastdfs
make
make install
cp /data/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
cp /data/soft/FastDFS/conf/mime.types /etc/fdfs/
cp /data/soft/FastDFS/conf/http.conf /etc/fdfs/
cp /data/soft/FastDFS/conf/anti-steal.jpg /etc/fdfs/
编辑nginx.conf
listen 9999;
location ~/group[1-3]/M00 {
root /data/fastdfs-storage/data;
ngx_fastdfs_module;
}
设置mod_fastdfs:/etc/fdfs/mod_fastdfs.conf
url_have_group_name = true
base_path=/data/fastdfs-storage
tracker_server=192.168.116.145:22122
url_have_group_name = true
store_path0=/data/fastdfs-storage
http.need_find_content_type=true
group_count = 3
添加group信息
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/data/fastdfs-storage
[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/data/fastdfs-storage
[group3]
group_name=group3
storage_server_port=23000
store_path_count=1
store_path0=/data/fastdfs-storage
设置软连接M00
ln -s /data/fastdfs-storage/data /data/fastdfs-storage/data/M00
启动nginx:
/data/nginx/sbin/nginx
设置主nginx
cd nginx-1.8.0
./configure --prefix=/data/nginx
make
make install
测试
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/214815xnd5dz5t58fndt85.jpg
http://127.0.0.1:9999/group1/M00/00/00/fwAAAVie3Y2AXe4KAACAyY9urrU744.jpg