FastDFS
Just demonstrate to how to use it. You should dive into when using it for productive environment.
安装FastDFS (standalone)
环境以及软件准备
ip: 192.168.13.33 path: /tmp/fastdfs
mkdir /tmp/fastdfs
cd /tmp/fastdfs
git clone https://github.com/happyfish100/libfastcommon
git clone https://github.com/happyfish100/fastdfs
git clone https://github.com/happyfish100/fastdfs-nginx-module
wget
"http://nginx.org/download/nginx-1.13.0.tar.gz"
yum groupinstall -y
"Development Tools"
yum install -y libevent* pcre-devel zlib-devel openssl openssl-devel
FastDFS 安装
cd /tmp/fastdfs/libfastcommon
./make.sh
./make.sh install
cd /tmp/fastdfs/fastdfs
./make.sh
./make.sh install
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
vim /etc/fdfs/tracker.conf
bind_addr=
192.168.
13.33
base_path=/tmp/fastdfs
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
vim /etc/fdfs/storage.conf
base_path=/tmp/fastdfs
store_path0=/tmp/fastdfs
tracker_server=
192.168.
13.33:
22122
Nginx 安装
cd /tmp/fastdfs
tar -xvf nginx-
1.13.
0.tar.gz
cd nginx-
1.13.
0
mkdir -vp /var/cache/nginx/{client_temp,proxy_temp,fastcgi_temp,uwsgi_temp,scgi_temp}
./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx --group=nginx --with-http_ssl_module \
--with-http_realip_module --with-http_addition_module \
--with-http_sub_module --with-http_dav_module \
--with-http_flv_module --with-http_mp4_module \
--with-http_gunzip_module --with-http_gzip_static_module \
--with-http_random_index_module --with-http_secure_link_module \
--with-http_stub_status_module --with-mail --with-mail_ssl_module \
--with-file-aio --with-ipv6 \
--with-cc-opt=
'-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 \
-fexceptions -fstack-protector --param=ssp-buffer-size=4 \
-m64 -mtune=generic' \
--add-module=/tmp/fastdfs/fastdfs-nginx-module/src
make && make install
vim /etc/nginx/nginx.conf
user root;
server {
listen
80;
server_name
192.168.
13.33;
location / {
root html;
index index.html index.htm;
}
location /group1/M00/ {
alias /tmp/fastdfs/data;
ngx_fastdfs_module;
}
error_page
500 502 503 504 /
50x.html;
location = /
50x.html {
root html;
}
}
useradd -M
-s /sbin/nologin nginx
cp /tmp/fastdfs/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
cp /tmp/fastdfs/fastdfs/conf/http.conf /etc/fdfs/
cp /tmp/fastdfs/fastdfs/conf/mime.types /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
base_path=/tmp/fastdfs
tracker_server=
192.168.
13.33:
22122
store_path0=/tmp/fastdfs
url_have_group_name=
true
启动
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
netstat -ltnp | grep fdfs
/usr/sbin/nginx -c /etc/nginx/nginx.conf
测试
vim /etc/fdfs/client.conf
base_path=/tmp/fastdfs
tracker_server=
192.168.
13.33:
22122
http.tracker_server_port=
80
cd /tmp
vim hello-fdfs.txt
/usr/local/bin/fdfs_test /etc/fdfs/storage.conf upload hello-fdfs.txt
结果如下图:
至此,FastFDS (standalone)安装部署完毕
集群安装 (cluster)
以 192.168.13.32, 192.168.13.33 两台机器为集群机器 每台机器都需要按照上述的步骤进行安装
安装好单机版,并运行通过之后,停掉每台FastDFS上的相关进程,进行如下配置,两台机器配置一致
配置
vim /etc/fdfs/tracker.conf
use_storage_id =
true
cp /tmp/fastdfs/fastdfs/conf/storage_ids.conf /etc/fdfs/
vim /etc/fdfs/storage_ids.conf
100001 group1
192.168.
13.32
100002 group1
192.168.
13.33
vim /etc/fdfs/storage.conf
tracker_server=
192.168.
13.32:
22122
tracker_server=
192.168.
13.33:
22122
vim /etc/fdfs/mod_fastdfs.conf
tracker_server=
192.168.
13.32:
22122
tracker_server=
192.168.
13.33:
22122
vim /etc/fdfs/client.conf
tracker_server=
192.168.
13.32:
22122
tracker_server=
192.168.
13.33:
22122
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
/usr/sbin/nginx -c /etc/nginx/nginx.conf