集群实战(1):swarm安装记述

查看主机名

hostnamectl 

修改主机名

hostnamectl set-hostname xxx

关闭selinux

sed -i 's/SELINUX=enforcing/#SELINUX=enforcing/'  /etc/selinux/config
sed -i "/#SELINUX=enforcing/a\SELINUX=disabled"   /etc/selinux/config

关闭防火墙或者开放端口

systemctl stop firewalld

修改hosts

vi /etc/hosts

安装docker

yum -y install docker

主节点初始化集群

docker swarm init --advertise-addr 192.168.6.130:2377

创建集群网络

docker network create --driver overlay 网络名

其他机器加入集群

测试

docker service create -p 80:80 --name webserver --replicas 5 httpd

注意:非必选项,修改ExecStart
(待核实,因为搭建集群后访问其他 节点并未生效,改了这个配置重启才生效。但感觉并非此问题。)

vi /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd-current -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock \
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
          --default-runtime=docker-runc \
          --exec-opt native.cgroupdriver=systemd \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
          --init-path=/usr/libexec/docker/docker-init-current \
          --seccomp-profile=/etc/docker/seccomp.json \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY \
          $REGISTRIES

参考链接:
https://blog.csdn.net/zmx729618/article/details/81709639
http://www.bubuko.com/infodetail-2433187.html
https://www.cnblogs.com/wlbl/p/10207749.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值