MySQL Cluster 7.4.1

Source: Internet
Author: User
Tags mysql delete

One: MySQL cluster principle:

1 MySQL cluster is divided into three nodes:

1.1 Control node: does not provide services by itself only controls the opening and closing of the entire cluster

1.2 Data node: Truly provides storage of the database and is associated with other data nodes

1.3 SQL Node: Provides normal service as usual database

Second: MySQL cluster essentials and ideas:

1 It is best to uninstall the existing MySQL or MARIADB,

Rpm-qa | grep mysql find a package containing MySQL

Rpm-e--nodeps mysql Delete and then check whether to delete clean

2 shut down the firewall/selinux Oh, otherwise there will be a problem with synchronizing data node synchronization

3 Delete or move out of my.cnf

Three: MySQL Build details:

1. Data nodes and SQL nodes

The first step is to add MySQL users and groups, which is required.

Groupadd MySQL

-g MySQL MySQL

The second step to start the installation, the download version is free of compile, copy it can be used.

Cd/Var/Tmp

Tar-C/Usr/Local-ZXVF MySQL-Cluster-Gpl-7.19a-linux-i686 -glibc23.. GZ

CD /usr/local

MV Mysql-cluster- gpl-7.1. 9a-linux-i686-glibc23.. GZ MySQL

The third step in MySQL to modify the directory permissions, which is also required, or the fourth step will be error.

CD MySQL

-.

-R MySQL data

-.

The fourth step installs the initial database table

Scripts/--user=mysql    

The fifth step is to set up the MySQL service to boot from

CP support-files/. Server /etc/rc.d/init. D/mysqld 

chmod +x /etc/rc./init./mysqld

chkconfig --add mysqld

Sixth step to start the MySQL service, if the error please refer to

Service mysqld Start

In these seven steps, additional server additions follow the steps above to add data nodes and SQL nodes.

2 Management nodes:

CD MySQL

CP bin/ndb_mgm*/usr/local/bin

/usr/local/bin

+x NDB_MGM*

Management node as long as the NDB_MGM and NDB_MGMD two files and a configuration file, so the three files are copied there, there is the management node.

NDB_MGMD is the MySQL cluster Management Server, NDB_MGM is the Client management tool, and so on will use them.

So far two SQL node two data nodes and a management node have been installed, but still do not work, have to be configured to connect these nodes together to work.

3. Configuration

1. Data nodes and SQL nodes

When the MySQL service starts, it will load/etc/my.cnf as its profile by default, and it is very simple to configure a MySQL server as a data node and SQL node, which is the content of the pre-configuration my.cnf:

[Client]

Port=3306

Socket=/tmp/Mysql.Sock

[Mysqld]

Basedir         = /usr/local/mysql/< Span class= "PLN" >

DataDir         =/usr/ local/mysql/data

User            = MySQL

Log-error       =/var/lib /mysql/mysqld.err

Just add 4 lines to the end of the content and turn the MySQL server into a data node and a SQL node.

#运行NDB存储引擎

Declare it as a SQL node #指定管理节点 the above two lines

NDB-connectstring=192.168. 1.252

[Mysql_cluster]

Declare it as a data node #指定管理节点 the above two lines

NDB-connectstring=192.168. 1.252

Note that all two servers have to be configured this way.

4. Management node

The configuration of the management node is a little more complicated to create a config.ini file in the Management Server/var/lib/mysql-cluster/directory.

/var/Lib

mkdir MySQL-cluster

CD MySQL-cluster

Vim config. INI

In the Config.ini file, add the following:

[NDBD DEFAULT]

Noofreplicas=1#每个数据节点的镜像数量

Datamemory=500M#每个数据节点中给数据分配的内存

Indexmemory=60UM #每个数据节点中给索引分配的内存

[TCP DEFAULT]

PortNumber=2202#数据节点的默认连接端口

[Ndb_mgmd]#配置管理节点

Hostname=10.10.10.164

DataDir=/var/Lib/Mysql-Cluster/#管理节点数据 (log) directory

[ndbd]#数据节点配置

Hostname=10.10.10.164

DataDir=/usr/Local/Mysql/Data/#数据节点目录

[ndbd]

Hostname=10.10.10.165

Datadir=< span class= "str" >/usr/local/mysql/data/

[mysqld]   #SQL节点目录

Hostname =10.10.10.165

[mysqld]

Hostname =10.10.10.166

[NDBD Default]: Indicates that each data node is configured to have no more options in the [NDBD] of each node, only one.
[NDB_MGMD]: Represents the configuration of the management node, only one.
[NDBD]: Represents the configuration of each data node, can have more than one.
[MYSQLD]: Represents the configuration of the SQL node, can have more than one, write the IP address of the different SQL nodes, can also write nothing,

Only one empty node is reserved, indicating that any IP address can be accessed, and the number of nodes indicates the total number of SQL nodes that can be used to connect to the data node.

Four, start

1. Management node

MySQL cluster requires each node to be started before it can work, and the node's boot order is the data node->sql node, the management node. Start the Management node first

/usr/local/bin

./-/var/Lib/MySQL-cluster/config. INI

The NDB_MGMD on the command line is the Management Server for MySQL cluster, followed by-F to indicate that the parameter that follows is the parameter configuration file that is started. If you have added a data node A few days after startup, you must add the--initial parameter when you modify the configuration file, otherwise the added node will not function in MySQL cluster.

./-/var/Lib/MySQL-cluster/config.  --initial             

A warning may be reported at startup, such as warning-at line 7: [TCP] portnumber is deprecated, this is not a tube. can work properly.

2. Data node

When you start the data node for the first time after installation, add the--initial parameter, and do not add it unless it is restarted after a backup, recovery, or configuration change.

/usr/local/mysql/bin/ndbd --initial

If the following information is displayed, start completion:

2010-12-31 12:48:03 [NDBD] INFO--Angel connected to ' 192.168.1.252:1186 '
2010-12-31 12:48:03 [NDBD] INFO--Angel allocated Nodeid:3

3. SQL node

Service mysqld Start

4. Client Management

/usr/local/bin

./NDB_MGM

At this point to enter the client, you can do various operations on the MySQL cluster, there will be NDB_MGM > prompt appears, first to see the connection of each node, enter show at ndb_mgm> prompt:

Ndb_mgm>Show

ClusterConfiguration

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

[ndbd(NDB)]2Node(S)

Id=2@192.168.1.252(Mysql-5.1.51Ndb-7.1.9,Nodegroup:0,Master)

Id=3@192.168.1.52(Mysql-5.1.51Ndb-7.1.9,Nodegroup:1)

[Ndb_mgmd(MGM)]1Node(S)

Id=1@192.168.1.252(Mysql-5.1.51Ndb-7.1.9)

[Mysqld(Api)]2Node(S)

Id=4@192.168.1.252   (mysql-5.1< Span class= "pun". 51 Ndb-7.1. 9

Id=5    @192.168. 1.52   (mysql-5.1 51 Ndb-7.1. 9

You can see that the individual nodes are connected, and the MySQL cluster configuration is complete.

Five, close

MySQL cluster is also very simple to close, just enter the shutdown at the ndb_mgm> prompt, this will show the closing information of each node, and then enter exit to exit NDB_MGM Management, back to the shell. Although MySQL cluster is turned off, the SQL node's MySQL service does not stop. Then we can do all kinds of experiments.

MySQL Cluster 7.4.1

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.