FastDFS (Fast Distributed File System) is an open source lightweight distributed file system , I spent a day through the installation and configuration, the reference period: https: //www.cnblogs.com/handsomeye/p/9451568.html , sum up now, hoping that newcomers avoid detours.
环境:CentOS Linux release 7.3.1611 (Core)[cat /etc/redhat-release]
Install wget: yum install wget
安装lrzsz:yum install lrzsz
Install gcc: yum install gcc
Installation: yum install vim
Installation: yum groupinstall Development Tools
Installation libfastcommon
-
Get libfastcommon installation package:
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz
-
Extracting installation package: tar -zxvf V1.0.38.tar.gz
-
Enter the directory: cd libfastcommon-1.0.38
-
Compile: ./ make.sh
-
Installation: ./ make.sh install
Installation FastDFS
-
Get fdfs installation package:
wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz
-
Extracting installation package: tar -zxvf V5.11.tar.gz
-
Enter the directory: cd fastdfs-5.11
-
Compile: ./ make.sh
-
Installation: ./ make.sh install
Configuration Service Tracker
1. Go to the / etc / fdfs directory, there are three .sample file suffix (automatically generated fdfs template configuration file), by cp command tracker.conf.sample copy, delete .sample suffix as an official document.
2. Edit tracker.conf: vi tracker.conf, modify the relevant parameters
base_path=/home/mm/fastdfs/tracker #tracker存储data和log的跟路径,必须提前创建好
http.server_port=80 #http端口,需要和nginx相同
3. Start tracker (support start | stop | restart):/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
Configuring Storage Service
- Enter / etc / fdfs directory, there are cp command to copy storage.conf.sample, delete .sample suffix as an official document;
-
Edit storage.conf: vi storage.conf, modify the relevant parameters:
base_path=/home/fastdfs/storage #storage存储data和log的跟路径,必须提前创建好 store_path0=/home/fastdfs/storage #如果为空,则使用base_path tracker_server=192.168.1.103:22122 #配置该storage监听的tracker的ip和port
-
Start storage (supports start | stop | restart):
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
Installation Nginx fastdfs-nginx-module and module
-
Download Nginx installation package
wget http://nginx.org/download/nginx-1.15.2.tar.gz
-
Download fastdfs-nginx-module installation package
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz
-
Decompression nginx: tar -zxvf nginx-1.15.2.tar.gz
-
Decompression fastdfs-nginx-module: tar -xvf V1.20.tar.gz
-
Installation depends libraries:
yum install libpcre3 libpcre3-dev openssl libssl-dev libperl-dev
-
Modify fastdfs-nginx-module-1.20 / src / config file:
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/" CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
-
Into the directory nginx: nginx CD-1.15.2 , load the configuration module fastdfs-nginx-module:
-
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/root/fastdfs-nginx-module-1.20/src -
Compile and install:
make -> make install
- Check the installation path: whereis nginx
-
-
cd /usr/local/nginx/sbin/ ./nginx ./nginx -s stop #此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程 ./nginx -s quit #此方式停止步骤是待nginx进程处理任务完毕进行停止 ./nginx -s reload
Nginx configuration and fastdfs-nginx-module module
-
Configuring mod-fastdfs.conf, and copied to the / etc / fdfs file directory
cd fastdfs-nginx-module-1.20/src/ cp mod_fastdfs.conf /etc/fdfs
-
Enter / etc / fdfs modification mod-fastdfs.conf:
base_path=/home/fastdfs/storage tracker_server=192.168.1.103:22122 #tracker的地址 url_have_group_name=true #url是否包含group名称 store_path0=/home/fastdfs/storage #文件存储的位置
-
Configuring nginx, new server:
cd /usr/local/nginx/conf/ vim nginx.conf
-
server {
listen 80;
server_name 192.168.1.103;
location /group1/M00/ {
ngx_fastdfs_module;
}} - A final copy of http.conf fastdfs unpacked directory and mime.types:
cd /usr/local/src/fastdfs-5.11/conf
cp mime.types http.conf /etc/fdfs/
测试服务:/usr/bin/fdfs_test /etc/fdfs/client.conf upload (指定配置文件)
example file url: http://192.168.1.107/group1/M00/00/00/wKgBa11_Lb2ADL_8AABdrSqbHGQ330_big.jpg