Mysql-cluster Installation Chapter (3)---rpm easy installation method

Source: Internet
Author: User
Tags chmod

Zhou clan, finishing technical documents, for the next generation to stay a little tutorial ...


Network architecture

192.168.0.202 Management node (MGM)

192.168.0.203 Storage node (NDB)

192.168.0.204 query Node (API)

Prepare the material (can be downloaded to the official website, unzip to take out these two packages)

mysql-cluster-client-gpl-7.3.5-1.el6.x86_64.rpm

mysql-cluster-server-gpl-7.3.5-1.el6.x86_64.rpm


Before starting the installation, or repeatedly told that the MGM management node, only need BIN/NDB_MGMD and BIN/NDB_MGM, NDB storage node, only need to BIN/NDB_MGM, know this, then it should be easy to understand our configuration below



The 192.168.0.202 configuration is as follows:

1, clean the machine with any MySQL-related packages

[[email protected] ~]# rpm-qa |grep MySQL

Mysql-5.1.61-4.el6.x86_64

Mysql-libs-5.1.61-4.el6.x86_64

Mysql-devel-5.1.61-4.el6.x86_64


[Email protected] ~]# yum-y remove mysql-5.1.61-4.el6.x86_64 mysql-libs-5.1.61-4.el6.x86_64 Mysql-devel-5.1.61-4.el6.x86_64


2, installation, because MGM only need to use mysql-cluster-server this package inside of the two bin file, but please note, here I was directly installed, although a bit superfluous, but forget, too lazy to get those two bags, direct rpm good, I know on the line.


[Email protected] ~]# RPM-IVH mysql-cluster-server-gpl-7.3.5-1.el6.x86_64.rpm

Preparing ... ########################################### [100%]

1:mysql-cluster-server-gp########################################### [100%]


3. Create a Folder

[Email protected] ~]# Mkdir/var/lib/mysql/data

[Email protected] ~]# Mkdir/var/lib/mysql-cluster

[Email protected] ~]# Mkdir/var/run/mysqld

[Email protected] ~]# chmod-r 1777/var/lib/mysql

[Email protected] ~]# chmod-r 1777/var/lib/mysql-cluster/

[Email protected] ~]# chmod-r 1777/var/run/mysqld/


It is necessary to explain, mysql/data this is the storage database, Mysql-cluster this is the Management node configuration path, Run/mysqld this is the MySQL run the background pid path, of course, these you can change according to your own needs.


4, enter the/var/lib/mysql-cluster directory, create the config.ini configuration file;

[NDBD Default]

noofreplicas=2

datamemory=80m

indexmemory=18m


[NDB_MGMD]

# IP Address of the first management node

Nodeid=1

hostname=192.168.0.202

Datadir=/var/lib/mysql-cluster


[NDBD]

# IP Address of the Storage Server (NDBD) Node 1

hostname=192.168.0.203

Datadir=/var/lib/mysql/data


[Mysqld]

hostname=192.168.0.204


[Mysqld]

[Mysqld]


5, start the Management node service, remember to specify the configuration path, otherwise the system will be created by default to

[[email protected] ~]# ndb_mgmd-f/var/lib/mysql-cluster/ Config.ini--configdir=/var/lib/mysql-cluster/

MySQL cluster Management Server mysql-5.6.17 ndb-7.3.5

[[ Email protected]_server ~]# NDB_MGM

--NDB Cluster--Management Client--

ndb_mgm> show

Connected to Management Server at:localhost:1186

Cluster Configuration

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

[ NDBD (NDB)]     1 node (s)

id=2 (not connected, accepting connect from 192.168.0.203)


[ NDB_MGMD (MGM)] 1 node (s)

As you can see, get up, however, note the following three conditions:

Situation one: If you are a dual management node, then at this moment, it is impossible to get up, he will wait for another management node connection, error is as follows

[Email protected] ~]# NDB_MGM

--NDB Cluster--Management Client--

Ndb_mgm> Show

Connected to Management Server at:localhost:1186

ERROR message:the cluster configuration is not yet confirmed by all defined Management servers. This management server was still waiting for node 2 to connect.


Could not get Configuration

* 4012:failed to get configuration

* The cluster configuration is not a yet confirmed by all defined Management servers. This management server was still waiting for node 2 to connect.

Ndb_mgm>

Situation Two: If you are a dual management node, and both of the Management node service started, and, all normal, then put one of the management node off, another management node show, no problem.

Situation three: If you are a dual management node, and both of the Management node service started, and, all normal, then the whole cluster shut down, or you can simulate accidental power loss, all machines are shutdown, boot, you will find that this time the management node, one can show, You do not have to wait for two management nodes to go up to show.


Summarize:

Single management node, without any problems, start the service directly, you can show

Double Management node, there is a problem, the first time, there is and the first time, the need to wait for both parties to negotiate handshake, to complete, hit a must, two people together on the bathroom, a on the end, can not go, must wait B also finish, in order to join hands to leave; Because it already knows that there is another B, in the heart know the line, do not care about B's dead and alive. Similarly, b is the same;



The 192.168.0.203 configuration is as follows:

1, clean the machine with any MySQL-related packages

[[email protected] ~]# rpm-qa |grep MySQL

Mysql-5.1.61-4.el6.x86_64

Mysql-libs-5.1.61-4.el6.x86_64

Mysql-devel-5.1.61-4.el6.x86_64


[Email protected] ~]# yum-y remove mysql-5.1.61-4.el6.x86_64 mysql-libs-5.1.61-4.el6.x86_64 Mysql-devel-5.1.61-4.el6.x86_64


2, installation, because NDB only need to use mysql-cluster-server this package inside a bin file (NDBD), but please note, here I was directly installed throughout, a little superfluous.


[Email protected] ~]# RPM-IVH mysql-cluster-server-gpl-7.3.5-1.el6.x86_64.rpm

Preparing ... ########################################### [100%]

1:mysql-cluster-server-gp########################################### [100%]


3. Create a Folder

[Email protected] ~]# Mkdir/var/lib/mysql/data

[Email protected] ~]# Mkdir/var/lib/mysql-cluster

[Email protected] ~]# Mkdir/var/run/mysqld

[Email protected] ~]# chmod-r 1777/var/lib/mysql

[Email protected] ~]# chmod-r 1777/var/lib/mysql-cluster/

[Email protected] ~]# chmod-r 1777/var/run/mysqld/


It is necessary to explain, mysql/data this is the storage database, Mysql-cluster this is the Management node configuration path, Run/mysqld this is the MySQL run the background pid path, of course, these you can change according to your own needs.


4. Create/etc/my.cnf

[Client]

Socket=/var/lib/mysql/mysql.sock


[Mysqld]

max_connections=100

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock


[Mysqld_safe]

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid


[Mysql_cluster]

ndb-connectstring=192.168.0.202


5. Start the NDB node

[Email protected] ~]# NDBD--initial

2014-07-15 19:12:35 [NDBD] INFO--Angel connected to ' 192.168.0.202:1186 '

2014-07-15 19:12:35 [NDBD] INFO--Angel allocated Nodeid:2


6, to the Management node, show a bit to see

Ndb_mgm> Show

Cluster Configuration

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

[NDBD (NDB)] 1 node (s)

id=2 @192.168.0.203 (mysql-5.6.17 ndb-7.3.5, starting, nodegroup:0)


[NDB_MGMD (MGM)] 1 node (s)

Id=1 @192.168.0.202 (mysql-5.6.17 ndb-7.3.5)


[Mysqld (API)] 3 node (s)

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

Id=4 (not connected, accepting connect from any host)

Id=5 (not connected, accepting connect from any host)

Obviously, it's already connected.



The 192.168.0.204 configuration is as follows:

1, clean the machine with any MySQL-related packages

[[email protected] ~]# rpm-qa |grep MySQL

Mysql-5.1.61-4.el6.x86_64

Mysql-libs-5.1.61-4.el6.x86_64

Mysql-devel-5.1.61-4.el6.x86_64


[Email protected] ~]# yum-y remove mysql-5.1.61-4.el6.x86_64 mysql-libs-5.1.61-4.el6.x86_64 Mysql-devel-5.1.61-4.el6.x86_64


2, installation, Mysql-cluster-server and mysql-cluster-client


[Email protected] ~]# RPM-IVH mysql-cluster-server-gpl-7.3.5-1.el6.x86_64.rpm

Preparing ... ########################################### [100%]

1:mysql-cluster-server-gp########################################### [100%]

[Email protected] ~]# RPM-IVH mysql-cluster-client-gpl-7.3.5-1.el6.x86_64.rpm

Preparing ... ########################################### [100%]

1:mysql-cluster-client-gp########################################### [100%]


3. Create a Folder

[Email protected] ~]# Mkdir/var/lib/mysql/data

[Email protected] ~]# Mkdir/var/lib/mysql-cluster

[Email protected] ~]# Mkdir/var/run/mysqld

[Email protected] ~]# chmod-r 1777/var/lib/mysql

[Email protected] ~]# chmod-r 1777/var/lib/mysql-cluster/

[Email protected] ~]# chmod-r 1777/var/run/mysqld/


It is necessary to explain, mysql/data this is the storage database, Mysql-cluster this is the Management node configuration path, Run/mysqld this is the MySQL run the background pid path, of course, these you can change according to your own needs.


4. Create/etc/my.cnf

[Client]

Socket=/var/lib/mysql/mysql.sock


[Mysqld]

max_connections=100

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

Ndbcluster

ndb-connectstring=192.168.0.202


[Mysqld_safe]

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid


5. Start the SQL service

[[email protected] ~]#/etc/init.d/mysql start

Starting MySQL ..... success!

[Email protected] ~]#


6, to the Management node, show a bit, see Mysql-api is not already up

Ndb_mgm> Show

Cluster Configuration

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

[NDBD (NDB)] 1 node (s)

id=2 @192.168.0.203 (mysql-5.6.17 ndb-7.3.5, nodegroup:0, *)


[NDB_MGMD (MGM)] 1 node (s)

Id=1 @192.168.0.202 (mysql-5.6.17 ndb-7.3.5)


[Mysqld (API)] 3 node (s)

Id=3 @192.168.0.204 (mysql-5.6.17 ndb-7.3.5)

Id=4 (not connected, accepting connect from any host)

Id=5 (not connected, accepting connect from any host)


7, to this, the entire cluster is completed.


Summary of issues:

1, if you want to expand the cluster, such as the addition of a NDB node, how to engage in

Manage nodes, delete all files beginning with NDB under/var/lib/mysql-cluster/

Manage nodes, modify/var/lib/mysql-cluster/config.ini, add NDB cluster ID and hostname

Storage nodes, modifying my.cnf, adding [Mysql_cluster] ndb-connectstring=192.168.0.202


2, if, one day, suddenly, want to put 203 this NDB node, attach on the API node, then there will be an egg ache things appear, theoretically, mysql-cluster each node, are independent, tube it is the same or different Taiwan, are normal; but if you add it, You need to pay attention to one thing.

the NDB node and SQL node of the same machine, must NDB node first start, in order to start the SQL node, otherwise SQL node, is never even on the cluster, never, I am tangled this problem, always do not start NDB node, in question themselves, why the SQL node started, The management node does not see the SQL node state.


3. command to close the cluster

Close the query node first mysqladmin-uroot-p shutdown password in/root/.mysql_secret

Then close the cluster node ndb_mgm-e shutdown


This article from the "Zhou Clan" blog, declined to reprint!

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.