亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

管理Docker Swarm 集群

發布時間:2020-07-29 22:00:18 來源:網絡 閱讀:212 作者:mb5ce7848ebdda2 欄目:系統運維

管理Docker Swarm 集群
1 .節點狀態變更管理
[root@manager ~]# docker node update --availability drain manager
Manager
[root@manager ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
3ugwexq8el6e9ouj1iyguxtnq * manager Ready Drain Reachable 19.03.1
6p4qed1dyurk81nuxs2b3s72p worker01 Ready Active Leader 19.03.1
zegtd8sspiw0lsctzc98cc0g4 worker02 Ready Active Reachable 19.03.1
此時manager 只能時管理節點,不能指派任務

2 . 添加標簽元數據

[root@manager ~]# docker node update --label-add GM-IDC-01 worker01

[root@manager ~]# docker node inspect worker01

"CreatedAt": "2019-08-22T07:09:10.403549405Z",
"UpdatedAt": "2019-08-22T08:16:14.952425008Z",
"Spec": {
"Labels": {
"GM-IDC-01": ""
…………………..省略了部分

3 . 節點的提權/降權

例如:將worker01,worker02都升級為管理節點

[root@manager ~]# docker node promote worker01 worker02
Node 6p4qed1dyurk81nuxs2b3s72p is already a manager.
Node zegtd8sspiw0lsctzc98cc0g4 is already a manager.

例如:將worker01,worker02都降權為普通節點

[root@manager ~]# docker node demote worker01 worker02
Manager worker01 demoted in the swarm.
Manager worker02 demoted in the swarm.

4 .退出集群
管理節點退出
[root@manager ~]# docker swarm leave –force
普通節點退出
[root@worker01 ~]# docker swarm leave

Docker Swarm 服務管理

示例:從Docker鏡像httpd 創建一個名稱為web 的服務,指定副本為2.
[root@manager ~]# docker pull httpd ##下載鏡像
注意:httpd 服務要注釋掉 'ServerName'

[root@manager ~]# docker service create --replicas 2 --name web httpd

overall progress: 2 out of 2 tasks
1/2: running
2/2: running
verify: Service converged
[root@manager ~]# docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
edfomyazxto9 web replicated 2/2 httpd:latest

顯示服務的詳細信息 (省略了部分)

[root@manager ~]# docker service inspect web
[
{
"ID": "edfomyazxto9f7t7kbau2h453",
"Version": {
"Index": 1524
},
"CreatedAt": "2019-08-22T09:38:04.259651137Z",
"UpdatedAt": "2019-08-22T09:38:04.259651137Z",
"Spec": {
"Name": "web",
"Labels": {},
"TaskTemplate": {
"ContainerSpec": {
"Image": "httpd:latest@sha256:98caed3e3a90ed9db8d25dcbb98eebe0ce56358a9dbbc940d7eb66a8e2b88252",
……………………………………………
刪除服務
[root@manager ~]# docker service rm web

2.重新加入群集,部署nginx 的web
特別注意::每一臺節點上都要有nginx 的鏡像,才能部署。

9 docker load --input mynginx ##載入鏡像,每一臺上都做
10 docker images
11 docker tag 848ea241199d nginx
12 docker images
13 clear
14 docker service create --replicas 2 --name web nginx ##指定副本為2
15 docker service logs -f web
16 docker service ls
17 docker service ps web
[root@manager ~]# docker service ps web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
pb3hw77bm022 web.1 nginx:latest manager Running Running 12 minutes ago
9f6u648z18gk web.2 nginx:latest worker01 Running Running 12 minutes ago
18 docker service inspect web
19 docker service inspect --pretty web ##查看信息
……………………………….
ContainerSpec:
Image: nginx:latest
Init: false
Resources:
Endpoint Mode: vip
服務的擴容/縮容
20 docker service scale web=3 ##服務擴容
21 docker service ps web
[root@manager ~]# docker service ps web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
pb3hw77bm022 web.1 nginx:latest manager Running Running 15 minutes ago
9f6u648z18gk web.2 nginx:latest worker01 Running Running 15 minutes ago
an6nc2lyhet5 web.3 nginx:latest worker02 Running Running 10 minutes ago

服務的縮容
[root@manager ~]# docker service scale web=1
[root@manager ~]# docker service ps web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
pb3hw77bm022 web.1 nginx:latest manager Running Running 17 minutes ago

添加Overlay網絡
在Swarm 集群中。添加Overlay網絡時,可以連接一個或多個服務。那么處于該網絡中的所有容器之間都可以進行通信!!
1.管理節點創建
[root@manager ~]# docker network create --driver overlay my-network
0c5k9xirc0pp1a9qqgoksvyf5
2.創建服務,使用my-network 網絡

[root@manager ~]# docker service create --replicas 3 --network my-network --name myweb nginx
mm3gtfocd8dm63a2d3b4uivjq
overall progress: 3 out of 3 tasks
1/3: running
2/3: running
3/3: running
verify: Service converged

數據卷的創建與應用

創建數據卷
[root@manager _data]# docker volume create product-kgc
product-kgc
查看創建的數據卷
[root@manager _data]# docker volume ls
DRIVER VOLUME NAME
local product-kgc
創建本機上的目錄
[root@manager _data]# mkdir -p /usr/share/nginx/html
創建容器
[root@manager _data]# docker service create --mount type=volume,src=product-kgc,dst=/usr/share/nginx/html --replicas 1 --name kgc-web-01 nginx ##鏡像的存在
查看創建的容器
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
bbqd215gwlog kgc-web-01.1 nginx:latest manager Running Running 11 minutes ago
查看數據卷的詳細信息
[root@manager ~]# docker volume inspect product-kgc
[
{
"CreatedAt": "2019-08-25T09:25:30+08:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/product-kgc/_data",
"Name": "product-kgc",
"Options": {},
"Scope": "local"
}
]
查看數據是否同步
[root@manager ~]# cd /var/lib/docker/volumes/product-kgc/_data/
[root@manager ~]# mkdir test01 test02
[root@manager ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32f426b2a047 nginx:latest "/run.sh" 16 minutes ago Up 16 minutes 80/tcp, 443/tcp kgc-web-01.1.bbqd215gwlog1v4a5j2ck2nvq
進入容器,查看 ##在本地目錄下創建的目錄,容器中也存在
[root@manager _data]# docker exec -it 32f426b2a047 bash
[root@32f426b2a047 nginx]# ls /usr/share/nginx/html/
test01 test02

附加::第二種方式創建數據卷,可以采用 bind 類型

[root@manager ~]# docker service create --replicas 3 --mount type=bind,src=/var/vhost/www/aa,dst=/usr/share/nginx/html --name kgc-web-02 nginx
d6c5iw9gxo980embkb7aas1ky
overall progress: 3 out of 3 tasks
1/3: running
2/3: running
3/3: running
verify: Service converged

[root@manager ~]# touch /var/vhost/www/aa/abcd
[root@manager ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
807ff87f1b2b nginx:latest "/run.sh" 40 minutes ago Up 40 minutes 80/tcp, 443/tcp kgc-web-02.2.pkwe5ql9oaf7994iv5qt44cke
32f426b2a047 nginx:latest "/run.sh" About an hour ago Up About an hour 80/tcp, 443/tcp kgc-web-01.1.bbqd215gwlog1v4a5j2ck2nvq
4f71487e7989 nginx:latest "/run.sh" About an hour ago Created myweb.2.j771vgcjzw0t3cne3fauz3ydf
d4c2cf0b0953 nginx:latest "/run.sh" About an hour ago Created myweb.1.hayst7oh5ck442xl9g51e54xl
[root@manager ~]# docker exec -it 807ff87f1b2b bash
[root@807ff87f1b2b nginx]# ls /usr/share/nginx/html/
abcd
驗證成功!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

泾源县| 肥东县| 育儿| 锦屏县| 右玉县| 福清市| 清新县| 嘉祥县| 额济纳旗| 彩票| 喀什市| 崇义县| 留坝县| 科技| 定兴县| 台安县| 汝州市| 祁连县| 滁州市| 西宁市| 万安县| 南乐县| 麻江县| 汉寿县| 昆山市| 新泰市| 望都县| 漳浦县| 临江市| 石嘴山市| 赤壁市| 新河县| 华蓥市| 兴隆县| 台北市| 桐城市| 山阳县| 平南县| 垣曲县| 丰顺县| 武功县|