這篇文章主要講解了“compose文件怎么在swarm中創(chuàng)建集群”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“compose文件怎么在swarm中創(chuàng)建集群”吧!
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),邯山企業(yè)網(wǎng)站建設(shè),邯山品牌網(wǎng)站建設(shè),網(wǎng)站定制,邯山網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷(xiāo),網(wǎng)絡(luò)優(yōu)化,邯山網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專(zhuān)業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
一、與上面環(huán)境不一致之處: 1.使用了etcd集群集群地址為:10.0.102.214:2379,10.0.102.175:2379,10.0.102.191:2379 2.解決網(wǎng)絡(luò)通信問(wèn)題:讓docker stack 共用同一網(wǎng)絡(luò):因stack部署時(shí)會(huì)以stack名稱創(chuàng)建網(wǎng)絡(luò),所以保持相同stack名字在同一網(wǎng)絡(luò)中。如下所示: docker stack deploy -c compose_swarm_1.yaml stack名 docker stack deploy -c compose_swarm_2.yaml stack名 docker stack deploy -c compose_swarm_3.yamlstack名
各個(gè)節(jié)點(diǎn)創(chuàng)建需要掛載的目錄及準(zhǔn)備掛載的文件(如開(kāi)啟binlog的Mariadb配置文件) #mkdir /data1/ #mkdir /etc/my.cnf.d 在k8s-node-3節(jié)點(diǎn)上創(chuàng)建開(kāi)啟binlog的mariadb配置文件 # vim /etc/my.cnf.d/bin-log.cnf [MySQLd] log-bin= mysql-bin log_slave_updates = 1 expire_logs_days = 20 server-id = 211
[root@node-1 ~]# docker stack deploy -c compose_swarm_1.yaml swarm_mariadb 【見(jiàn)圖1】 [root@node-1 ~]# docker stack deploy -c compose_swarm_2.yaml swarm_mariadb 【見(jiàn)圖2】 [root@node-1 ~]# docker stack deploy -c compose_swarm_3.yaml swarm_mariadb 【見(jiàn)圖3】 檢查 [root@node-1 ~]#docker service ls 【見(jiàn)圖4】 [root@node-1 ~]# docker stack ps swarm_mariadb 【見(jiàn)圖5】 [root@node-1 ~]# docker exec -it a40e41c2219a /bin/bash [root@a40e41c2219a /]# mysql -uroot –pmypassword MariaDB [(none)]> show status like 'wsrep%'; 【見(jiàn)圖6】 或者 [root@node-1 ~]# mysql -uroot -pmypassword -h node-1 -P 3311 -e "show status like 'wsrep%';"
version: '3' services: mariadb_galera_swarm0: #service名,3個(gè)文件各不相同 deploy: replicas: 1 #每個(gè)service下只有1個(gè)容器 restart_policy: condition: on-failure delay: 10s max_attempts: 10 window: 100s placement: constraints: [node.hostname==node-1] #將容器運(yùn)行在固定節(jié)點(diǎn)之上 update_config: parallelism: 1 delay: 3m # higher than SST duration image: severalnines/mariadb:10.1 ports: - "3310:3306" #暴露的端口3個(gè)節(jié)點(diǎn)不能相同 environment: #創(chuàng)建集群相關(guān)環(huán)境務(wù)必一致 CLUSTER_NAME: "mariadb_cluster_swarm" DISCOVERY_SERVICE: "10.0.102.218:2379,10.0.102.151:2379,10.0.102.162:2379" MYSQL_ROOT_PASSWORD: "mypassword" XTRABACKUP_PASSWORD: "mypassword" command: - --innodb_buffer_pool_size=256M - --max_connections=81 volumes: #根據(jù)需求進(jìn)行掛載 - /etc/my.cnf.d:/etc/my.cnf.d - /data2:/var/lib/mysql - /etc/localtime:/etc/localtime healthcheck: interval: 5s timeout: 3s retries: 200 # interval * retries > SST duration networks: - galera_swarm #網(wǎng)絡(luò) networks: galera_swarm: driver: overlay
version: '3' services: mariadb_galera_swarm1: deploy: replicas: 1 restart_policy: condition: on-failure delay: 10s max_attempts: 10 window: 100s placement: constraints: [node.hostname==node-2] update_config: parallelism: 1 delay: 3m # higher than SST duration image: severalnines/mariadb:10.1 ports: - "3312:3306" network_mode: host environment: CLUSTER_NAME: "mariadb_cluster_swarm" DISCOVERY_SERVICE: "10.0.102.218:2379,10.0.102.151:2379,10.0.102.162:2379" MYSQL_ROOT_PASSWORD: "mypassword" XTRABACKUP_PASSWORD: "mypassword" command: - --innodb_buffer_pool_size=256M - --max_connections=81 volumes: - /etc/my.cnf.d:/etc/my.cnf.d - /data2:/var/lib/mysql - /etc/localtime:/etc/localtime healthcheck: interval: 5s timeout: 3s retries: 200 # interval * retries > SST duration networks: - galera_swarm networks: galera_swarm: driver: overlay
version: '3' services: mariadb_galera_swarm2: deploy: replicas: 1 restart_policy: condition: on-failure delay: 10s max_attempts: 10 window: 100s placement: constraints: [node.hostname==node-3] update_config: parallelism: 1 delay: 3m # higher than SST duration image: severalnines/mariadb:10.1 ports: - "3313:3306" network_mode: host environment: CLUSTER_NAME: "mariadb_cluster_swarm" DISCOVERY_SERVICE: "10.0.102.218:2379,10.0.102.151:2379,10.0.102.162:2379" MYSQL_ROOT_PASSWORD: "mypassword" XTRABACKUP_PASSWORD: "mypassword" command: - --innodb_buffer_pool_size=256M - --max_connections=81 volumes: - /etc/my.cnf.d:/etc/my.cnf.d - /data2:/var/lib/mysql - /etc/localtime:/etc/localtime healthcheck: interval: 5s timeout: 3s retries: 200 # interval * retries > SST duration networks: - galera_swarm networks: galera_swarm: driver: overla
感謝各位的閱讀,以上就是“compose文件怎么在swarm中創(chuàng)建集群”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)compose文件怎么在swarm中創(chuàng)建集群這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
網(wǎng)頁(yè)名稱:compose文件怎么在swarm中創(chuàng)建集群
網(wǎng)頁(yè)URL:http://www.chinadenli.net/article38/ipphpp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、小程序開(kāi)發(fā)、網(wǎng)站收錄、企業(yè)網(wǎng)站制作、搜索引擎優(yōu)化、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
全網(wǎng)營(yíng)銷(xiāo)推廣知識(shí)