[英]MySQL Cluster - Create new table but not found in other mysql server
i Have create a mysql cluster with docker-compose.我已经用 docker-compose 创建了一个 mysql 集群。
version: '3.9'
services:
management:
image: mysql/mysql-cluster:8.0
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
command: ndb_mgmd
networks:
mysqlcluster:
ipv4_address: 172.28.0.1
ndb1:
image: mysql/mysql-cluster:8.0
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
command: ndbd
depends_on:
- "management"
networks:
mysqlcluster:
ipv4_address: 172.28.0.21
ndb2:
image: mysql/mysql-cluster:8.0
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
command: ndbd
depends_on:
- "management"
networks:
mysqlcluster:
ipv4_address: 172.28.0.22
ndb3:
image: mysql/mysql-cluster:8.0
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
command: ndbd
depends_on:
- "management"
networks:
mysqlcluster:
ipv4_address: 172.28.0.23
ndb4:
image: mysql/mysql-cluster:8.0
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
command: ndbd
depends_on:
- "management"
networks:
mysqlcluster:
ipv4_address: 172.28.0.24
mysql1:
image: mysql/mysql-cluster:8.0
ports:
- "2201:3306"
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
- ./data/mysql1:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: bdteste
MYSQL_USER: teste
MYSQL_PASSWORD: teste
MYSQL_ROOT_HOST: '%'
command: mysqld
depends_on:
- "management"
- "ndb1"
- "ndb2"
- "ndb3"
- "ndb4"
networks:
mysqlcluster:
ipv4_address: 172.28.0.11
mysql2:
image: mysql/mysql-cluster:8.0
ports:
- "2202:3306"
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
- ./data/mysql2:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: bdteste
MYSQL_USER: teste
MYSQL_PASSWORD: teste
MYSQL_ROOT_HOST: '%'
command: mysqld
depends_on:
- "management"
- "ndb1"
- "ndb2"
- "ndb3"
- "ndb4"
networks:
mysqlcluster:
ipv4_address: 172.28.0.12
mysql3:
image: mysql/mysql-cluster:8.0
ports:
- "2203:3306"
volumes:
- ./mysql.conf/my.cnf:/etc/my.cnf
- ./mysql.conf/mysql-cluster.cnf:/etc/mysql-cluster.cnf
- /etc/localtime:/etc/localtime:ro
- ./data/mysql2:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: bdteste
MYSQL_USER: teste
MYSQL_PASSWORD: teste
MYSQL_ROOT_HOST: '%'
command: mysqld
depends_on:
- "management"
- "ndb1"
- "ndb2"
- "ndb3"
- "ndb4"
networks:
mysqlcluster:
ipv4_address: 172.28.0.13
adminer:
image: adminer
restart: always
ports:
- 8888:8080
links:
- mysql1:db
networks:
mysqlcluster:
networks:
mysqlcluster:
driver: bridge
ipam:
config:
- subnet: 172.28.0.0/16
gateway: 172.28.5.254
All running and work well:一切运行良好:
bash-4.4# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 172.28.0.1:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 6 node(s)
id=21 @172.28.0.21 (mysql-8.0.30 ndb-8.0.30, Nodegroup: 0, *)
id=22 @172.28.0.22 (mysql-8.0.30 ndb-8.0.30, Nodegroup: 0)
id=23 @172.28.0.23 (mysql-8.0.30 ndb-8.0.30, Nodegroup: 1)
id=24 @172.28.0.24 (mysql-8.0.30 ndb-8.0.30, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @172.28.0.1 (mysql-8.0.30 ndb-8.0.30)
[mysqld(API)] 4 node(s)
id=11 @172.28.0.11 (mysql-8.0.30 ndb-8.0.30)
id=12 @172.28.0.12 (mysql-8.0.30 ndb-8.0.30)
From client i create new database and new table on 172.28.0.11 and i am insert new row, All work well.从客户端,我在 172.28.0.11 上创建新数据库和新表,并且插入新行,一切正常。 But if i am connect to 172.28.0.12 database exist but empty table, new table that i am create on 172.28.0.11 not detected on 172.28.0.12.
但是如果我连接到 172.28.0.12 数据库存在但空表,我在 172.28.0.11 上创建的新表在 172.28.0.12 上未检测到。
Any sugestions?有什么建议吗? Thanks
谢谢
Sorry, This my fault.对不起,这是我的错。 Base on documentation
基于文档
https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-install-example-data.html https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-install-example-data.html
We must create table with ENGINE=NDBCLUSTER我们必须使用 ENGINE=NDBCLUSTER 创建表
After i recreate all table with ENGINE=NDBCLUSTER, every mysql server now sync the table.在我使用 ENGINE=NDBCLUSTER 重新创建所有表后,每个 mysql 服务器现在同步表。 Thanks
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.