CentOS6.5 install mysql cluster7.3.7 to build a mysql database cluster environment (dual-Management Center), centos6.5 install mysql
MySQL Cluster is a technology that allows you to deploy the "in memory" Database Cluster in a non-shared system. Without a shared architecture, the system can use cheap hardware without special requirements for hardware and software. In addition, since each component has its own memory and disk, there is no single point of failure. MySQL Cluster is composed of a group of computers, each of which runs a variety of processes, including MySQL servers, NDB Cluster data nodes, management servers, and (possibly) dedicated Data Access Program.
The commands that both servers need to execute are not mentioned in the following section. Because they are configured in the dual-management center, in fact, the two machines have different id and ip configurations. Other parameter configurations are basically the same.
1. Download mysql-cluster 7.3.7
Http://dev.mysql.com/downloads/cluster/
2. Clean up the environment and install the mysql service that comes with CentOS6.5. I can run the first command without executing it. If not, we recommend that you run the command.
# Yum-y remove mysql # rpm-qa | grep mysql * # rpm-e-nodeps mysql-libs-5.1.71-1.el6.x86_64
2) Prepare the environment
Create a folder (the following three classes are used to create the corresponding folder)
Storage node: # mkdir/var/lib/mysql/data
Management node: # mkdir/var/lib/mysql-cluster SQL node: folder authorization is not required.
Process DIR: # mkdir/var/run/mysqld
You can use the following command to change the permission to write data:
# Chmod-R 1777/var/lib/mysql
# Chmod-R 1777/var/run/mysqld
# Chmod-R 1777/var/lib/mysql-cluster
3) install mysql-cluster
First release mysql-cluster-gpl-7.4.2-1.el6.x86_64.rpm-bundle.tar
# Tar xvf MySQL-Cluster-gpl-7.4.2-1.el6.x86_64.rpm-bundle.tar
Run the following command to install
# Rpm-ivh MySQL-Cluster-server-gpl-7.3.4-1.el6.x86_64.rpm
# Rpm-ivh MySQL-Cluster-client-gpl-7.3.4-1.el6.x86_64.rpm
Note: After the server gpl package is installed, the following message is displayed, reminding us that the first Super account password after the cluster is installed exists in the/root/. mysql_secret file.
Bytes ---------------------------------------------------------------------------------------------------------------------
A random password has been set for the MySQL root USER!
You will find that password in '/root/. mysql_secret '.
You must change that password on your first connect,
No other statement but 'set password' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/Usr/bin/mysql_secure_installation
Which will also give you the option of removing the test database.
This is stronugly recommended for production servers.
-----------------------------------------------------------
2. Configuration Management Node
1) execute the following command:
# Cd/var/lib/mysql-cluster
# Vi config. ini
2) configure the config. ini file, as shown in the attachment
Configuration File 100.218:
[Computer]
Mgr-server-01
HostName = 192.168.100.218
[Mgm default]
Datadir =/var/lib/mysql-cluster
[Mgm]
HostName = 192.168.100.218
NodeId = 60
ExecuteOnComputer = mgr-server-01
PortNumber = 1186
ArbitrationRank = 2
[Mgm]
HostName = 192.168.100.217
NodeId = 61
ExecuteOnComputer = mgr-server-01
PortNumber = 1186
ArbitrationRank = 2
[Ndbd default]
NoOfReplicas = 2
DataMemory = 500 M
IndexMemory = 500 M
[Ndbd]
HostName = 192.168.100.217
DataDir =/var/lib/mysql
NodeId = 1
[Ndbd]
HostName = 192.168.100.218
DataDir =/var/lib/mysql
NodeId = 2
[Mysqld]
HostName = 192.168.100.217
NodeId = 81
[Mysqld]
HostName = 192.168.100.218
NodeId = 82
Configuration File 100.217:
[Computer]
Mgr-server-02
HostName = 192.168.100.217
[Mgm default]
Datadir =/var/lib/mysql-cluster
[Mgm]
HostName = 192.168.100.218
NodeId = 60
ExecuteOnComputer = mgr-server-01
PortNumber = 1186
ArbitrationRank = 2
[Mgm]
HostName = 192.168.100.217
NodeId = 61
ExecuteOnComputer = mgr-server-01
PortNumber = 1186
ArbitrationRank = 2
[Ndbd default]
NoOfReplicas = 2
DataMemory = 500 M
IndexMemory = 500 M
[Ndbd]
HostName = 192.168.100.217
DataDir =/var/lib/mysql
NodeId = 1
[Ndbd]
HostName = 192.168.100.218
DataDir =/var/lib/mysql
NodeId = 2
[Mysqld]
HostName = 192.168.100.217
NodeId = 81
[Mysqld]
HostName = 192.168.100.218
NodeId = 82
In fact, there is little difference between the two files, that is, the name and id in the computer configuration.
3. SQL node and data node configuration
Modify my. add the following content to the cnf file: [client] socket =/var/lib/mysql. sock [mysqld] max_connections = 100 datadir =/var/lib/mysql socket =/var/lib/mysql. sock ndbcluster ndb-connectstring = 192.168.100.218, 192.168.100.217 [mysqld_safe] log-error =/var/log/mysqld. log # pid-file =/var/run/mysqld. pid-file =/var/lib/mysql/mysqld. pid
[Mysql_cluster] ndb-connectstring = 192.168.100.218, 192.168.100.217
4. MySQL Cluster Initial Startup command and user password change adjustment: (Please start in strict order)
1) Start mysql-cluster
Before starting the service for the first time, make sure that the firewall of the two machines is disabled (service iptables stop or set the firewall port to allow access, and the two ports are communication port 1186 and data port 3306)
Start mgt console command for the first time: ndb_mgmd-f/var/lib/mysql-cluster/config. ini
Run the "ndbd -- initial" command to start the balancing node.
Run mysqld_safe -- defaults-file =/usr/my. cnf -- explicit_defaults_for_timestamp &
My. cnf is in the etc directory in some systems
Pay attention to the need to monitor the entire console output during the startup process. If any error information is found, it should be resolved in a timely manner based on the error log Content.
Bytes ---------------------------------------------------------------------------------------------------------
Run the following command to enable the Management console: ndb_mgm
Run # show
Check whether all nodes have been fully started, as shown below. Each node is connected. If any node is not connected, you will see
Ndb_mgm> show
Connected to Management Server at: 192.168.100.218: 1186
Cluster Configuration
---------------------
[Ndbd (NDB)] 2 node (s)
Id = 1 @ 192.168.100.217 (mysql-5.6.21 ndb-7.4.2, node group: 0)
Id = 2 @ 192.168.100.218 (mysql-5.6.21, Nodegroup: 0 ,*)
[Ndb_mgmd (MGM)] 1 node (s)
Id = 60 @ 192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
Id = 61 @ 192.168.100.217 (mysql-5.6.21 ndb-7.4.2)
[Mysqld (API)] 2 node (s)
Id = 81 @ 192.168.100.217 (mysql-5.6.21 ndb-7.4.2)
Id = 82 @ 192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
If a node is not connected, as shown in the following code, id = 81 indicates no connection. Check the fault point.
Ndb_mgm> show
Cluster Configuration
---------------------
[Ndbd (NDB)] 2 node (s)
Id = 1 @ 192.168.100.217 (mysql-5.6.21 ndb-7.4.2, node group: 0)
Id = 2 @ 192.168.100.218 (mysql-5.6.21, Nodegroup: 0 ,*)
[Ndb_mgmd (MGM)] 1 node (s)
Id = 60 @ 192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
Id = 61 @ 192.168.100.217 (mysql-5.6.21 ndb-7.4.2)
[Mysqld (API)] 2 node (s)
Id = 81 (not connected, accepting connect from 192.168.100.217)
Id = 82 @ 192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
2) change the password
After mysqld is started properly (you can use pgrep mysqld to obtain the process ID), run the following command to modify the process ID:
Mysql-u root-p;
Random Password (for details, see the/root/. mysql_secret file), and then use the following command to change the password:
Set password = PASSWORD ('new password ');
However, the new password must be a hash value. Therefore, you must use the following method to obtain the hash value of the password string:
Select password ('20140901 ');
However, executing the above command will allow you to set the password first, and then turn it back, go to mysql elsewhere and execute the following command. The hash value of 111111 is "* RESET" set password = PASSWORD ('* fd571204174ba9afe270fe62151ae967eca5e0aa'). It's depressing. After the setting, the ciphertext must be used for login. Then, use the ciphertext to log on to the system. Run the following command to force the use mysql; delete from user; grant all on *. * to root @ '%' identified by "111111" with grant option; flush privileges; quit; then, you can use the plaintext password to log on.
The preceding commands must be executed on several servers with SQL data nodes;
5. After the above steps are completed, test whether the cluster works normally.
1) Simple Function Testing
Run the following command on mysql 218:
Create database clustertest;
Use clustertest;
Create table testtable (Count INT) ENGINE = NDBCLUSTER; Note: ENGINE = NDBCLUSTER; the ENGINE must use NDBCLUSTER to synchronize data; otherwise, data will not be synchronized.
Check whether the database and table are created automatically. Go to mysql on mysql 217. If the database and table are created successfully, check the environment configuration.
2) test whether data can be synchronized in the case of disaster recovery (if a database is stopped and then started, will the lost data be automatically supplemented)
Stop the mysql service on 217 and run it on 218.
Insert into testtable values (1 );
Start mysql 217 and use show to check that the database nodes of 217 are connected. Run the following statement:
Select * from testtable;
If data is found, the function is complete.
6. Disable Cluster: (the Cluster must be executed in strict order)
Close the data node: # mysqld stop (the SQL node can be shut down using mysqladmin shutdown or another method .)
Run # ndb_mgm-e shutdown on the Management node.
Close management nodes and data nodes securely.
Run the following process detection command to check whether the system has exited:
# Pgrep mysqld
# Ps aux | grep nbdb
If not, find the corresponding pid and perform the kill operation.
Kill-9 process no.
7. Restart the Cluster solution:
The order in which the entire cluster is started. Note that some statements have subtracted the initialization content:
Ndb_mgmd-f/var/lib/mysql-cluster/config. ini
Ndbd
Mysqld_safe -- defaults-file =/etc/my. cnf -- explicit_defaults_for_timestamp &
Note: 1. After mysql is installed, it will be automatically started by default. Every time you start the cluster, you must first disable the mysql service, which is too troublesome, you can execute the following command (I am a little embarrassed ):
Chkconfig -- level 123456 mysql off
2. Firewall problems. I am too lazy to open ports one by one. I simply shut down the firewall directly (not recommended)
Chkconfig -- level 123456 iptables off
See related documents: MySQL Cluster config. ini file configuration details: http://note.youdao.com/share? Id = 376407a1136d2032afb6ef68aa39fba5 & type = note
MySQL Cluster backup and recovery http://www.linuxidc.com/Linux/2013-06/85295.htm
MySQL Cluster installation configuration http://www.linuxidc.com/Linux/2013-07/87705.htm
MySQL Cluster 3 machines build Cluster environment DOC http://www.linuxidc.com/Linux/2013-01/78249.htm
MySQL Cluster7.2 online addition of data nodes there are major drawbacks http://www.linuxidc.com/Linux/2012-08/67605.htm
Build a http://www.linuxidc.com/Linux/2014-05/102218.htm for a MySQL-Cluster architecture
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.