Docker安装和配置FastDFS

1、拉取镜像

docker pull morunchang/fastdfs

2、运行tracker

docker run -d --name=tracker --net=host morunchang/fastdfs sh tracker.sh

3、运行storage

docker run -d --name=storage --net=host -e TRACKER_IP=<your tacker server address>:22122 -e GROUP_NAME=<group name> morunchang/fastdfs sh storage.sh
  • 网络模式: --net=host 是docker的网络模式之一:作用是使用和宿主机一样的ip和端口。
  • <your tacker server address> 替换为你机器的IP。
  • <group name> 是组名,即storage的组,我们这里可以命名为group1
  • 如果想要增加新的storage服务器,再次运行该命令,注意更换新组名

4、修改nginx配置

4.1、进入storage容器内容

docker exec -it storage /bin/bash

4.2、修改nginx.conf配置文件

vim /etc/nginx/conf/nginx.conf

添加以下内容:

location ~ /M00 {
     # 禁止缓存
     add_header Cache-Control no-store; 
     root /data/fast_data/data;
     ngx_fastdfs_module;  
}

5、退出容器并重启storage容器

exit
docker restart storage

6、设置tracker和storage开启自启动

docker update --restart=always tracker
docker update --restart=always storage
发布了24 篇原创文章 · 获赞 1 · 访问量 6397

猜你喜欢

转载自blog.csdn.net/pkxwyf/article/details/105299485