CentOS Mysql Cluster Install deployment tutorial _mysql

Source: Internet
Author: User
Tags mkdir mysql in centos create database iptables node server

First, installation requirements

Installation Environment: Centos-6.5-32bit

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

Download Address: 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 server needs to be implemented)

[ROOT@MGM] #rpm-qa|grep mysql* (MySQL in query system)

[ROOT@MGM] #rpm-e–nodeps mysql-libs-5.1.71-1.el6.i686 ( According to the version of MySQL that I found out.

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 (packages in this directory, according to their own storage location to enter) C3/>[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 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 (SQL node executes this command)

Third, cluster configuration

1. Management 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)

[ndbd DEFAULT]

noofreplicas=2

#[tcp DEFAULT]

#PortNumber =1186

[NDB_MGMD]

#设置管理节点服务器

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 

#必须有空的mysqld节点, otherwise the data node is disconnected and started with an error

[MYSQLD]

nodeid=6

[ MYSQLD]

nodeid=7

Copy NDB_MGM, NDB_MGMD, config.ini to 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 red box content)

[ROOT@MGM bin]/etc/init.d/iptables Restart reboot firewall

2. Data node configuration: (All data nodes need to be implemented)

[ROOT@NDBD1] #mkdir/var/mysql

[root@ndbd1] #mkdir/var/mysql/data

[root@ndbd1] #mkdit/var/mysql/log

[ ROOT@NDBD1]#/etc/init.d/iptables Stop (to turn off the firewall or add the open port yourself)

[ROOT@NDBD1] #vi/etc/my.cnf (Add the following)

[mysqld]

datadir=/var/mysql/data

socket=/var/mysql/mysql.sock

user=mysql

# disabling Symbolic-links is Recommended to prevent assorted security risks

symbolic-links=0

#运行NDB存储引擎

ndbcluster

#指定管理节点

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.log

Pid-file=/var/run/mysqld/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 m Ysql] #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/my SQL [ROOT@SQL1 MySQL] #ln-S/usr/local/mysql/bin/mysql/usr/bin [ROOT@SQL1 MySQL] #ln-S/var/mysql/mysql.sock/tmp/mysql . Sock [root@sql1 MySQL] #vi/etc/my.cnf [mysqld] datadir=/var/mysql/data socket=/var/mysql/mysql.sock user=mysql # Di Sabling Symbolic-links is recommended to prevent assorted security risks symbolic-links=0 Log-bin =/var/mysql/log/mysql -bin.log max_connections=1000 #以下为mysql Main main mode of the profile # ignore MySQL database replication Binlog-ignore-db=mysql # 2 per increase Auto-increment-incre ment=2 # Sets the offset of the automatically grown field, that is, the initial value is 2 auto-increment-offset=1 ndbcluster 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.log pid-file=/var/run/mysqld/

 Mysqld.pid

Four, Mysql-cluster start

1. Start Mysql-cluster

MySQL cluster boot sequence is: Management node-> data node->sql node

MySQL cluster shutdown sequence for, SQL node-> data node-> management node

2. Management node:

[root@MGM ]#ndb_mgmd -f /var/lib/mysql-cluster/config.ini –initial(Note that when the first or the config file is modified, the open service must be added initial otherwise the new additions will not be used)

3. Data node:

[root@NDBD1 ]#/usr/local/mysql/bin/ndbd –initial(ditto here)

4.sql node:

[root@SQL1 ]#service mysqld start

5. Verification: (On the Management node)

[ROOT@MGM] #ndb_mgm

Ndb_mgm>show

Five, test

1. Execute at SQL1 node:

[ROOT@SQL1] #mysql call the MySQL

mysql>create database Tianyuan; Create the databases

mysql>use Tianyuan; use database

MySQL >create table Test (i int,name varchar ()) Engine=ndbcluster; CREATE TABLE

Mysql>insert into test values (1, ' Ceshi '); Insert table Data

Mysql>select * from test; query validation

2. Verify that the SQL1 data is synchronized to SQL2 at the SQL2 node:

[ROOT@SQL2] #mysql call MySQL

mysql>show databases; query database

mysql>use Tianyuan; use database

Mysql>select * From Test; Query validation

3. You can verify that data is synchronized by interrupting data nodes or SQL nodes.

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.