基于docker swarm集群实验 -- 2020/8/10

docker集群

1、安装好4台docker机器(1c2g)

docker-maneger:192.168.80.1
docker-2:192.168.80.2
docker-3:192.168.80.3
docker-4:192.168.80.4
LB-1:ens33:192.168.0.207  ens37:192.168.80.208

2、开启路由功能

$ vim snat.sh

iptables -F
iptables -t nat -F
echo 1 >/proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.80.0/24 -o ens33 -j SNAT --to-source 192.168.0.207
[root@LB-1 ~]# bash snat.sh 
[root@LB-1 ~]# iptables -L -t nat -vn
Chain PREROUTING (policy ACCEPT 1 packets, 147 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain INPUT (policy ACCEPT 1 packets, 147 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 1 packets, 108 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 1 packets, 108 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 SNAT       all  --  *      ens33   192.168.80.0/24      0.0.0.0/0            to:192.168.0.207

关闭防火墙、selinux

systemctl stop firewalld
systemctl disable firewalld
sed -i's/=enforcing/=disabled/'

3、在管理节点docker机器上配置swarm

docker swarm init --advertise-addr 192.168.80.1

在工作节点上加入

    docker swarm join \
    --token SWMTKN-1-4crsq2chuxhtd4a1bb0eo0bh1gpvgjchgx6141zhe7xe0oh8of-0nwyw4o5l3rimiv6c3jsd2yl4 \
    192.168.80.1:2377

4、获取centos7的镜像

docker pull docker.io/sglim2/centos7

5、在manager节点上配置Dockerfile,自制nginx镜像

FROM docker.io/sglim2/centos7

MAINTAINER Ekko

ENV company dtstack
WORKDIR /
COPY nginx-1.18.0.tar.gz /

RUN yum install -y zlib zlib-devel openssl-devel pcre pcre-devel gcc gcc-c++ autoconf automake make \
    && tar xf nginx-1.18.0.tar.gz \
    && cd nginx-1.18.0 \
    && ./configure  --prefix=/usr/local/nginx --
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值