环境:
centos6.8
mysql-cluster版本:
mysql-cluster-gpl-7.4.11-linux-glibc2.5-x86_64.tar.gz
节点分配:
192.168.41.203 SQL节点
192.168.41.204 NDB节点1 SQL节点
192.168.41.205 NDB节点2 SQL节点
192.168.41.206 Manager节点
mysqld服务只需要安装在SQL节点,NDB和Manager只需可执行的二进制脚本和配置文件
安装
192.168.41.203 SQL节点
192.168.41.204 SQL节点
192.168.41.205 SQL节点
shell>groupadd mysql
shell>useradd -g mysql -s /bin/false mysql
shell>tar -xzvf mysql-cluster-gpl-7.4.12-linux2.6.tar.gz
shell> mvmysql-cluster-gpl-7.4.12-linux2.6-i686 /usr/local/mysql
shell>cd mysql
shell>scripts/mysql_install_db --user=mysql
shell>chown -R root .
shell>chown -R mysql data
shell>chgrp -R mysql .
shell>cp support-files/mysql.server /etc/rc.d/init.d/mysqld
shell>chmod +x /etc/rc.d/init.d/mysqld
shell>chkconfig --add mysqld
192.168.41.204 NDB节点1
192.168.41.205 NDB节点2
shell>cp mysql/bin/ndbd /usr/local/bin/ndbd
shell>cp mysql/bin/ndbmtd /usr/local/bin/ndbmtd
shell>cd /usr/local/bin
shell>chmod +x ndb*
192.168.41.206 Manager节点
shell> cp mysql/bin/ndb_mgm* /usr/local/bin
shell>cd /usr/local/bin
shell>chmod +x ndb_mgm*
集群各节点配置文件
192.168.41.203 SQL节点
192.168.41.204 NDB节点1 SQL节点
192.168.41.205 NDB节点2 SQL节点
shell> vi /etc/my.cnf
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=192.168.0.10 # location of management server
192.168.41.206 Manager节点
shell>mkdir /var/lib/mysql-cluster
shell>cd /var/lib/mysql-cluster
shell>vi config.ini
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
[tcp default]
# TCP/IP options:
portnumber=2202 # This the default; however, you can use any
# port that is free for all the hosts in the cluster
# Note: It is recommended that you do not specify the port
# number at all and simply allow the default value to be used
# instead
[ndb_mgmd]
# Management process options:
hostname=192.168.0.10 # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node log files
[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
hostname=192.168.0.30 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[ndbd]
# Options for data node "B":
hostname=192.168.0.40 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[mysqld]
# SQL node options:
hostname=192.168.0.20 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
集群各个节点启动
192.168.41.206 Manager节点
shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini
192.168.41.204 NDB节点1
192.168.41.205 NDB节点2
shell> ndbd
192.168.41.203 SQL节点
192.168.41.204 SQL节点
192.168.41.205 SQL节点
shell> service mysqld start
查看集群状态
192.168.41.206 Manager节点
shell>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 @192.168.0.30 (Version: 5.6.31-ndb-7.4.12, Nodegroup: 0, *) id=3 @192.168.0.40 (Version: 5.6.31-ndb-7.4.12, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.10 (Version: 5.6.31-ndb-7.4.12) [mysqld(API)] 1 node(s) id=4 @192.168.0.20 (Version: 5.6.31-ndb-7.4.12)