docker 安装 fastdfs
1、安装docker(已安装的跳过这一步)
2、安装FastDFS
## 这里我使用的腾讯云个人镜像
docker pull ccr.ccs.tencentyun.com/satan/fastdfs:6.06
## 创建挂载映射文件夹
mkdir /data/fdfs/tracker /data/fdfs/storage
## 安装tracker
docker run -dti --network=host --name tracker -v /data/fdfs/tracker:/var/fdfs ccr.ccs.tencentyun.com/satan/fastdfs:6.06 tracker
## 安装storage
docker run -dti --network=host --name storage -e TRACKER_SERVER=10.128.7.178:22122 -v /data/fdfs/storage:/var/fdfs ccr.ccs.tencentyun.com/satan/fastdfs:6.06 storage
## 10.128.7.178 是我宿主机ip; 网络模式 host
3、防火墙设置
1.开放80,22122,23000端口,云服务器防火墙策略也要开(注意:如果关闭防火墙,云服务器策略也要开)
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=22122/tcp --permanent
firewall-cmd --zone=public --add-port=23000/tcp --permanent
2.重新加载配置
firewall-cmd --reload
3.查看防火墙锁开放的端口
firewall-cmd --zone=public --list-ports
4、 访问nginx测试
10.128.7.128是我的宿主机
不能访问的请按下面方法排查
[root@WXGGFW-Ser04 app]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
86925a568d0c ccr.ccs.tencentyun.com/satan/fastdfs:6.06 "/home/fastdfs.sh st…" 14 hours ago Up 14 hours storage
f76d38455c33 ccr.ccs.tencentyun.com/satan/fastdfs:6.06 "/home/fastdfs.sh tr…" 14 hours ago Up 21 minutes tracker
## 分别进入容器 看看nginx 启动没有, 看看nginx conf配置 和 logs
[root@WXGGFW-Ser04 app]# docker exec -it f76d38455c33 /bin/bash
[root@WXGGFW-Ser04 /]# ps -ef|grep nginx
root 24 1 0 01:26 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 26 24 0 01:26 ? 00:00:00 nginx: worker process
root 67 50 0 01:52 pts/1 00:00:00 grep --color=auto nginx
[root@WXGGFW-Ser04 /]# tail -f /usr/local/nginx/logs/error.log
ngx_http_fastdfs_process_init pid=118
[2025-01-08 12:07:42] ERROR - file: ../tracker/fdfs_shared_func.c, line: 474, host "" is invalid, error info: Unknown host
2025/01/08 12:07:42 [alert] 24#0: worker process 118 exited with fatal code 2 and cannot be respawned
ngx_http_fastdfs_process_init pid=26
[2025-01-08 12:15:01] ERROR - file: ../tracker/fdfs_shared_func.c, line: 474, host "" is invalid, error info: Unknown host
2025/01/08 12:15:01 [alert] 24#0: worker process 26 exited with fatal code 2 and cannot be respawned
nginx服务进程正常启动。
错误原因:
进入nginx安装目录,查看nginx错误日志。
ERROR - file: …/tracker/fdfs_shared_func.c, line: 474, host “tracker” is invalid, error info: Unknown host
报错信息:
解决办法:
cd /etc/fdfs/
vim mod_fastdfs.conf
修改tracker_server参数
tracker_server={{ip}}:22122