CentOS mysql cluster installation and deployment tutorial, centoscluster

Source: Internet
Author: User

CentOS mysql cluster installation and deployment tutorial, centoscluster

I. Installation Requirements

Installation environment: CentOS-6.5-32bit

Software: mysql-cluster-gpl-7.2.25-linux2.6-i686.tar.gz

: Http://mysql.mirror.kangaroot.net/Downloads/

Package: mysql-cluster-gpl-7.2.25-linux2.6-i686.tar.gz

Package storage directory:/usr/local

Management node (MGM): 192.168.1.71

Data Node 1 (NDBD1): 192.168.1.72

Data Node 2 (NDBD2): 192.168.1.73

SQL Node 1 (SQL1): 192.168.1.74

SQL Node 2 (SQL2): 192.168.1.75

Ii. installation and deployment

1. Before installation: (all node servers need to be executed)

[Root @ MGM] # rpm-qa | grep mysql * (mysql in the query system) [root @ MGM] # rpm-e-nodeps mysql-libs-5.1.71-1.el6.i686 (based on the mysql version I found)

2. Start deployment: (all node servers need to be executed)

[Root @ MGM] # groupadd mysql [root @ MGM] # useradd mysql-g mysql [root @ MGM] # cd/usr/local (the software package is in this directory, access [root @ MGM local] # tar -xvfmysql-cluster-gpl-7.2.25-linux2.6-i686.tar.gz [root @ MGM local] # mkdir/usr/local/mysql (create mysql directory) [root @ MGM local] # mvmysql-cluster-gpl-7.2.25-linux2.6-i686/* mysql [root @ MGM local] # chown-R mysql: mysql/[root @ MGM local] # cd mysql [root @ MGM mysql] # scripts/mysql_install_db-user = mysql (management and data nodes execute this command) # scripts/mysql_install_db-user = mysql-datadir =/var/mysql/data (the SQL node executes this command)

3. cluster configuration

1. Manage node configuration:

[Root @ MGM mysql] # mkdir/var/lib/mysql-cluster [root @ MGM] # mkdir/var/mysql [root @ MGM] # mkdir/var/mysql/data [root @ MGM] # mkdit/var/mysql/log [root @ MGM mysql] # vi/var/lib/mysql-cluster/config. ini (Add the following content) [ndbd default] NoOfReplicas = 2 # [tcp default] # PortNumber = 1186 [NDB_MGMD] # Set nodeid = 1 HostName = 192.168.1.71 DataDir =/var/mysql/data [NDBD] nodeid = 2 HostName = 192.168.1.72 DataDir =/var/mysql/data [NDBD] nodeid = 3 HostName = 192.168.1.73 DataDir =/var/mysql/data [MYSQLD] nodeid = 4 HostName = 192.168.1.74 [MYSQLD] nodeid = 5 HostName = 192.168.1.75 # The mysqld node must be empty, otherwise, [MYSQLD] nodeid = 6 [mysqld] nodeid = 7

Copy ndb_mgm, ndb_mgmd, and config. ini to the bin directory:

[Root @ MGM mysql] # cd/usr/local/mysql/bin [root @ MGM bin] # cp. /ndb_mgm/usr/local/bin/[root @ MGM bin] # cp. /ndb_mgmd/usr/local/bin/[root @ MGM bin] # cp/var/lib/mysql-cluster/config. ini/usr/local/bin/[root @ MGM bin] # vi/etc/sysconfig/iptables (add the red box content)

[Root @ MGM bin]/etc/init. d/iptables restart Firewall

2. data node configuration: (all data nodes need to be executed)

[Root @ NDBD1] # mkdir/var/mysql [root @ NDBD1] # mkdir/var/mysql/data [root @ NDBD1] # mkdit/var/mysql/log [root @ NDBD1] #/etc/init. d/iptables stop (disable the firewall or add an open port) [root @ NDBD1] # vi/etc/my. cnf (Add the following content) [mysqld] datadir =/var/mysql/datasocket =/var/mysql. sockuser = mysql # Disabling symbolic-links is recommended to prevent assorted security ready-links = 0 # Run NDB storage engine ndbcluster # specify the management node ndb-connectstring = 192.168.1.71 [MYSQL_CLUSTER] ndb-connectstring = 192.168.1.71 [NDB_MGM] connect-string = 192.168.1.71 [mysqld_safe] log-error =/var/mysql/log/mysqld. logpid-file =/var/run/mysqld. pid

3. SQL node configuration: (all SQL nodes need to be executed)

[Root @ SQL1] # cd/usr/local/mysql/[root @ SQL1 mysql] # cp support-files/mysql. server/etc/rc. d/init. d/mysqld [root @ SQL1 mysql] # chmod + x/etc/rc. d/init. d/mysqld [root @ SQL1 mysql] # chkconfig-add mysqld [root @ SQL1 mysql] # mkdir/var/mysql [root @ SQL1 mysql] # mkdir/var/mysql/data [root @ SQL1 mysql] # mkdir/var/mysql/log [root @ SQL1 mysql] # chown-R mysql: mysql/var/mysql [root @ SQL1 mysql] # ln-s/usr/local/mysql/bin/mysql/usr/bin [root @ SQL1 mysql] # ln-s/ var/mysql. sock/tmp/mysql. sock [root @ SQL1 mysql] # vi/etc/my. cnf [mysqld] datadir =/var/mysql/datasocket =/var/mysql. sockuser = mysql # Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links = 0log-bin =/var/mysql/log/mysql-bin.logmax_connections = 1000 # The following is the configuration file for the mysql master mode # ignore mysql Database Replication binlog-ignore-db = mysql # 2auto-increment-increment = 2 # Set the offset of the automatically increasing field, the initial value is 2auto-increment-offset = Signature = 192.168.1.71 [MYSQL_CLUSTER] ndb-connectstring = 192.168.1.71 [NDB_MGM] connect-string = 192.168.1.71 [mysqld_safe] log-error =/var/mysql/log/mysqld. logpid-file =/var/run/mysqld. pid

4. Start mysql-cluster

1. Start mysql-cluster

The start sequence of the mysql cluster is: Management node> data node> SQL node.

The order in which the mysql cluster is closed is SQL node-> data node-> Management Node

2. manage nodes:

[root@MGM ]#ndb_mgmd -f /var/lib/mysql-cluster/config.ini –initial(Note that after you modify the config file for the first time, you must add initial to open the service. Otherwise, the newly added content will not be used)

3. Data nodes:

[root@NDBD1 ]#/usr/local/mysql/bin/ndbd –initial(Same as above)

4. SQL node:

[root@SQL1 ]#service mysqld start

5. Verify: (on the management node)

[Root @ MGM] # ndb_mgm

Ndb_mgm> show

V. Test

1. Run the following command on sql1:

[Root @ SQL1] # mysql calls mysqlmysql> create database tianyuan; creates database mysql> use tianyuan; uses database mysql> create table test (I int, name varchar (10 )) engine = ndbcluster; create a table mysql> insert into test values (1, 'ceshi'); insert table data mysql> select * from test; query Verification

2. Verify that sql1 data has been synchronized to sql2:

[Root @ SQL2] # mysql calls mysqlmysql> show databases; Queries database mysql> use tianyuan; uses database mysql> select * from test; query Verification

3. You can interrupt the data node or SQL node to verify whether the data will be synchronized.

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.