在Docker1.12版本中,一个大的功能点是swarm集群(基于swarmkit项目),通过docker命令可以直接实现docker-engine相互发现,并组建成为一个容器集群。有关集群的docker命令如下:
swarm命令用于集群管理,子命令如下:
[root@host1 ~]# docker swarm --help
Usage: dockerswarmCOMMAND
ManageDockerSwarm
Options:
--help Printusage
Commands:
init Initialize a Swarm.
join Join a Swarmas a nodeand/or manager.
update updatetheSwarm.
leave Leave a Swarm.
inspect InspecttheSwarm
Run 'docker swarm COMMAND --help' for moreinformationon a command.
可以看到,提供了init、join、update、leave、inspect命令
[root@host1 ~]# docker swarm init --help
Usage: dockerswarminit [OPTIONS]
Initialize a Swarm.
Options:
--auto-acceptvalue Autoacceptancepolicy (worker, manager, or none)
--force-new-cluster Forcecreate a new clusterfromcurrentstate.
--help Printusage
--listen-addrvalue Listenaddress (default 0.0.0.0:2377)
--secretstring Setsecretvalueneededto acceptnodesintocluster
在第一个节点上运行init命令初始化一个集群,初始化完成后会监听2377端口,接受其他节点的加入请求
[root@host1 ~]# docker swarm init Swarminitialized: currentnode (6mjmescd8473lh6jpvmx2khkq) is now a manager.
[root@host1 ~]# docker swarm join --help
Usage: dockerswarmjoin [OPTIONS] HOST:PORT
Join a Swarmas a nodeand/or manager.
Options:
--ca-hashstring HashoftheRootCertificateAuthoritycertificateusedfor trustedjoin
--help Printusage
--listen-addrvalue Listenaddress (default 0.0.0.0:2377)
--manager Try joiningas a manager.
--secretstring Secretfor nodeacceptance
在第二个、第三个节点上通过join命令加入集群
[root@host2 ~]# docker swarm join 186.100.40.90:2377
This nodejoined a Swarmas a worker.
[root@host3 ~]# docker swarm join 186.100.40.90:2377
This nodejoined a Swarmas a worker.
在第一个节点上,通过docker node ls查看节点信息
[root@host1 ~]# docker node ls
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGERSTATUS LEADER
3xto6bh4htx7thj7b222datfd host2 Accepted Ready Active
6mjmescd8473lh6jpvmx2khkq * host1 Accepted Ready Active Reachable Yes
bwkk0n044fuod36dvghi9jbkv host3 Accepted Ready Active
可以看到当前集群中有3个节点,Manager节点为host1,由于当前只有一个manager,所以这一节点也为是leader(swarmkit采用raft协议构建集群)
[root@host1 ~]# docker swarm inspect
[
{
"ID": "90wkw2fmy0x5fjlh0mtuhtkrd",
"Version": {
"Index": 11
},
"CreatedAt": "2016-06-19T12:47:40.260925387Z",
"UpdatedAt": "2016-06-19T12:47:40.665401298Z",
"Spec": {
"Name": "default",
"AcceptancePolicy": {
"Policies": [
{
"Role": "worker",
"Autoaccept": true
},
{
"Role": "manager",
"Autoaccept": false
}
]
},
"Orchestration": {
"TaskHistoryRetentionLimit": 10
},
"Raft": {
"SnapshotInterval": 10000,
"LogEntriesForSlowFollowers": 500,
"HeartbeatTick": 1,
"ElectionTick": 3
},
"Dispatcher": {
"HeartbeatPeriod": 5000000000
},
"CAConfig": {
"NodeCertExpiry": 7776000000000000
}
}
}
]
通过service命令可以管理一个服务,子命令如下:
[root@host1 ~]# docker service --help
Usage: dockerserviceCOMMAND
ManageDockerservices
Options:
--help Printusage
Commands:
create Create a new service
inspect Inspect a service
tasks Listthetasksof a service
ls Listservices
rm Remove a service
scale Scaleoneor multipleservices
update Update a service
Run 'docker service COMMAND --help' for moreinformationon a command.
(1)service create命令用于创建一个服务[root@host1 ~]# docker service create –help
Usage: dockerservicecreate [OPTIONS] IMAGE [COMMAND] [ARG...]
Create a new service
Options:
--constraintvalue Placementconstraints (default [])
--endpoint-modestring Endpointmode(Validvalues: VIP, DNSRR)
-e, --envvalue Setenvironmentvariables (default [])
--help Printusage
-l, --labelvalue Servicelabels (default [])
--limit-cpuvalue LimitCPUs
--limit-memoryvalue LimitMemory
--modestring Servicemode (replicatedor global) (default "replicated")
-m, --mountvalue Attach a mountto theservice
--namestring Servicename
--networkvalue Networkattachments (default [])
-p, --publishvalue Publish a portas a nodeport (default [])
--replicasvalue Numberoftasks (default none)
--reserve-cpuvalue ReserveCPUs
--reserve-memoryvalue ReserveMemory
--restart-conditionstring Restartwhenconditionis met (none, on_failure, or any)
--restart-delayvalue Delaybetweenrestartattempts (default none)
--restart-max-attemptsvalue Maximumnumberofrestartsbeforegivingup (default none)
--restart-windowvalue Windowusedto evalulatetherestartpolicy (default none)
--stop-grace-periodvalue Timeto waitbeforeforcekilling a container (default none)
--update-delayduration Delaybetweenupdates
--update-parallelismuint Maximumnumberoftasksupdatedsimultaneously (default 1)
-u, --userstring Usernameor UID
-w, --workdirstring Workingdirectoryinsidethecontainer
在参数中有两个比较重要的参数: * replicas用于描述服务对应的实例数 * mode用来描述服务的类型,replicated多实例类型,global全局服务类型(在每一个节点上都会创建)
在第一个节点上,通过create命令创建服务:
[root@host1 ~]# docker service create --name test_service --replicas 2 busybox ping 186.100.40.1
et1i181ni4dj2ocm1l4frbqzm
[root@host1 ~]# docker service ls
ID NAME SCALE IMAGE COMMAND
et1i181ni4dj test_service 2 busybox ping 186.100.40.1
[root@host1 ~]# docker service tasks test_service
ID NAME SERVICE IMAGE LASTSTATE DESIREDSTATE NODE
1yewid0xbviyggyvjv10adjrs test_service.1 test_service busybox RunningAbout a minute Running host3
9l4z9aqlg9iwums14yxu0lym7 test_service.2 test_service busybox RunningAbout a minute Running host1
可以看到,刚才创建的service对应的2个实例分别在host3和host1上
对刚才创建的service实力数目进行更新
[root@host1 ~]# docker service update --replicas 3 test_service
test_service
[root@host1 ~]# docker service tasks test_service
ID NAME SERVICE IMAGE LASTSTATE DESIREDSTATE NODE
1yewid0xbviyggyvjv10adjrs test_service.1 test_service busybox Running 5 minutes Running host3
9l4z9aqlg9iwums14yxu0lym7 test_service.2 test_service busybox Running 5 minutes Running host1
emnuxg8sb37hbxbpdt63mpy1a test_service.3 test_service busybox Running 18 seconds Running host2
[root@host1 ~]# docker service inspect test_service
[
{
"ID": "et1i181ni4dj2ocm1l4frbqzm",
"Version": {
"Index": 33
},
"CreatedAt": "2016-06-19T13:07:29.549242777Z",
"UpdatedAt": "2016-06-19T13:12:23.210552545Z",
"Spec": {
"Name": "test_service",
"TaskTemplate": {
"ContainerSpec": {
"Image": "busybox",
"Args": [
"ping",
"186.100.40.1"
]
},
"Resources": {
"Limits": {},
"Reservations": {}
},
"RestartPolicy": {
"Condition": "any",
"MaxAttempts": 0
},
"Placement": {}
},
"Mode": {
"Replicated": {
"Replicas": 3
}
},
"UpdateConfig": {
"Parallelism": 1
},
"EndpointSpec": {
"Mode": "vip"
}
},
"Endpoint": {
"Spec": {}
}
}
]
node命令用户节点管理,比如将一个节点变为manager节点、同意节点加入请求等。
[root@host1 ~]# docker node --help
Usage: dockernodeCOMMAND
ManageDockerSwarmnodes
Options:
--help Printusage
Commands:
accept Accept a nodein theswarm
demote Demote a nodefrommanagerin theswarm
inspect Inspect a nodein theswarm
ls Listnodesin theswarm
promote Promote a nodeto a managerin theswarm
rm Remove a nodefromtheswarm
tasks Listtasksrunningon a node
update Update a node
Run 'docker node COMMAND --help' for moreinformationon a command.
accpet命令用户同意节点加入请求,在初始化swarm集群时候通过–auto-accept可以指定节点默认加入的较色,如果为none的话,需要通过accpet命令同意加入节点,成为worker节点 重新初始化三节点,集群初始化时,采用–auto-accept=none,最终可以看到新加入的两个节点MEMBERSHIP为Pending
[root@host1 ~]# docker node ls
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGERSTATUS LEADER
15wyq8vc1vxe7r4n3yyl0p93j * host1 Accepted Ready Active Reachable Yes
2fh91rbwtj2xosqixzlc7s3mg Pending Unknown Active
5okhpif49b4d6byohpdr4vdmw Pending Unknown Active
通过accept命令同意节点加入:
[root@host1 ~]# docker node accept 2fh91rbwtj2xosqixzlc7s3mg 2fh91rbwtj2xosqixzlc7s3mg [root@host1 ~]# docker node ls ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGERSTATUS LEADER 15wyq8vc1vxe7r4n3yyl0p93j * host1 Accepted Ready Active Reachable Yes 2fh91rbwtj2xosqixzlc7s3mg host3 Accepted Ready Active 5okhpif49b4d6byohpdr4vdmw Pending Unknown Active [root@host1 ~]# docker node accept 5okhpif49b4d6byohpdr4vdmw 5okhpif49b4d6byohpdr4vdmw 5okhpif49b4d6byohpdr4vdmw attemptingto accept a nodein theswarm. [root@host1 ~]# docker node ls ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGERSTATUS LEADER 15wyq8vc1vxe7r4n3yyl0p93j * host1 Accepted Ready Active Reachable Yes 2fh91rbwtj2xosqixzlc7s3mg host3 Accepted Ready Active 5okhpif49b4d6byohpdr4vdmw host2 Accepted Ready Active
[root@host1 ~]# docker node promote 2fh91rbwtj2xosqixzlc7s3mg
2fh91rbwtj2xosqixzlc7s3mg
2fh91rbwtj2xosqixzlc7s3mg attemptingto promote a nodeto a managerin theswarm.
[root@host1 ~]# docker node ls
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGERSTATUS LEADER
15wyq8vc1vxe7r4n3yyl0p93j * host1 Accepted Ready Active Reachable Yes
2fh91rbwtj2xosqixzlc7s3mg host3 Accepted Ready Active Reachable
5okhpif49b4d6byohpdr4vdmw host2 Accepted Ready Active
[root@host1 ~]# docker node promote 5okhpif49b4d6byohpdr4vdmw
5okhpif49b4d6byohpdr4vdmw
5okhpif49b4d6byohpdr4vdmw attemptingto promote a nodeto a managerin theswarm.
[root@host1 ~]# docker node ls
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGERSTATUS LEADER
15wyq8vc1vxe7r4n3yyl0p93j * host1 Accepted Ready Active Reachable Yes
2fh91rbwtj2xosqixzlc7s3mg host3 Accepted Ready Active Reachable
5okhpif49b4d6byohpdr4vdmw host2 Accepted Ready Active Reachable
[root@host1 ~]# docker node demote 15wyq8vc1vxe7r4n3yyl0p93j
15wyq8vc1vxe7r4n3yyl0p93j
15wyq8vc1vxe7r4n3yyl0p93j attemptingto demote a managerin theswarm.
[root@host1 ~]# docker node ls
Errorresponsefromdaemon: rpcerror: code = 4 desc = contextdeadlineexceeded
可以看到变为worker节点以后,就无法再此节点上对集群进行管理
[root@host2 ~]# docker node ls
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGERSTATUS LEADER
15wyq8vc1vxe7r4n3yyl0p93j host1 Accepted Ready Active
2fh91rbwtj2xosqixzlc7s3mg host3 Accepted Ready Active Reachable Yes
5okhpif49b4d6byohpdr4vdmw * host2 Accepted Ready Active Reachable
可以看到此时,host2已经变为了leader
[root@host2 ~]# docker node update --help
Usage: dockernodeupdate [OPTIONS] NODE
Update a node
Options:
--availabilitystring Availabilityofthenode (active/pause/drain)
--help Printusage
--membershipstring Membershipofthenode (accepted/rejected)
--rolestring Roleofthenode (worker/manager)
这两个命令都是experiment阶段,用来部署一个STACK,一个STACK可以描述多个service。 在创建Stack前,需要通过compose.yml文件描述一个组应用,然后再用compose bundle产生一个dsb文件,用户stack的创建。
[root@host2 ~]# docker stack --help
Usage: dockerstackCOMMAND
ManageDockerstacks
Options:
--help Printusage
Commands:
config Printthestackconfiguration
deploy Createand update a stack
rm Removethestack
tasks Listthetasksin thestack
Run 'docker stack COMMAND --help' for moreinformationon a command.
Docker1.12通过swarm实现了容器集群,在集群之上可以service命令创建一个服务,实现服务的多实例。在服务之上,通过stack可以描述一组服务,最终实现一个大系统的部署。可见,Docker在公司在下一盘很大的棋,从镜像生态到容器引擎,从容器引擎到容器集群,Anything is possible in Docker。
文章浏览阅读3.7k次,点赞3次,收藏10次。1、先启动wincc 双击计算机,并勾选变量记录运行系统,在激活项目 点击变量管理,点击变量记录,归档名tank_archives _excel 通过opcua获取wincc归档数据
文章浏览阅读785次。工具: 反编译工具 dnspy过程:打开压缩包,发现是一个扫雷游戏,选择反编译工具通过修改源码完成游戏,得到flag1.用dnspy打开Assembly-CSharp.dll文件路径:\Mine Sweeping\Mine Sweeping_Data\Managed\2.打开后找到使游戏结束的代码段 如下3.经分析,将this.bIsMine改成false后,即使点击到雷,游戏也不会结束,具体操作如下4.保存修改后的模块5.再次打开扫雷游戏,把所有的..._ctf assembly-csharp.dll
文章浏览阅读2.2w次,点赞8次,收藏45次。系统环境:Ubuntu 16.04虚拟机:VM12Linux 死机有很多种情况,最常见的是系统负载过高导致的。可以是运行内存耗用极大的程序,也会迅速提升系统负载。由于系统负载过高导致的卡死,一定是解决的越快越好!不能再试图依赖任何图形界面的东西,因为鼠标都没有用,而且使用开启终端命令也没有用。首先 Ctrl + Alt +(F1-F6)中,进_linux虚拟机死机
文章浏览阅读5.8k次,点赞2次,收藏10次。export default { name:'xxx'}name的作用有三个:1、当项目使用keep-alive时,可搭配组件name进行缓存过滤<div id="app"> <keep-alive exclude="xxx"> <router-view/> </keep-alive></div>exclude="_vue 文件里的name有什么用
文章浏览阅读4.1k次。最近一段时间,因为公司项目的需要,对HTTP协议以及FTP协议都有所了解,并且在基于网络开放源代码 基础上,能够完成项目的要求。今天给大家分享下,怎样建立属于我们自己的FTP服务器以及FPT客户端,同时 非常非常感谢这些开源软件及其作者为IT行业做出的贡献,最大程度上至少解放了我们这些IT码农。且看正文。 本文主要内容: _android设备代码搭建ftp服务器
文章浏览阅读70次。老婆的老家边上有一个不错的度假村,度假村里有一个庙,庙是被人承包的,承包一年的费用据说是十几万,十几万之外承包人又投资几十万作一些基本的建设如装修,迎请菩萨,等等。庙里有一些剃光了脑袋的家伙,据说是和尚,和尚们都娶妻生子,此外还烧香念佛,算命解卦,不亦乐乎!在过去的十一中,据说每天的收入都好几万。有一天,我亲眼看到有个中年妇女非常气愤地从庙那边走过来,说要投诉这个庙...
文章浏览阅读7.8w次,点赞26次,收藏139次。一.背景 最近mybatis-plus框架的更新,让我们基础开发中如虎添翼。其中基本的增删改查,代码生成器想必大家用着那叫一个爽。本人在使用中,也遇到一些坑。比如savebatch,saveorupdatebatch,看着这不是批量新增,批量新增或更新嘛,看着api进行开发,感觉也太好用啦。开发完一测试,速度跟蜗牛一样,针对大数据量真是无法忍受。在控制台上发现,怎么名义上是批量插入,还是一条一条的进行插入,难怪速度龟速。二.解决办法 查阅网上资料,大体有两种解决方案:..._saveorupdatebatch
文章浏览阅读2.2k次。LCD段码屏功耗不大,很小。功耗虽然等于电压和电流的乘积,但在使用中却有独立的意义,他标志着器件消耗电能的多少,这在微型,便携设备上意义重大。在主要的平板显示器件中,PDP,FED,VFD的功耗大,而EL,LED的功耗次之。目前有人称OLED的功耗比液晶显示还低,这是个误解。OLED的功耗和LED功耗在同一数量级,但是它是主动发光器件,不需背光源,而且只有在显示时才耗电,因此和增加了背光源的液晶显..._段码屏功耗
文章浏览阅读1.9w次,点赞15次,收藏20次。问题描述:铺铜后进行DRC进行出现modified polygon冲突。如何解决:参考网上乱七八糟的解决方式未果后,我尝试看了下AD的用户手册,查找到相应部分描述如下:很显然这个冲突的出现,最可能的原因是因为铺铜中有铜块被搁置或未导入。对应规则:用户手册里也给出了参考的解决方案:显然只要将无用铜块进行合理修改或者删除即可,于是打开铺铜管理器->进行相应操作,冲突即可消除。例如:..._modified polygon错误怎么修改
文章浏览阅读2.8k次。一个正确的语义分割二分类损失函数的计算应该是如下这样的criterion = nn.BCEWithLogitsLoss(weight=None)masks_pred = net(imgs)loss = criterion(masks_pred, true_masks) #使用二分类交叉熵epoch_loss += loss.item()先前在网络最后输出时使用sigmoid,然后使用B..._criterion = nn.bcelogitsloss()
文章浏览阅读141次。41-_狂神说java 网络编程
文章浏览阅读1.1w次,点赞12次,收藏90次。导读:作者:高鹏(网名八怪),《深入理解MySQL主从原理32讲》系列文的作者。2008年开始至今一直从事Oracle/MySQL相关工作,现任易极付高级DBA,Orac..._深入理解mysql主从原理32讲