Deploy the MysqlCluster cluster in Ubuntu and use tumysqlcluster.
Deployment environment:
System: ubuntu-12.04.4-server
Mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
Note:
1. Do not install Mysql before deployment. Some people use apt-get for deployment. However, if you use cluster binary, do not pre-install the release version.
2. Some system commands cannot be used, so pay attention to these
Preparation: 3 hosts
Mgm node: 192.168.1.71
Data Node: 192.168.1.72 192.168.1.72
SQL node: 192.168.1.73 192.168.1.73
Take 72 as an example. 73 is the same configuration method.
1. Install a management Node
Tar-zvxf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
Music mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/usr/local/mysql
Cd/usr/local/mysql
Mkdir-p/usr/local/mysql/ndbdata
Mkdir/usr/local/mysql-cluster/
Vi/usr/local/mysql-cluster/config. ini
========================= Configuration file content ==========================
# Ndb_mgmd-f path/mysql-cluster/config. ini -- configdir = path/mysql-cluster/
[Ndbd default]
NoOfReplicas = 2
DataMemory = 128 M
IndexMemory = 32 M
[Mysqld default]
[NDB_MGMD DEFAULT]
DataDir =/usr/local/mysql-cluster
[Tcp default]
# Section for the cluster management node
[NDB_MGMD]
NodeId = 1
HostName = 192.168.1.71
[NDBD]
# IP address of the first storage node
NodeId = 2
HostName = 192.168.1.72
DataDir =/usr/local/mysql/ndbdata
[NDBD]
# IP address of the second storage node
NodeId = 3
HostName = 192.168.1.73
DataDir =/usr/local/mysql/ndbdata
# One [MYSQLD] per storage node
[MYSQLD]
HostName = 192.168.1.72
[MYSQLD]
HostName = 192.168.1.73
[MYSQLD]
[MYSQLD]
# Note that two idle MYSQLD instances are reserved.
========================================================== ================
2. Install data nodes on 72
Tar-zvxf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
Music mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/usr/local/mysql
Cd/usr/local/mysql
Mkdir-p/usr/local/mysql/ndbdata
Copy the execution File
Add execution file path
Vi ~ /. Bash_profile
PATH = $ PATH: $ HOME/bin:/usr/local/mysql/bin
Create a configuration file:
Vi/etc/mysql/my. cnf
Add the following content to the Host:
[Mysql_cluster]
Ndb-connectstring = 192.168.1.71
Install SQL nodes
Tar-zvxf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
Music mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/usr/local/mysql
Cd/usr/local/mysql
Add a mysql user
Groupadd mysql
Useradd-g mysql
Add permission
Chown-R mysql: mysql/usr/local/mysql
Copy configuration file
Cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf
Initialize Database
Cd/usr/local/mysql
Scripts/mysql_install_db -- user = mysql
Copy the files required by the daemon
Cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysqld
Add execution file path
Vi ~ /. Bash_profile
PATH = $ PATH: $ HOME/bin:/usr/local/mysql/bin
Change configuration file
Vi/etc/mysql/my. cnf
Edit the following information:
[Mysqld]
Port = 3306
Socket =/tmp/mysql. sock
Ndbcluster
Ndb-connectstring = 192.168.1.71
Bind-address = 192.168.1.72
[Mysql_cluster]
Ndb-connectstring = 192.168.1.71
4. Start and close the Cluster
Startup sequence: Management node ---> data node ---> SQL Node
1. Start the management Node
Cd/usr/local/mysql/bin/
Start the management node. Add -- initail to start the node first.
Ndb_mgmd-f path/mysql-cluster/config. ini -- configdir = path/mysql-cluster/
Ndb_mgm-e show # view node connection status
2. Start the data node
/Usr/local/mysql/bin/ndbd -- initial (this command is used for the first startup)
/Usr/local/mysql/bin/ndbd (Use this command later)
3. Start the SQL Node
/Usr/local/mysql/bin/mysqld_safe -- user = mysql &
Or
/Etc/init. d/mysqld restart
Then, log on to the mysql server 72 and create a table using the ndb engine in the test database,
Insert data. Normally, another msyql server should produce the same result.