docker swarm 集群搭建
创建一个集群
[vagrant@node1 ~]$ docker swarm init --advertise-addr 192.168.9.101
Swarm initialized: current node (9fv7wb4zve235hltmchxprez7) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN--1wk8aduuxnay6ek866xaj31ixqnsib56b3p65hpzpcbbzo1qla-alcf8l1n7qpv7h7d6hg35scni 192.168.9.101: To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
查看网络
[vagrant@node1 ~]$ docker network ls
NETWORK ID NAME DRIVER SCOPE
83c5df0f97ac bridge bridge local
7d81897af218 docker_gwbridge bridge local
b13ca5d9c552 host host local
0vfhc5c85dwi ingress overlay swarm
c427f9d683f4 none null local
分别在另外两台上面执行
[vagrant@node2 ~]$ docker swarm join --token SWMTKN--1wk8aduuxnay6ek866xaj31ixqnsib56b3p65hpzpcbbzo1qla-alcf8l1n7qpv7h7d6hg35scni 192.168.9.101:
This node joined a swarm as a worker.
[vagrant@node3 ~]$ docker swarm join --token SWMTKN--1wk8aduuxnay6ek866xaj31ixqnsib56b3p65hpzpcbbzo1qla-alcf8l1n7qpv7h7d6hg35scni 192.168.9.101:
This node joined a swarm as a worker.
查看集群节点
[vagrant@node1 ~]$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
9fv7wb4zve235hltmchxprez7 * node1 Ready Active Leader 19.03.
lypcp8z6s2boi2897ni0g5oc5 node2 Ready Active 19.03.
o0hmpgi59tms2lt65wlgzivpn node3 Ready Active 19.03.
提升node2,node3 为备用master,高可用
[vagrant@node1 ~]$ docker node promote node2
[vagrant@node1 ~]$ docker node promote node3
查看效果:
[vagrant@node1 ~]$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
9fv7wb4zve235hltmchxprez7 * node1 Ready Active Leader 19.03.
lypcp8z6s2boi2897ni0g5oc5 node2 Ready Active Reachable 19.03.
o0hmpgi59tms2lt65wlgzivpn node3 Ready Active 19.03.
创建服务
[vagrant@node1 ~]$ docker service create --name test1 alpine ping www.baidu.com
i5lip5az4w5ehv28q2fn3jxji
overall progress: out of tasks
/: running [==================================================>]
verify: Service converged
[vagrant@node1 ~]$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
i5lip5az4w5e test1 replicated / alpine:latest
创建nginx服务
vagrant@node1 ~]$ docker service create --name nginx nginx
m511a51xd6js4lflrrtr91vf7
overall progress: out of tasks
overall progress: out of tasks
overall progress: out of tasks
overall progress: out of tasks
overall progress: out of tasks
overall progress: out of tasks
/: running [==================================================>]
verify: Service converged
爆过 8080服务
[vagrant@node1 ~]$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
m511a51xd6js nginx replicated / nginx:latest
i5lip5az4w5e test1 replicated / alpine:latest
[vagrant@node1 ~]$ docker service update --publish-add : nginx
nginx
overall progress: out of tasks
/: running [==================================================>]
verify: Service converged
[vagrant@node1 ~]$
扩容:
[vagrant@node1 ~]$ docker service scale nginx=
nginx scaled to
overall progress: out of tasks
/: running [==================================================>]
/: running [==================================================>]
/: running [==================================================>]
删除服务:
[vagrant@node1 ~]$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
m511a51xd6js nginx replicated / nginx:latest *:->/tcp
i5lip5az4w5e test1 replicated / alpine:latest
[vagrant@node1 ~]$ docker service rm nginx
nginx
[vagrant@node1 ~]$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
i5lip5az4w5e test1 replicated / alpine:latest
创建网络
[vagrant@node1 ~]$ docker network ls
NETWORK ID NAME DRIVER SCOPE
83c5df0f97ac bridge bridge local
7d81897af218 docker_gwbridge bridge local
b13ca5d9c552 host host local
0vfhc5c85dwi ingress overlay swarm
c427f9d683f4 none null local
meps4tilzidi test_tanzi-overlay overlay swarm
[vagrant@node1 ~]$ docker network
connect create disconnect inspect ls prune rm
[vagrant@node1 ~]$ docker network create -d overlay tanzi-overlay
p3ssr7hpilfr1k6qry6tp8nc5
创建服务并指定网络
[vagrant@node1 ~]$ docker service create --network tanzi-overlay --name nginx -p : nginx
p3b79k42mvex1op5mwk9zfg1z
overall progress: out of tasks
/: running [==================================================>]
verify: Service converged
[vagrant@node1 ~]$ docker service create --network tanzi-overlay --name alpine alpine ping www.baidu.com
34tkwuppcgb5pqppj1zx22hhr
overall progress: out of tasks
/: running [==================================================>]
verify: Service converged
定义一种不给外面访问的dnsrr的访问模式
[vagrant@node1 ~]$ docker service create --name nginx-b --endpoint-mode dnsrr nginx
u9snzqigr65x9xwb131jkm1ao
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
更新一个服务
[vagrant@node1 ~]$ docker service update --network-add tanzi-overlay nginx-b
nginx-b
overall progress: out of tasks
/: running [==================================================>]
verify: Service converged
定一个组,确定依赖关系:
[vagrant@node1 ~]$ docker stack services
nginx test2
[vagrant@node1 ~]$ docker stack services nginx
ID NAME MODE REPLICAS IMAGE PORTS
7ti9w26od1i3 nginx_nginx replicated / nginx:latest *:->/tcp
cl1awlwzmxaq nginx_alpine replicated / alpine:latest
[vagrant@node1 ~]$ docker stack deploy -c test.yml nginx
Updating service nginx_alpine (id: cl1awlwzmxaqybwyz09a3sr5t)
Updating service nginx_nginx (id: 7ti9w26od1i3yec6jmxcalwfz)
[vagrant@node1 ~]$ docker stack services
"docker stack services" requires exactly argument.
See 'docker stack services --help'. Usage: docker stack services [OPTIONS] STACK List the services in the stack
[vagrant@node1 ~]$ docker stack services ls
Nothing found in stack: ls
[vagrant@node1 ~]$ docker stack services
nginx test2
[vagrant@node1 ~]$ docker stack services test2
ID NAME MODE REPLICAS IMAGE PORTS
celxgkxf3z31 test2_alpine replicated / alpine:latest
[vagrant@node1 ~]$ docker stack services nginx
ID NAME MODE REPLICAS IMAGE PORTS
7ti9w26od1i3 nginx_nginx replicated / nginx:latest *:->/tcp
cl1awlwzmxaq nginx_alpine replicated / alpine:latest
version: "3.7"
services:
nginx:
image: nginx
networks:
- "tanzi-overlay"
ports:
- "8080:80" alpine:
image: alpine
networks:
- "tanzi-overlay"
command:
- "ping"
- "nginx"
deploy:
replicas:
restart_policy:
condition: on-failure
resources:
limits:
cpus: "0.1"
memory: 50M
depends_on:
- nginx networks:
tanzi-overlay:
external: true
docker swarm 集群搭建的更多相关文章
- docker swarm集群搭建及使用Portainer、shipyard
一.规划 1.swarm01作为manager节点,swarm02和swarm03作为worker节点. # cat /etc/hosts 127.0.0.1 localhost 192.168. ...
- 分享:docker swarm集群搭建
[Y_H]实践原创 三台虚拟机:1台centOS , 2台ubuntu. 网上有用docker-machine创建虚拟机做的例子. 这里直接用VMware创建这三台虚拟机,然后用xshell连 ...
- docker swarm集群搭建以及使用滚动更新
基础环境,三台虚拟机 172.17.3.70 172.17.3.71 172.17.3.72 系统配置:centos 7,关闭selinux 需要优化的基础配置: [root@sw1 ~]# vim ...
- Docker swarm集群搭建教程
一.什么是Swarm Swarm这个项目名称特别贴切.在Wiki的解释中,Swarm behavior是指动物的群集行为.比如我们常见的蜂群,鱼群,秋天往南飞的雁群都可以称作Swarm behavio ...
- DOCKER 学习笔记8 Docker Swarm 集群搭建
前言 在前面的文章中,已经介绍如何在本地通过Docker Machine 创建虚拟Docker 主机,以及也可以在本地Windows 创建虚拟主机,也是可以使用的.这一节,我们将继续学习 Docker ...
- docker swarm集群搭建
本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: swarm是docker原生的集群管理软件,与kuberne ...
- 从零开始搭建Docker Swarm集群
从零开始搭建Docker Swarm集群 检查节点Docker配置 1. 打开Docker配置文件(示例是centos 7)vim /etc/sysconfig/docker2. 添加-H tcp:/ ...
- Docker系列之swarm集群搭建
学习Docker很久了,今天分享一下Docker的swarm集群的搭建过程很简单 首先第一步是 每台机器上面都要安装docker 本人使用的是centos7操作系统,使用3太虚拟机,3太虚拟机必须网络 ...
- Docker Swarm 集群环境搭建及弹性服务部署
上一篇文章<Docker Swarm 集群管理利器核心概念扫盲>中我们把 Swarm 重要的概念性知识给大家讲解了一波,理论完事就该实战了,这篇文章带大家从零开始,搭建 Docker Sw ...
随机推荐
- 海思3519A 开发环境设置相关
设置板卡和虚拟机的网络参数 setenv serverip 192.168.1.107 setenv ipaddr 192.168.1.10 setenv gatewayip 192.168.1.1 ...
- Httpd服务进阶知识-LAMP源码编译安装
Httpd服务进阶知识-LAMP源码编译安装 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 想必大家都知道,动态资源交给fastcgi程序处理,静态资源依旧由httpd服务器处理 ...
- SpringCloud2.0 Eureka Client 服务注册 基础教程(三)
1.创建[服务提供者],即 Eureka Client 1.1.新建 Spring Boot 工程,工程名称:springcloud-eureka-client 1.2.工程 pom.xml 文件添加 ...
- 后台返回的base64的图片格式,前端如何转为普通的图片格式
在上一篇的博客当中,写了前端如何将普通的图片格式转为base64的图片,今天开发的时候遇到了后台返回的图片格式是base64的,我这边需要把base64的图片格式转为普通的,搜了一下js的方法,感觉很 ...
- seaborn---调色板
一.样式控制 1.set([context,style,palette,font,...]) 一步设定美学参数. 2.axes_style([style,rc]) 返回参数字典,用于绘图的美学风格. ...
- [译] 揭秘 iOS 布局
翻译自:Demystifying iOS Layout 在你刚开始开发 iOS 应用时,最难避免或者是调试的就是和布局相关的问题.通常这种问题发生的原因就是对于 view 何时真正更新的错误理解.想理 ...
- Spring的三大核心思想:IOC(控制反转),DI(依赖注入),AOP(面向切面编程)
Spring核心思想,IoC与DI详解(如果还不明白,放弃java吧) 1.IoC是什么? IoC(Inversion of Control)控制反转,IoC是一种新的Java编程模式,目前很多 ...
- Mac 上 brew 安装Tomcat
首先保证brew命令能够正常使用: 搜索tomcat是否存在:brew search tomcat 安装tomcat:brew install tomcat 检查是否安装成功:catalina -h ...
- python语言(二)列表、字典、集合、文件读写、关系测试
1.列表 list 代码 s = '王宇建,苏红,邹存才...' # 列表 数字 list l = ['王宇建','苏红','邹存才'] # 一维数组 二维数组 三维数组 # 0 1 2 # 索引 ...
- GridControl 使用方法篇 --- 隐藏表头、隐藏Group by Box