• docker公司测试环境搭建总结


    1.防火墙转发规则:

    [root@docker ~]# firewall-cmd --list-all
    public (active)
    target: default
    icmp-block-inversion: no
    interfaces: em1
    sources:
    services: dhcpv6-client ssh
    ports: 50001/tcp 3306/tcp 5672/tcp 6379/tcp 15672/tcp
    protocols:
    masquerade: no
    forward-ports: port=8012:proto=tcp:toport=8012:toaddr=172.17.0.5
    port=50001:proto=tcp:toport=22:toaddr=172.17.0.2
    port=27017:proto=tcp:toport=27017:toaddr=172.17.0.6
    port=8070:proto=tcp:toport=8070:toaddr=172.17.0.3
    port=8056:proto=tcp:toport=8056:toaddr=172.17.0.4
    port=15672:proto=tcp:toport=15672:toaddr=172.17.0.9
    port=8080:proto=tcp:toport=8080:toaddr=172.17.0.2
    port=5672:proto=tcp:toport=5672:toaddr=172.17.0.9
    port=6379:proto=tcp:toport=6379:toaddr=172.17.0.7
    port=3306:proto=tcp:toport=3306:toaddr=172.17.0.8
    sourceports:
    icmp-blocks:
    rich rules:

    [root@docker ~]#

    注意删转发规则的时候记得:--permanent,在这里卡了一下

    2,启动的容器:用母鸡目录做的数据卷儿:

    [root@docker ~]# docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    627d468a004a 894a84a4a21f "/usr/sbin/init" 8 hours ago Up 8 hours 22/tcp rabbitmq
    c96f41b44943 894a84a4a21f "/usr/sbin/init" 8 hours ago Up 8 hours 22/tcp mysql
    aada204303bd 894a84a4a21f "/usr/sbin/init" 8 hours ago Up 8 hours 22/tcp redis
    385a5ae88f46 894a84a4a21f "/usr/sbin/init" 8 hours ago Up 8 hours 22/tcp mongodb
    4fe159f3e1c2 894a84a4a21f "/usr/sbin/init" 8 hours ago Up 8 hours 22/tcp statistics
    3ff1bb4aa177 894a84a4a21f "/usr/sbin/init" 8 hours ago Up 8 hours 22/tcp filter
    9e876e75b836 894a84a4a21f "/usr/sbin/init" 8 hours ago Up 8 hours 22/tcp message
    b50807faca74 894a84a4a21f "/usr/sbin/init" 9 hours ago Up 9 hours 22/tcp java
    [root@docker ~]#

    3.考虑自动部署的问题:

    容器脚本1:就是jar包修改了就自动重启。

    [root@b50807faca74 ~]# cat duibi.sh
    #!/bin/bash
    b=`sed -n '1p' a`
    a=`stat -c %Y /data/exchange/exchange-1.4.jar`
    echo $a > a
    if [ "$a" == "$b" ];then
    echo "ok" >> a
    else
    cd /data/exchange/
    ps -ef|grep exchange-1.4.jar | grep -v grep|awk -F ' ' '{print $2}'|xargs kill -9
    nohup java -jar exchange-1.4.jar & > nohup.out >/dev/null
    fi

    母鸡脚本2:

    [root@docker ~]# cat genxin.sh
    #!/bin/bash
    genxin(){
    wget $3 -O $2
    mv $2 $1
    }

    echo 'Input a number between e,f,m,s'
    echo 'and'
    echo 'Input url '
    echo 'Your number is:c'
    read -p "number:" a
    read -p "url:" url
    read -p "downurl:" downurl
    bao=`echo "$url"|awk -F "/" '{print $NF}'`
    case $a in
    e)
    echo 'You select e'
    dir=/data/exchange
    genxin $dir $bao $downurl
    ;;
    s)
    echo 'You select s'
    dir=/data/statistics
    genxin $dir $bao $downurl
    ;;
    f) echo 'You select f'
    dir=/data/filter
    genxin $dir $bao $downurl
    ;;
    m) echo 'You select m'
    dir=/data/message
    genxin $dir $bao $downurl
    ;;
    *) echo 'You do not select a number between 1 to 4'
    ;;
    esac

    注意:jar包在文件服务器seafile,里面,只需要传两个下载地址就可以了!感觉心里还是不是这么自动!!!明天再想想

     4.加了个ansible:

    [root@d6c5aaaa0bfe ~]# ansible target_servers -k -m command -a "df -h"
    SSH password:
    172.17.0.7 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-bb3810f63510753746fa3564da574cbbad45a46f1c09d33cee007e1a2d3d2281 10G 792M 9.3G 8% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /[
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/redis
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 60K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 48K 32G 1% /tmp

    172.17.0.6 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-803f5c4ebd2cd737c9bdb5eec8157d27a1b2a6250c835330b3206cb81ef8f822 10G 1.6G 8.5G 16% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /]
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/mongodb
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 60K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 56K 32G 1% /tmp

    172.17.0.10 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-105393dca3a922735e9acd187f44d6423d9826464dbe1ea6b898fbfdb8eeaacf 10G 529M 9.5G 6% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /[
    shm 64M 180K 64M 1% /dev/shm
    tmpfs 64M 56K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 48K 32G 1% /tmp

    172.17.0.9 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-c3e35ec8f80c51a89d30724a65650b0a7a1c4de62c15f9178847e5fe6737e765 10G 853M 9.2G 9% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /[
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/rabbitmq
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 56K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 48K 32G 1% /tmp

    172.17.0.8 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-fbc350e3d6527fe6b30c630fb16b3e563ec8777480f9fbcbcce2ace08260cb62 10G 1.5G 8.6G 15% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /[
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/mysql
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 60K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 48K 32G 1% /tmp

    172.17.0.5 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-063dcf0b304c0b378afbe367bdc6d41c327a10dbc3828a7af89be5ca783c817e 10G 795M 9.3G 8% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /[
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/statistics
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 56K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 80K 32G 1% /tmp

    172.17.0.4 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-a7db59d659d3a92e4f55b6ed631bc4f8f093e7f2fffc4fd073ab517798aa7f10 10G 795M 9.3G 8% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /[
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/filter
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 56K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 80K 32G 1% /tmp

    172.17.0.3 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-0faf72c047b2ae78ab33f678fba07b292fc58f17b14b9c0c3eb9834ac3b58ebd 10G 795M 9.3G 8% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /]
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/message
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 56K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 80K 32G 1% /tmp

    172.17.0.2 | SUCCESS | rc=0 >>
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/docker-253:2-17172279-25756dcd8ad175df8cffd86000d983a2d733ac765d66ccac19532b5b69563feb 10G 801M 9.3G 8% /
    tmpfs 32G 0 32G 0% /dev
    tmpfs 32G 0 32G 0% /sys/fs/cgroup
    /dev/mapper/centos_docker-var 985G 6.0G 929G 1% /[
    /dev/mapper/centos_docker-data 2.8T 1.1G 2.7T 1% /data/exchange
    shm 64M 0 64M 0% /dev/shm
    tmpfs 64M 228K 64M 1% /run
    tmpfs 64M 0 64M 0% /var/log/journal
    tmpfs 32G 112K 32G 1% /tmp

    6.记录:

    [root@docker ~]# docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)|awk -F '-' '{print $1,$2}'|awk -F '/' '{print $2}'
    ansible 172.17.0.10
    rabbitmq 172.17.0.9
    mysql 172.17.0.8
    redis 172.17.0.7
    mongodb 172.17.0.6
    statistics 172.17.0.5
    filter 172.17.0.4
    message 172.17.0.3
    java 172.17.0.2
    [root@docker ~]#

  • 相关阅读:
    C++的精髓——代码复用、接口复用
    静态库和动态库的区别和win平台和linux平台代码实现
    windows工程总结
    预编译头文件stdafx.h-stdafx.cpp-stdafx.pch(pre-compile headfile)
    linux调用库的方式
    Window 32位 编程总结
    读Zepto源码之内部方法
    读Zepto源码之代码结构
    再谈 javascript 数组去重
    把axios封装为vue插件使用
  • 原文地址:https://www.cnblogs.com/Jt00/p/6994293.html
Copyright © 2020-2023  润新知