Mysql Cluster7.4.12 Distributed Cluster setup

Source: Internet
Author: User


Cluster Planning:

Node IP Address
Management Server (NDB_MGMD) 192.168.6.203
Data nodes (NDBD)

192.168.6.204

192.168.6.205

SQL node (mysqld)

192.168.6.204

192.168.6.205


Mysql Cluster Version:

MySQL Cluster NDB 7.4.12 (5.6.31-ndb-7.4.12),

: http://dev.mysql.com/downloads/cluster/


Cluster Department Department:

1, environmental cleaning and installation:

If a mysql-related installation or dependency package already exists, first clean up MySQL related installation and dependencies

Check MySQL for MySQL-related dependency packages:

Rpm-qa | grep mysql*

If present: mysql-libs-5.1.66-2.el6_3.x86_64

Then uninstall MySQL and delete dependencies:

Yum-y Remove Mysqlrpm-e--nodeps mysql-libs-5.1.66-2.el6_3.x86_64 ...


2. Cluster Installation:

Management node:

192.168.6.203

RPM-IVH mysql-cluster-server-gpl-7.4.12-1.el6.x86_64.rpm

Data node and MySQL server:

192.168.6.204

192.168.6.205

RPM-IVH MYSQL-CLUSTER-SERVER-GPL-7.4.12-1.EL6.X86_64.RPMRPM-IVH mysql-cluster-client-gpl-7.4.12-1.el6.x86_64.rpm


Configuration file:

Manage node configuration files:

Create on 192.168.6.203 /var/lib/mysql-cluster/config.ini, the contents are as follows

[ndb_mgmd default]  portnumber=1186    [ndb_mgmd]  nodeid=10   HostName=192.168.6.203  DataDir=/var/lib/mysql-cluster/  Portnumber=1186     [TCP DEFAULT]  SendBufferMemory=4M  ReceiveBufferMemory=4M     [ndbd default]  noofreplicas=2    # number of  replicasdatamemory=800m    # how much memory to allocate  for data storageindexmemory=100m   # how much memory to  allocate for index storage                   # for datamemory and indexmemory, we  have used the                   # default values. since the  "World"  database takes up                   # only  about 500kb, this should be more than enough for                   # this  example cluster setup.  [ndbd]  nodeid=20  hostname=192.168.6.204   datadir=/var/lib/mysql/    [ndbd]nodeid=21hostname=192.168.6.205datadir=/var/ lib/mysql/[mysqld default]  [mysqld]  hostname=192.168.6.204[mysqld]   hostname=192.168.6.205

Data nodes and MYSQLD nodes:

Create/etc/my.cnf on 192.168.6.20[4,5], respectively

[mysqld]# Options for Mysqld process:ndbcluster # run NDB storage enginendb-connectstring= ' 192.168.6. 203:1186 "[mysql_cluster]# # Options for MySQL cluster processes:ndb-connectstring=" 192.168.6.203:1186 "# Location of the man Agement Server


3. Start the cluster:

Preparation: Cluster Each machine shuts down the firewall; set SELinux selinux=disabled;

Start the Management node first:

Start the Management node on 192.168.6.203:

Ndb_mgmd-f/var/lib/mysql-cluster/config.ini--initial

Then start the data node:

192.168.6.20[4,5] On the Start data node:

ndbd

Last 192.168.6.20[4,5] Start the MYSQLD service:

Mysqld_safe--user=mysql &


View node connection status through the management node:

shell> ndb_mgm--NDB Cluster--Management Client--ndb_mgm> showconnected to Management Server at:192.168.6.203:1 186Cluster Configuration---------------------[ndbd (NDB)]2 node (s) id=20@192.168.6.204 (mysql-5.6.31 ndb-7.4.12, nodegroup:0, *) id=21@192.168.6.205 (mysql-5.6.31 ndb-7.4.12, nodegroup:0) [NDB_MGMD (MGM)]1 node (s) id=10@ 192.168.6.203 (mysql-5.6.31 ndb-7.4.12) [Mysqld (API)]2 node (s) id=22@192.168.6.204 (mysql-5.6.31 ndb-7.4.12) id=23@ 192.168.6.205 (mysql-5.6.31 ndb-7.4.12) ndb_mgm>

When you see the above condition, the cluster starts successfully.


Go to mysqld to see if MySQL already supports the distributed storage engine Ndbcluster

Shell> mysql -uroot -pmysql> set password=password (' xxxxxx ')   #  First login needs to modify root  user's login password mysql> show engines\g;+--------------------+---------+----------------- -----------------------------------------------+--------------+------+------------+| engine              | Support | Comment                                                            | transactions | xa   | savepoints |+--------------------+------ ---+----------------------------------------------------------------+--------------+------+------------+|  ndbcluster         | yes     | clustered,  fault-tolerant tables                                |  yes          | no   | no          | |  MRG_MYISAM         | YES      | collection of identical myisam tables                            | no           | no   |  no         | |  myisam              | yes     |  MyISAM storage engine                                            | NO            | NO   | NO          | |  BLACKHOLE          | YES      | /dev/null storage engine  (anything you write to it  Disappears)  | NO           | NO    | no         | |  performance_schema | yes     | performance schema                                                | no           | no   |  no         | |  csv                |  YES     | CSV storage engine                                                | no           | no   | no          | |  ARCHIVE            | YES      | Archive storage engine                                           | NO            | NO   | NO          | |  FEDERATED          | NO       | Federated MySQL storage engine                                  | null          | null | null       | |  InnoDB             | DEFAULT  | supports transactions, row-level locking, and foreign keys      | YES          | YES   | yes        | |  ndbinfo            | YES      | MySQL Cluster system information storage engine                 | NO            | no   | no         | |  MEMORY             | YES      | Hash based, stored in memory, useful for  temporary tables      | no            | NO   | NO          |+--------------------+---------+----------------------------------------------------------------+------- -------+------+------------+11 rows in set  (0.00 sec)


4. Test Data synchronization:

Create a t2 table on the 192.168.6.204:

Mysql> use test;database changedmysql> create table t2 (id int,  Name varchar ()  engine=ndbcluster; query ok, 0 rows affected  (0.10 sec) mysql> desc t2;+-------+------- ------+------+-----+---------+-------+| field | type         | null | key | default | extra |+-------+-------------+------+-- ---+---------+-------+| id    | int (one)      | yes   |     | NULL    |        | |  name  | varchar ( | yes  |     | null)     |       |+-------+-------------+------+-----+------ ---+-------+2 rows in set  (0.00 sec)

The

Inserts a piece of data into the table T2 on 192.168.6.205:

mysql> desc t2;+-------+-------------+------+-----+---------+-------+| field |  type        | null | key | default |  extra |+-------+-------------+------+-----+---------+-------+| id    |  int (one)      | yes  |     | null     |       | |  name  | varchar ( | yes  |     | null)     |       |+-------+-------------+------+-----+------ ---+-------+2 rows in set  (0.00 sec) mysql> insert into t2  VALUES (1, ' Lisan '); query ok, 1 row affected  (0.00 sec) mysql> select * from  t2;+------+-------+| id   |  name  |+------+-------+|    1 | lisan |+------+-------+1  row in set  (0.00 SEC)

View the T2 table on 204:

Mysql> SELECT * FROM t2;+------+-------+| ID |    Name |+------+-------+| 1 | Lisan |+------+-------+1 row in Set (0.00 sec)

When you see the results above, the distributed MySQL data is successfully synchronized.


Problems encountered during installation:

1, unable to connect with connect string:nodeid=0,localhost:1186 retrying every 5 seconds. Attempts Left:2 1, failed.

Possible causes: Package installation error (multiple or low-load error); Config.ini or my.cnf configuration file is incorrect;

2, unable to connect with connect string:nodeid=0,192.168.1.102:1186 retrying every 5 seconds. Attempts Left:12 9 8 7 6 5 4 3 2 1, failed.

Possible cause: Firewall on, block the cluster data communication, SELinux Open, can be closed by Setenforce 0;



This article is from the "Alfer" blog, make sure to keep this source http://alfer.blog.51cto.com/9133887/1842087

Mysql Cluster7.4.12 Distributed Cluster setup

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.