zoukankan      html  css  js  c++  java
  • 使用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
    
  • 相关阅读:
    201521123044 《Java程序设计》第2周作业-Java基本语法与类库
    201521123044 《Java程序设计》第01周学习总结
    201521123044 《Java程序设计》第1周学习总结
    Java 第七周总结
    Java 第六周总结
    Java 第五周总结
    test

    Java 第四周总结
    Java 第三周总结
  • 原文地址:https://www.cnblogs.com/lmx1002/p/10642058.html
Copyright © 2011-2022 走看看