Build a mysql cluster in linux

Source: Internet
Author: User

Build a mysql cluster in linux

Chapter 2 Environment Description
1.1 System Description
Three linux servers are used and centos is used to minimize the installation of the system.
1.2 Software Description
Database Management Nodes and database nodes all adopt:
Mysql-cluster-gpl-7.0.8a-linux-i686-glibc23.tar.gz
1.3 topology structure description
The mysql cluster has the following three layers:
Application Layer: various applications that communicate with the mysql server.
Mysql server layer: Processes SQL commands, communicates with the NDB storage engine, and Mysql servers.
NDB cluster Component layer: The NDB cluster component is also known as a data node. It processes queries and returns the results to the mysql server. The topology is as follows:

 
Mysql-cluster: 192.168.254.200
NDB node: IP Address: 192.168.254.221
NDB node: IP Address: 192.168.254.222
SQL node: IP Address: 192.168.254.221
SQL node: IP Address: 192.168.254.222
Chapter 4 Mysql management node Installation
2.1 install dependency packages
Yum install wget gcc-c ++ make cmake ncurses-devel libtool zilib-devel-y
Note: cmake is required for Versions later than mysql 5.5. Versions later than mysql 5.5 replace cmake with configure;
2.2 create a mysql user
Useradd-s/sbin/nologin-M mysql
2.3 compile and install the mysql management Node
Extra xvf mysql-cluster-gpl-7.2.8.tar.gz
Cd mysql-cluster-gpl-7.2.8
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/data/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/data/mysql /\
-DMYSQL_USER = mysql \
-DMYSQL_TCP_PORT = 3306


Make & make install


2.4 modify the configuration file
Mkdir-p/data/mysql-cluster/
Vi/data/mysql-cluster/config. ini
[Ndbd default]
NoOfReplicas = 2
DataMemory = 80 M
IndexMemory = 18 M
[Ndb_mgmd]
Id = 1
Hostname = 192.168.254.200
Datadir =/data/mysql/
[Ndbd]
Id = 2
Hostname = 192.168.254.221
Datadir =/data/mysql/


[Ndbd]
Id = 3
Hostname = 192.168.254.222
Datadir =/data/mysql/
[MYSQLD]
[MYSQLD]
2.5 start a management Node
/Usr/local/mysql/bin/ndb_mgmd-f/data/mysql-cluster/config. ini
If the instance is successfully started, the following message is displayed:
MySQL Cluster Management Server mysql-5.5.27 ndb-7.2.8
 
Chapter 4 install Mysql running nodes
3.1 installation instructions
For the installation process of Mysql nodes, see management node installation;
3.2 Configuration File Modification
Cp support-files/my-medium.cnf/etc/my. cnf
Cp support-files/mysql. server/etc/init. d/mysqld
Chmod 755/etc/init. d/mysqld
3.3 initialize mysql
Bash scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/data/mysql/
3.4 start the mysql node service
/Usr/local/mysql/bin/ndbd-initial
/Etc/init. d/mysqld start


Chapter 4 Management and Testing
4.1 manage node status
Go to the management node workbench
/Usr/local/mysql/bin/ndb_mgmd
Run show to display the current status
 
That is, the cluster runs normally.
4.2 Mysql node status
The following process is generated when the ndbd service is started;
 
4.3 Test Data Synchronization
221 (master:
 
Then log on to mysql 222 and check the status:
 
Similarly, perform the following operations on 222:
 
Then, view the synchronization result on 221:
 
The preceding results indicate that the cluster runs successfully and the master-slave synchronization of the database can be ensured.


Then, disconnect 222 of network services and view the management nodes;
 
Start network service 222 and run/usr/local/mysql/bin/ndbd-initial;
 
Then, view the management node service;
 
If a service is disconnected, you can continue using the mysql service.
4.4 node Management
If you have modified config. in the INI file, execute the following statement to make the configuration file take effect;/usr/local/mysql/bin/ndb_mgmd-f/data/mysql-cluster/config. ini -- reload
Rolling restart the old data storage node service (rolling restart means that all nodes cannot be restarted at the same time. If both nodes are stopped at the same time, the Database Front-end query will encounter an error );
Ndb_mgm> "id" (restart; stop; start)
Restart, stop, start, and "id" node service.

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.