使用docker搭建FastDFS

拉取镜像(使用docker-componse可以忽略)

[root@localhost ~]# docker pull phinexdaz/fdfs_tracker
[root@localhost ~]# docker pull phinexdaz/fdfs_storage

docker-componse.yml

[root@localhost fdfs]# cat docker-componse.yml 
version: '2'

services: 
    fdfs_tracker:
        image: phinexdaz/fdfs_tracker
        container_name: fdfs_tracker
        cap_add:
            - LINUX_IMMUTABLE
        ports:
            - "22122:22122"
        volumes:
            - /etc/localtime:/etc/localtime:ro
            - /opt/compose-conf/df/data/fastdfs/tracker:/data/tracker
        hostname: fdfs_tracker
        restart: always
        environment:
            - LANG=zh_CN.UTF-8
        mem_limit: 2g
        memswap_limit: 2g
        stdin_open: true
        tty: true
    fdfs_storage:
        image: phinexdaz/fdfs_storage
        links:
            - fdfs_tracker
        container_name: fdfs_storage
        cap_add:
            - LINUX_IMMUTABLE
        ports:
            - "80:80"
            - "23000:23000"
        volumes:
            - /etc/localtime:/etc/localtime:ro
            - /opt/compose-conf/df/data/fastdfs/storage:/data/storage
            
        hostname: fdfs_storage
        restart: always
        environment:
            - LANG=zh_CN.UTF-8
            - TRACKER=fdfs_tracker
        mem_limit: 2g
        memswap_limit: 2g
        stdin_open: true
        tty: true

启动fdfs

[root@localhost fdfs]# docker-compose -f docker-componse.yml up -d
# 进入docker
[root@localhost fdfs]# docker-enter fdfs_storage
# 更改启动脚本, 更改ip变量
[root@fdfs_storage /]# cat /entrypoint.sh 
#!/bin/bash

STORAGE_BASE_PATH="/data/storage"
STORAGE_LOG_FILE="$STORAGE_BASE_PATH/logs/storaged.log"
STORAGE_CONF_FILE="/etc/fdfs/storage.conf"

echo "start fdfs_storgaed..."

#ip=`cat /etc/hosts | grep $TRACKER | awk '{print $1}'`
ip=$TRACKER
sed -i "s/^.*tracker_server=.*$/tracker_server=$ip:22122/" /etc/fdfs/storage.conf
sed -i "s/^.*tracker_server=.*$/tracker_server=$ip:22122/" /etc/fdfs/client.conf
sed -i "s/^.*tracker_server=.*$/tracker_server=$ip:22122/" /etc/fdfs/mod_fastdfs.conf
 
fdfs_storaged "$STORAGE_CONF_FILE"
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 
tail -f "$STORAGE_LOG_FILE"

# 提交镜像
[root@localhost fdfs]# docker commit fdfs_storage phinexdaz/fdfs_storage

[root@localhost fdfs]# docker-compose -f docker-componse.yml up -d

测试

[root@localhost fdfs]# docker-enter fdfs_storage
[root@localhost fdfs]# docker-enter fdfs_storage fdfs_upload_file /etc/fdfs/client.conf /tmp/ss.txt
[root@localhost ~]# curl http://127.0.0.1:88/group1/M00/00/00/rBcAA1yi9nmAQ56OAAAABFqCAvc886.txt
123

转载于:https://www.cnblogs.com/lmx1002/p/10642058.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值