1,概念以及非docker 部署
参考 http://www.ityouknow.com/fastdfs.html
2,docker部署
2.1,基于 season/fastdfs 镜像
2.1.1 拉取镜像 单节点( 该镜像storage 没有内置nginx)
docker pull season/fastdfs
2.1.2 tracker搭建
docker run -p 22122:22122 -ti -d --name trakcer \
-v /root/datas/fastdfs/tracker/tracker_data:/fastdfs/tracker/data \
-v /root/datas/fastdfs/conf:/fdfs_conf \
--net=host \
season/fastdfs \
tracker
2.1.3 storage搭建
docker run -p 23000:23000 -tid --name storage \
-v /root/datas/fastdfs/storage/storage_data:/fastdfs/storage/data \
-v /root/datas/fastdfs/storage/store_path:/fastdfs/store_path \
-v /root/datas/fastdfs/conf:/fdfs_conf \
--net=host \
-e TRACKER_SERVER:192.168.80.129:22122 \
season/fastdfs \
storage
2.2,基于 morunchang/fastdfs 镜像(集群)
2.2.1 环境说明
192.168.1.22,192.168.1.111 两台centos
192.168.1.22 安装 tracker1 storage2
192.168.1.111 安装 tracker2 storage1
2.2.1 拉取镜像 基本命令
docker pull morunchang/fastdfs
#下面命令 没有映射配置文件,storage 也无法指向多个tracker2
docker run -d --name tracker --net=host morunchang/fastdfs sh tracker.sh
docker run -d --name tracker --net=host -e GROUP_COUNT=2 -e TRACKER_PORT=22122 morunchang/fastdfs sh tracker.sh
docker run -d --name storage --net=host -v /root/datas/fastdfs/storage/storage_data:/data/fast_data -e TRACKER_IP=192.168.80.111:22122 -e -e GROUP_NAME=group1 -e STORAGE_PORT=23001 morunchang/fastdfs sh storage.sh
2.2.1 tracker搭建 分别在 22跟111服务器指向相同操作
1,搭建一个tracker,弄出一份配置文件,修改成我们需要的
docker run -d --name tracker --net=host morunchang/fastdfs sh tracker.sh
docker cp tracker:/etc/fdfs/tracker.conf /root/datas/fastdfs/tracker/conf/
docker rm -rf tracker
2,修改配置文件 一般会改下端口, 最终搭建命令。
docker run -d --name tracker --net=host \
-v /etc/localtime:/etc/localtime \
-v /root/datas/fastdfs/tracker/data:/data/fast_data/data \
-v /root/datas/fastdfs/tracker/conf/tracker.conf:/etc/fdfs/tracker.conf \
morunchang/fastdfs sh tracker.sh
2.2.1 storage搭建
1,搭建一个storage,弄出一份配置文件,修改成我们需要的
docker run -d --name storage --net=host -v /root/datas/fastdfs/storage/storage_data:/data/fast_data -e TRACKER_IP=192.168.80.111:22122 -e -e GROUP_NAME=group1 -e STORAGE_PORT=23001 morunchang/fastdfs sh storage.sh
docker cp storage:/storage.sh /root/datas/fastdfs/storage/conf/
docker cp storage:/etc/fdfs/mod_fastdfs.conf /root/datas/fastdfs/storage/conf/
docker cp storage:/etc/fdfs/storage.conf /root/datas/fastdfs/storage/conf/
docker cp storage:/etc/nginx/conf/nginx.conf /root/datas/fastdfs/storage/conf/
docker cp storage:/data/fastdfs/conf/client.conf /root/datas/fastdfs/storage/conf/
storage.conf:
tracker_server=198.168.1.11:22122
tracker_server=198.168.1.22:22122
nginx.conf
listen 端口改成跟 storage.conf(http.server_port) 属性一样
mod_fastdfs.conf
tracker_server=198.168.1.11:22122
tracker_server=198.168.1.22:22122
storage.sh 内容改成如下
#!/bin/sh
/data/fastdfs/storage/fdfs_storaged /etc/fdfs/storage.conf
/etc/nginx/sbin/nginx
tail -f /data/fast_data/logs/storaged.log
docker rm -rf storage
2,修改配置文件 , 最终搭建命令。
docker run -d --name storage --net=host --restart always \
-v /etc/localtime:/etc/localtime \
-v /root/datas/fastdfs/storage/data:/data/fast_data/ \
-v /root/datas/fastdfs/storage/conf/storage.sh:/storage.sh \
-v /root/datas/fastdfs/storage/conf/storage.conf:/etc/fdfs/storage.conf \
-v /root/datas/fastdfs/storage/conf/nginx.conf:/etc/nginx/conf/nginx.conf \
-v /root/datas/fastdfs/storage/conf/mod_fastdfs.conf:/etc/fdfs/mod_fastdfs.conf \
-v /root/datas/fastdfs/storage/conf/client.conf:/data/fastdfs/conf/client.conf \
morunchang/fastdfs sh storage.sh
2.2.1 注意事项
2.2.1.1 查看fastdfs 监控状态
docker exec -it storage fdfs_monitor /etc/fdfs/storage.conf
参数说明:
参数说明:
tracker_server_count:2 --表示2个Tracker Server
tracker server is 198.168.1.121:22122 --表示Leader Tracker
group count: 1 --表示有1个group
group name = group1 --组名称是group1
storage server count = 2 --组内有2个storage
active server count = 2 --活动的storage有2个
storage server port = 23002 --storage的端口
storage HTTP port = 9101 --storage的文件访问端口
store path count = 1 --storage只挂了一个存储目录
total_upload_count = 11 --总共上传了多少个文件
total_upload_bytes = 691405 --总共上传了多少字节
success_upload_bytes = 691405 --成功上传了多少字节
total_download_count = 2 --总共下载了多少文件(使用java客户端)
2.2.1.2 防火墙端口打开
iptables :
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 23000 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 22122 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 8888 -j ACCEPT
service iptables restart
iptables -L
firewall:
firewall-cmd --zone=public --add-port=23000 /tcp --add-port=22122 /tcp --add-port=8888 /tcp --permanent
firewall-cmd --reload
3,参考链接
https://blog.csdn.net/zhanngle/article/details/88770028
https://segmentfault.com/a/1190000019267250
http://www.ityouknow.com/fastdfs.html
http://wucb.top/2017/12/13/fastdfs_docker_conf/index.html
网友评论