1. In the experiment environment, I used three servers to build the mysqlcluster environment. The SQL node and data node are on the same server, and the Management node is a separate one. clusternode1: 192.168.1
1. In the experiment environment, I used three servers to build the mysql cluster environment. The SQL node and data node are on the same server, and the Management node is a single. cluster node1: 192.168.1
1. experiment environment
I used three servers to build the mysql cluster environment. The SQL node and the data node are on the same server, and the Management node is a separate one.
Cluster node1: 192.168.1.102 data node1: 192.168.1.102
Cluster node2: 192.168.1.104 data node2: 192.168.1.104
Manager node: 192.168.1.19
OS: CentOS 6.4 64-bit
2. Install mysql cluster on the SQL node and data node (Note: cluster node 1 and node 2 are the same)
Cluster node1:
[Root @ node1 home] # wget
[Root @ node1 home] # tar xvf mysql-cluster-gpl-7.3.6-linux-glibc2.5-x86_64.tar.gz
[Root @ node1 home] # mv mysql-cluster-gpl-7.3.6-linux-glibc2.5-x86_64/usr/local/mysql-cluster-gpl-7.3.6/
[Root @ node1 home] # cd/usr/local/
[Root @ node1 local] # groupadd mysql
[Root @ node1 local] # useradd-r-M-s/sbin/nologin mysql
[Root @ node1 local] # chown-R root: mysql-cluster-gpl-7.3.6/
[Root @ node1 local] # chown-R mysql: mysql mysql-cluster-gpl-7.3.6/data/
[Root @ node1 scripts] #./mysql_install_db -- user = mysql -- datadir =/usr/local/mysql-cluster-gpl-7.3.6/data -- basedir =/usr/local/mysql-cluster-gpl-7.3.6
[Root @ node1 scripts] # cd ../bin/
[Root @ node1 bin] # cp-a ../support-files/mysql. server/etc/init. d/mysqld
[Root @ node1 bin] # chkconfig -- add mysqld
[Root @ node1 bin] # chkconfig mysqld on
[Root @ node1 bin] # cp-a ../my. cnf/etc/my. cnf
[Root @ node1 bin] # vim/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql-cluster-gpl-7.3.6 -- database installation path
Datadir =/usr/local/mysql-cluster-gpl-7.3.6/data -- database data directory
Port = 3306
Ndbcluster -- cluster service
Ndb-connectstring = 192.168.1.19 -- the IP address of the Management Node
[Mysql_cluster]
Ndb-connectstring = 192.168.1.19 -- the IP address of the Management Node
[Root @ node1 bin] #./mysqld_safe -- user = mysql
[Root @ node1 bin] #/etc/init. d/mysqld restart
ERROR! MySQL server PID file cocould not be found!
Starting MySQL ...................................... SUCCESS!
[Root @ node1 bin] # netstat-anp | grep mysql
Tcp 0 0: 3306: * LISTEN 1982/mysqld
Unix 2 [ACC] stream listening 48481 1982/mysqld/tmp/mysql. sock [root @ node1 bin] #/etc/init. d/iptables stop
Iptables: Setting chains to policy ACCEPT: filter [OK]
Iptables: Flushing firewall rules: [OK]
Iptables: Unloading modules: [OK]
[Root @ node1 bin] #
Cluster node2:
Note: The mysql cluster installation on node 2 is the same as that on node 1, and the configuration file is the same.
3. manage nodes
[Root @ db2 home] # wget
[Root @ db2 home] # tar xvf mysql-cluster-gpl-7.3.6-linux-glibc2.5-x86_64.tar.gz
[Root @ db2 home] # mv mysql-cluster-gpl-7.3.6-linux-glibc2.5-x86_64/usr/local/mysql-cluster-gpl-7.3.6/
[Root @ db2 home] # cd/usr/local/
[Root @ db2 local] # groupadd mysql
[Root @ db2 local] # useradd-r-M-s/sbin/nologin mysql
[Root @ db2 local] # chown-R root: mysql mysql-cluster-gpl-7.3.6/
[Root @ db2 local] # chown-R mysql: mysql mysql-cluster-gpl-7.3.6/data/
[Root @ db2 scripts] #./mysql_install_db -- user = mysql -- datadir =/usr/local/mysql-cluster-gpl-7.3.6/data -- basedir =/usr/local/mysql-cluster-gpl-7.3.6
[Root @ db2 scripts] # cd ../bin/
[Root @ db2 bin] # cp-a ../my. cnf/etc/my. cnf
[Root @ db2 bin] # vim/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql-cluster-gpl-7.3.6
Datadir =/usr/local/mysql-cluster-gpl-7.3.6/data
Port = 3306
[Root @ db2 home] #/etc/init. d/iptables stop
Iptables: Flushing firewall rules: [OK]
Iptables: Setting chains to policy ACCEPT: filter [OK]
Iptables: Unloading modules: [OK]
[Root @ db2 home] # mkdir/var/lib/mysql-cluster/
[Root @ db2 home] # vim/var/lib/mysql-cluster/config. ini -- pay attention to Case sensitivity in the configuration file
[Ndbd default]
NoOfReplicas = 1
[Tcp default]
Portnumber = 2202
[Ndb_mgmd]
Id = 1
Hostname = 192.168.1.19
Datadir =/usr/local/mysql-cluster-gpl-7.3.6/data
[Ndbd]
Id = 2
Hostname = 192.168.1.102
Datadir =/usr/local/mysql-cluster-gpl-7.3.6/data/
[Ndbd]
Id = 3
Hostname = 192.168.1.104
Datadir =/usr/local/mysql-cluster-gpl-7.3.6/data/
[MYSQLD]
Id = 4
Hostname = 192.168.1.102
[MYSQLD]
Id = 5
Hostname = 192.168.1.104