(MySQL cluster) install MySQLCluster on Linux (RedHat5.6)

Source: Internet
Author: User
Tags localhost mysql scp command
I. Environment Introduction IP_AddressPort_NoNode_nameService_nameDesc192.168.56.1013306SQLnode (APINode) mysqldSQL node (API node) 192.168.56.1012202

I. Environment Introduction

IP_Address

Port_No

Node_name

Service_name

Desc

192.168.56.101

3306

SQL node)

Mysqld

SQL node (API node)

192.168.56.101

2202

Data Node

Ndbd

Data Node

192.168.56.102

3306

SQL node)

Mysqld

SQL node (API node)

192.168.56.102

2202

Data Node

Ndbd

Data Node

192.168.56.103

1186

Mgmt Node

Ndb_mgmd

Management Node

2. Preparations

1) disable the firewall (operate on three servers)

[Root @ localhost ~] # Service iptables stop

Flushing firewall rules: [OK]

Setting chains to policy ACCEPT: filter [OK]

Unloading iptables modules: [OK]

[Root @ localhost local] # chkconfig iptables off

2) firewall is disabled by default (operate on three servers)

[Root @ localhost ~] # Chkconfig iptables off

3) add mysql users and groups (operate on three servers)

[Root @ localhost ~] # Groupadd mysql

[Root @ localhost ~] # Useradd-g mysql

4) Upload the Installation File (only on 192.168.56.101)

You can use FileZilla to upload installation files, such as the/tmp directory on Linux. The Installation File I am using is: mysql-cluster-gpl-7.1.10-linux-i686-glibc23.tar.gz

Iii. Install Mysql Cluster

1. Install data nodes and SQL nodes (you only need to operate on 192.168.56.101)

1) install the tar package

[Root @ localhost ~] # Cd/tmp

[Root @ localhost tmp] # tar-C/usr/local-zxvf mysql-cluster-gpl-7.1.10-linux-i686-glibc23.tar.gz

[Root @ localhost tmp] # ln-s/usr/local/mysql-cluster-gpl-7.1.10-linux-i686-glibc23 // usr/local/mysql

[Root @ localhost tmp] # cd/usr/local/mysql

[Root @ localhost mysql] # scripts/mysql_install_db -- usr = mysql

2) Authorization

[Root @ localhost mysql] # cd ..

[Root @ localhost local] # chown-R mysql

[Root @ localhost local] # chgrp-R mysql

3) Create and edit my. cnf, and enter the following content:

[Mysqld]

Ndbcluster

Ndb-connectstring = 192.168.56.103

[Mysql_cluster]

Ndb-connectstring = 192.168.56.103

2. Copy the/usr/local/mysql folder and/etc/my. cnf to 192.168.56.102.

[Root @ localhost local] # scp-r./mysql/* root@192.168.56.102:/usr/local/mysql

The authenticity of host' 192. 168.56.102 (192.168.56.102) 'can't be established.

RSA key fingerprint is 1f: 26: d9: 20: d1: 77: 47: bf: 3c: 7b: 64: 6d: 68: 0f: bb: 76.

Are you sure you want to continue connecting (yes/no )? Yes

Warning: Permanently added '192. 168.56.102 '(RSA) to the list of known hosts.

Root@192.168.56.102's password:

...........

[Root @ localhost local] # scp-r/etc/my. cnf root@192.168.56.102:/etc/

3. Copy the/usr/local/mysql folder to 192.168.56.103 (use the scp command)

[Root @ localhost local] # scp-r./mysql/* root@192.168.56.103:/usr/local/mysql

The authenticity of host' 192. 168.56.103 (192.168.56.103) 'can't be established.

RSA key fingerprint is 1f: 26: d9: 20: d1: 77: 47: bf: 3c: 7b: 64: 6d: 68: 0f: bb: 76.

Are you sure you want to continue connecting (yes/no )? Yes

Warning: Permanently added '192. 168.56.103 '(RSA) to the list of known hosts.

Root@192.168.56.103's password:

4. Authorize in 102 & 103

[Root @ localhost ~] # Cd/usr/local

[Root @ localhost local] # chown-R mysql

[Root @ localhost local] # chgrp-R mysql

5. Configure the management node (on 192.168.56.103)

[Root @ localhost mysql] # mkdir/var/lib/mysql-cluster

[Root @ localhost mysql] # chown-R mysql/var/lib/mysql-cluster

[Root @ localhost mysql] # chgrp-R mysql/var/lib/mysql-cluster

[Root @ localhost mysql] # cd/usr/local/mysql/

[Root @ localhost mysql] # vim config. ini

Enter the following content in config. ini.

[Ndbd default]

NoOfReplicas = 2 # Number of replicas

DataMemory = 80 M # How much memory to allocate for data storage

IndexMemory = 18 M # How much memory to allocate for index storage

[Tcp default]

Portnumber = 2202 # This the default; however, you can use any

[Ndb_mgmd]

Hostname = 192.168.56.103 # Hostname or IP address of MGM node

Datadir =/var/lib/mysql-cluster # Directory for MGM node log files

[Ndbd]

Hostname = 192.168.56.101 # Hostname or IP address

Datadir =/usr/local/mysql/data # Directory for this data node's data files

[Ndbd]

Hostname = 192.168.56.102 # Hostname or IP address

Datadir =/usr/local/mysql/data # Directory for this data node's data files

[Mysqld]

Hostname = 192.168.56.101 # Hostname or IP address

[Mysqld]

Hostname = 192.168.56.102 # Hostname or IP address

4. Start Mysql Cluster

1. Start the management node background service (on 192.168.56.103)

[Root @ localhost mysql] #/usr/local/mysql/bin/ndb_mgmd-f/usr/local/mysql/config. ini

2. Start the management node Management Service (on 192.168.56.103)

[Root @ localhost mysql] #/usr/local/mysql/bin/ndb_mgm

3. View Mysql Cluster configuration information (on 192.168.56.103)

Ndb_mgm> show

Connected to Management Server at: localhost: 1186

Cluster Configuration

---------------------

[Ndbd (NDB)] 2 node (s)

Id = 2 (not connected, accepting connect from 192.168.56.101)

Id = 3 (not connected, accepting connect from 192.168.56.102)

[Ndb_mgmd (MGM)] 1 node (s)

Id = 1 @ 192.168.56.103 (mysql-5.1.51 ndb-7.1.10)

[Mysqld (API)] 2 node (s)

Id = 4 (not connected, accepting connect from 192.168.56.101)

Id = 5 (not connected, accepting connect from 192.168.56.102)

4. Start the data node (101 & 102 operations)

[Root @ localhost local] #/usr/local/mysql/bin/ndbd -- initial

5. Start the SQL node (101 & 102 operations)

[Root @ localhost local] #/usr/local/mysql/bin/mysqld_safe -- defaults-file =/etc/my. cnf &

6. View Mysql Cluster configuration information again (operate on 192.168.56.103)

Ndb_mgm> show

Cluster Configuration

---------------------

[Ndbd (NDB)] 2 node (s)

Id = 2 @ 192.168.56.101 (mysql-5.1.51 ndb-7.1.10, node group: 0, Master)

Id = 3 @ 192.168.56.102 (mysql-5.1.51, Nodegroup: 0)

[Ndb_mgmd (MGM)] 1 node (s)

Id = 1 @ 192.168.56.103 (mysql-5.1.51 ndb-7.1.10)

[Mysqld (API)] 2 node (s)

Id = 4 @ 192.168.56.101 (mysql-5.1.51 ndb-7.1.10)

Id = 5 @ 192.168.56.102 (mysql-5.1.51 ndb-7.1.10)

V. Mysql Cluster Test

1. create databases, tables, and insert data on 101 (102)

[Root @ localhost ~] # Mysql

...

Mysql> show databases;

+ -------------------- +

| Database |

+ -------------------- +

| Information_schema |

| Mysql |

| Ndb_2_fs |

| Ndbinfo |

| Test |

+ -------------------- +

5 rows in set (0.00 sec)

Mysql> create database test1;

Query OK, 1 row affected (0.06 sec)

Mysql> show databases;

+ -------------------- +

| Database |

+ -------------------- +

| Information_schema |

| Mysql |

| Ndb_2_fs |

| Ndbinfo |

| Test |

| Test1 |

+ -------------------- +

6 rows in set (0.00 sec)

Mysql> use test1;

Database changed

Mysql> create table tb_test (id int) engine = ndb;

Query OK, 0 rows affected (0.36 sec)

Mysql> insert into tb_test select 1;

Query OK, 1 row affected (0.06 sec)

Records: 1 Duplicates: 0 Warnings: 0

Mysql> select * from tb_test;

+ ------ +

| Id |

+ ------ +

| 1 |

+ ------ +

1 row in set (0.00 sec)

2. view existing databases, tables, and table data on 102 (101)

[Root @ localhost ~] # Mysql

...

Mysql> show databases;

+ -------------------- +

| Database |

+ -------------------- +

| Information_schema |

| Mysql |

| Ndb_3_fs |

| Ndbinfo |

| Test |

| Test1 |

+ -------------------- +

6 rows in set (0.01 sec)

Mysql> use test1;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with-

Database changed

Mysql> select * from tb_test;

+ ------ +

| Id |

+ ------ +

| 1 |

+ ------ +

1 row in set (0.00 sec)

After the test, the Mysql Cluster is successfully configured.

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.