FastDFS环境搭建
环境准备
系统环境说明
名称 | 说明 |
---|
CentOS | 7.X(安装系统) |
libfastcommon | FastDFS分离出的一些公用函数包 |
FastDFS | FastDFS本体 |
fastdfs-nginx-module | FastDFS和nginx的关联模块,解决组内同步延迟问题 |
nginx | nginx 1.15.4 |
服务器环境资源及用途
名称 | IP地址 | 应用 |
---|
tracker,storage01 | 192.168.40.210 | FastDFS,libfastcommon,nginx,fastdfs-nginx-module |
storage02 | 192.168.40.220 | FastDFS,libfastcommon,nginx,fastdfs-nginx-module |
安装目录
说明 | 路径 |
---|
tracker/storage日志路径 | /data/local/fastdfs/ |
文件存储路径 | /data/local/fastdfs |
安装路径 | /usr/local/ |
开始安装
1.安装包以及依赖文件下载
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
cd /usr/local/
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
git clone https://github.com/happyfish100/fastdfs.git --depth 1
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
wget http://nginx.org/download/nginx-1.15.4.tar.gz
tar -zxvf nginx-1.15.4.tar.gz
2.安装fastdfs
cd libfastcommon/
./make.sh && ./make.sh install
cd ../fastdfs/
./make.sh && ./make.sh install
cd ../nginx-1.15.4/
./configure --add-module=/usr/local/fastdfs-nginx-module/src
make && make install
3.修改配置文件
192.168.40.210
cd /etc/fdfs
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf
cp /usr/local/fastdfs/conf/http.conf /etc/fdfs/
cp /usr/local/fastdfs/conf/mime.types /etc/fdfs/
cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vim tracker.conf
base_path=/data/local/fastdfs
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
vim storage.conf
group_name=ciec0
port=23000
base_path=/data/local/fastdfs
store_path0=/data/local/fastdfs
tracker_server=192.168.40.210:22122
http.server_port=81
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
192.168.40.220
vim storage.conf
group_name=ciec0
port=23000
base_path=/data/local/fastdfs
store_path0=/data/local/fastdfs
tracker_server=192.168.40.210:22122
http.server_port=81
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
4.测试上传
base_path=/data/local/fastdfs
tracker_server=192.168.40.210:22122
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /etc/fdfs/client.conf
ciec0/M00/00/00/wKgo0l3kfiuAf5FiAAAGr5EsoIc78.conf
5.配置nginx访问
vim /etc/fdfs/mod_fastdfs.conf
tracker_server=192.168.40.210:22122
group_name=ciec0
url_have_group_name=true
base_path=/data/local/fastdfs
store_path0=/data/local/fastdfs
cd /usr/local/nginx/conf
mkdir fdfs/
vim fdfs_ciec.conf
server {
listen 81;
server_name localhost;
location ~/ciec0/M00 {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
vim nginx.conf
upstream fdfs_group01 {
server 192.168.40.210:81 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.40.220:81 weight=1 max_fails=2 fail_timeout=30s;
}
server {
listen 80;
server_name 0.0.0.0;
location /ciec0{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_pass http://fdfs_group01;
expires 30d;
}
}
include /usr/local/nginx/conf/test/fdfs.conf;
/usr/local/nginx/sbin/nginx
cd /usr/local/nginx/conf
mkdir fdfs/
vim fdfs_ciec.conf
server {
listen 81;
server_name localhost;
location ~/ciec0/M00 {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
/usr/local/nginx/sbin/nginx
6.测试文件下载
# 浏览器访问
http://192.168.40.210/ciec0/M00/00/00/wKgo0l3kfiuAf5FiAAAGr5EsoIc78.conf
# 成功下载及配置完成