[ndbd default] # Options affecting ndbd processes on all data nodes: NoOfReplicas=2 # Number of fragment replicas DataMemory=98M # How much memory to allocate for data storage
[ndb_mgmd] # Management process options: HostName=192.168.0.105 # Hostname or IP address of management node NodeId=1 # Node ID for this Management node DataDir=/var/lib/mysql-cluster # Directory for management node log files
[ndbd] # Options for data node "A": # (one [ndbd] section per data node) HostName=192.168.0.104 # Hostname or IP address NodeId=2 # Node ID for this data node DataDir=/data/mysql-cluster/data # Directory for this data node's data files
[ndbd] # Options for data node "B”: # (one [ndbd] section per data node) HostName=192.168.0.106 # Hostname or IP address NodeId=3 # Node ID for this data node DataDir=/data/mysql-cluster/data # Directory for this data node's data files
[mysqld] # SQL node options: HostName=192.168.0.104 # Hostname or IP address # (additional mysqld connections can be # specified for this node for various # purposes such as running ndb_restore)
[mysqld] # SQL node options: HostName=192.168.0.106 # Hostname or IP address # (additional mysqld connections can be # specified for this node for various # purposes such as running ndb_restore)
初始化并启动管理服务器
1 2
cd /usr/local/bin/ ndb_mgmd --initial --configdir=/var/lib/mysql-cluster -f /var/lib/mysql-cluster/config.ini --ndb-nodeid=1
当出现以下结果的时候,表示管理服务器已经启动成功了
1 2
root@mgm:/usr/local/bin# ndb_mgmd --initial --configdir=/var/lib/mysql-cluster -f /var/lib/mysql-cluster/config.ini --ndb-nodeid=1 MySQL Cluster Management Server mysql-5.7.33 ndb-7.6.17
我们再执行 ndb_mgm 命令,可以查看当前集群的状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
root@mgm:/usr/local/bin# ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 (not connected, accepting connect from 192.168.0.104) id=3 (not connected, accepting connect from 192.168.0.106)
root@ndb1:~# /usr/local/mysql/bin/mysqld --defaults-file=/etc/mysql/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql 2021-06-20T12:23:26.874302Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2021-06-20T12:23:27.102146Z 0 [Warning] InnoDB: New log files created, LSN=45790 2021-06-20T12:23:27.145317Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2021-06-20T12:23:27.154405Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 50a15854-d1c2-11eb-9792-000c29681e23. 2021-06-20T12:23:27.155927Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2021-06-20T12:23:28.339372Z 0 [Warning] CA certificate ca.pem is self signed. 2021-06-20T12:23:28.624534Z 1 [Note] A temporary password is generated for root@localhost: sF#Hy,IuT6d#
root@ndb1:~# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.33-ndb-7.6.17-cluster-gpl MySQL Cluster Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h'forhelp. Type '\c' to clear the current input statement.