您好,登錄后才能下訂單哦!
這篇文章主要講解了“compose文件怎么在swarm中創建集群”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“compose文件怎么在swarm中創建集群”吧!
一、與上面環境不一致之處: 1.使用了etcd集群 集群地址為:10.0.102.214:2379,10.0.102.175:2379,10.0.102.191:2379 2.解決網絡通信問題: 讓docker stack 共用同一網絡:因stack部署時會以stack名稱創建網絡,所以保持相同stack名字在同一網絡中。如下所示: 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名
各個節點創建需要掛載的目錄及準備掛載的文件(如開啟binlog的Mariadb配置文件) #mkdir /data1/ #mkdir /etc/my.cnf.d 在k8s-node-3節點上創建開啟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 【見圖1】 [root@node-1 ~]# docker stack deploy -c compose_swarm_2.yaml swarm_mariadb 【見圖2】 [root@node-1 ~]# docker stack deploy -c compose_swarm_3.yaml swarm_mariadb 【見圖3】 檢查 [root@node-1 ~]#docker service ls 【見圖4】 [root@node-1 ~]# docker stack ps swarm_mariadb 【見圖5】 [root@node-1 ~]# docker exec -it a40e41c2219a /bin/bash [root@a40e41c2219a /]# mysql -uroot –pmypassword MariaDB [(none)]> show status like 'wsrep%'; 【見圖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個文件各不相同 deploy: replicas: 1 #每個service下只有1個容器 restart_policy: condition: on-failure delay: 10s max_attempts: 10 window: 100s placement: constraints: [node.hostname==node-1] #將容器運行在固定節點之上 update_config: parallelism: 1 delay: 3m # higher than SST duration image: severalnines/mariadb:10.1 ports: - "3310:3306" #暴露的端口3個節點不能相同 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_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中創建集群”的內容了,經過本文的學習后,相信大家對compose文件怎么在swarm中創建集群這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。