MySQL 5.0.22 cluster configuration under RedHat AS4-U2

Source: Internet
Author: User
Tags node server
Mysql 5.0.22 Cluster for RedHat AS4-U2

Recently, I have seen a lot of information about cluster. I have been studying the load balancing and high availability of linux systems, but it has not been completely successful yet, but it only implements some simple services; today, I found that the mysql cluster is not very complex. I spent an afternoon studying it and referring to the MySQL cluster configuration steps of the Nanu predecessors, A simple cluster is successful. But I don't understand it. Is it true that after the mysql cluster configuration is complete, only tables in the database can be synchronized, rather than the entire database? Please give me some advice. Thank you!

Li zengji contact QQ: 156440574 MSN: lzj0619@hotmail.com Email: zengji.li@gmail.com hope to communicate with you in linux cluster!

I. experiment environment
1. Linux OS version. RedHat AS4-U2
2. Mysql database version mysql-max-5.0.22-linux-i686-glibc23.tar.gz.
A total of three machine PCs installed with the RedHat AS4-U2 version, first ensure that the system does not have a package with mysql, if there is rpm-e.
PC1 IP: 192.168.10.196
PC2 IP: 192.168.10.197
PC3 IP: 192.168.10.198
Ii. Installation Procedure
1. Execute the following commands on PC1 and PC2 in order:
Music mysql-max-5.0.22-linux-i686-glibc23.tar.gz/usr/local/
Cd/usr/local/
Tar zxvf mysql-max-5.0.22-linux-i686-glibc23.tar.gz
Rm mysql-max-5.0.22-linux-i686-glibc23.tar.gz
Music mysql-max-5.0.22-linux-i686-glibc23 mysql
Groupadd mysql
Useradd-g mysql
Cd mysql
Scripts/mysql_install_db -- user = mysql
Chown-R mysql: mysql.
Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf
Vi/etc/my. cnf
Find the line myisam_sort_buffer_size = 8 m, and add the following two lines to the end:
Ndbcluster
Ndb-connectstring = 192.168.10.198
Add the following six lines to the last line of my. cnf:
[Ndbd]
Connect-string = 192.168.10.198
[Ndb_mgm]
Connect-string = 192.168.10.198
[Ndb_mgmd]
Config-file =/var/lib/mysql-cluster
After modification, save and release!
Mkdir/var/lib/mysql-cluster
2. Execute the following command on PC3 in sequence:
Music mysql-max-5.0.22-linux-i686-glibc23.tar.gz/usr/local/
Cd/usr/local/
Tar zxvf mysql-max-5.0.22-linux-i686-glibc23.tar.gz
Rm mysql-max-5.0.22-linux-i686-glibc23.tar.gz
Music mysql-max-5.0.22-linux-i686-glibc23 mysql
Groupadd mysql
Useradd-g mysql
Cd mysql
Scripts/mysql_install_db -- user = mysql
Chown-R mysql: mysql.
Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf
Vi/etc/my. cnf
Find the line myisam_sort_buffer_size = 8 m, and add the following two lines to the end:
Ndbcluster
Ndb-connectstring = 192.168.10.198
Add the following six lines to the last line of my. cnf:
[Ndbd]
Connect-string = 192.168.10.198
[Ndb_mgm]
Connect-string = 192.168.10.198
[Ndb_mgmd]
Config-file =/var/lib/mysql-cluster
After modification, save and release!
Mkdir/var/lib/mysql-cluster
Cd/var/lib/mysql-cluster
Touch config. ini
Vi config. ini enter the following information: (errors are not allowed for half a character)
[Ndbd default]
NoOfReplicas = 2
DataDir =/var/lib/mysql-cluster
[NDB_MGMD]
Hostname = 192.168.10.198
DataDir =/var/lib/mysql-cluster
[NDBD]
HostName = 192.168.10.197
[NDBD]
HostName = 192.168.10.196
[MYSQLD]
[MYSQLD]
[MYSQLD]
Save and exit!
3. The configuration process has been completed so far. You need to set some shortcut commands below:
On PC1 and PC2, enter the following command:
Cp/usr/local/mysql/support-files/mysql. server/etc/rc. d/init. d/mysqld
Chmod + x/etc/rc. d/init. d/mysqld
Chkconfig-add mysqld
Ln-s/usr/local/mysql/bin/ndbd/usr/bin/ndbd
VI/etc/rc. Local
Add a line of ndbd and save and exit
On PC3, enter the following command:
CP/usr/local/MySQL/support-files/MySQL. Server/etc/rc. d/init. d/mysqld
Chmod + x/etc/rc. d/init. d/mysqld
Chkconfig-add mysqld
Ln-S/usr/local/MySQL/bin/ndb_mgm/usr/bin/ndb_mgm
Ln-S/usr/local/MySQL/bin/ndb_mgmd/usr/bin/ndb_mgmd
Add the following line after VI/etc/rc. Local
/Usr/local/MySQL/bin/ndb_mgmd-F/var/lib/MySQL-cluster/config. ini
Save and exit!
3. Start the service
The command to be executed by PC3 is as follows:
/Usr/local/MySQL/bin/ndb_mgmd-F/var/lib/MySQL-cluster/config. ini
Service mysqld start
The commands to be executed in pC1 and PC2 are as follows:
/Usr/local/MySQL/bin/ndbd -- Initial Note: Use the -- Initial Parameter only when ndbd is started for the first time.
Service mysqld start
Iv. Test and check
The command to be executed by PC3 is as follows:
Ndb_mgm
If the following command is executed and the following information is displayed, the task is normal!
[Root @ lzj local] # ndb_mgm
-- NDB Cluster -- Management Client --
Ndb_mgm> show
Connected to Management Server at: 192.168.10.198: 1186
Cluster Configuration
---------------------
[Ndbd (NDB)] 2 node (s)
Id = 2 @ 192.168.10.197 (Version: 5.0.22, Nodegroup: 0, Master)
Id = 3 @ 192.168.10.196 (Version: 5.0.22, Nodegroup: 0)
[Ndb_mgmd (MGM)] 1 node (s)
Id = 1 @ 192.168.10.198 (Version: 5.0.22)
[Mysqld (API)] 3 node (s)
Id = 4 @ 192.168.10.198 (Version: 5.0.22)
Id = 5 @ 192.168.10.197 (Version: 5.0.22)
Id = 6 @ 192.168.10.196 (Version: 5.0.22)
Ndb_mgm>
During the test, you need to create a table to check whether the mysql of the three machines can be synchronized.
5. Precautions
1. mysql cluster must start the management node server in advance during startup. After the management node is started successfully, start other nodes.
2. It is best to close the management node when you close the entire cluster.
3. When the management node goes down and another host goes down, the meaning of the cluster is lost. The management node should be on standby 24 hours a day.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.