Troubleshooting of MySQL cluster architecture and configuration problems

Source: Internet
Author: User

Troubleshooting of MySQL cluster architecture and configuration problems

First, let's talk about the advantages and disadvantages of MySQL.

Advantages

  • Solving single point of failure
  • Automatic data redundancy

The disadvantage is that maintenance is too troublesome.

The rpm package of the supervisor. Install all software after unpacking. It is not the source code package installation. If mysql-server and other database service software are installed in the system, uninstall it on your own.

There are three roles in the MySQL cluster. The following are three roles and their functions.

Role

Data Node: data stored in the table by the ndbd node (records in the table)

SQL nodes: Do not store data for users to access and execute SQL operations

Management node: used to manage clusters. When the management process is started on the host, the configuration file used is specified.

The next step is the focus. Cluster configuration file. This configuration file must be manually created

The first step is to manage the master configuration file of the node. the file at the end of ini, where my directory is placed in the/etc/mysql-cluster.ini, is the configuration file for my management node.

Format:

[Ndbd default] specifies the public configuration of the data node, which applies to all nodes.

[Ndb_mgmd] specifies the configuration of the Management Node

[Ndbd] configuration of the specified data node

[Mysqld] specifies the SQL node configuration

Note: At this time, you have to write several tags for several nodes. That is to say, if you have two machines for SQL nodes, you must define two [mysqld] tags. The same is true for data nodes. The following is my configuration.

 

 

[Ndbd default]

NoOfReplicas = two copies of data backup, which is generally the same as the number of data nodes

DataMemory = 80 M uses more physical memory to save the executed SQL statements and execution results

IndexMemory = 18 M uses multiple physical memories to store the executed index field statements and execution results

 

 

[Ndb_mgmd]

Nodeid = 1 (the ID numbers in the same network cannot be repeated and must be unique. In general, you can set the host location of the IP address of the cost machine, but in RedHat6, it seems that the nodeid cannot exceed 50 .)

Hostname = 192.168.1.1 manage the IP address of the host

Datadir =/usr/local/cluster/ndbddata storage path of cluster information collected during cluster management

(This directory must exist in the system. It is not manually created and the permission does not matter)

 

[Ndbd]

Nodeid = 30

Hostname = 192.168.1.30

Datadir =/usr/local/cluster/ndbddata SQL node data storage path

(This directory must exist in the system. It is not manually created and the permission does not matter)

[Ndbd]

Nodeid = 40

Hostname = 192.168.1.40

Datadir =/usr/local/cluster/ndbddata

 

[Mysqld] You do not need to specify the data storage location because it only provides the mysql Service

NodeId = 10

Hostname = 192.168.1.10

[Mysqld]

NodeId = 20

Hostname = 192.168.1.20

Note: Do not forget the directory written above. We have written the main configuration file, and then we will create our datadir. Never forget.

Configure data nodes:

Hand-written configuration file (all data nodes need to be configured. You can copy a copy to another data node and then modify it)

The configuration file is the same as the configuration file of mysql-server, that is, my. cnf. Make sure to change the configuration file mv of mysql-server or change its name.

[Mysqld]

Datadir =/usr/local/cluster/ndbdata // This directory must be consistent with the directory specified in the management configuration file.

Ndb-connectstring = 192.168.1.1 points to who manages the IP address of my host

What storage engine does ndbcluster run?

[Mysql_cluster] specifies who manages the cluster.

Ndb-connectstring = 192.168.1.1 host of the Management Cluster

Configure an SQL node:

Compile the configuration file

Vim/etc/my. cnf is also the configuration file that needs to be created manually

[Mysqld]

Ndbcluster

Default-storage-engin = ndbcluster specifies the database storage engine used

[Mysql_cluster] specifies who manages the cluster.

Ndb-connectstring = 192.168.1.1

At this point, the computer configuration of all clusters is complete, and then we can start the service.

Cluster startup sequence:

Start the process for managing nodes first

Ndb_mgmd-f/specifies the path for managing the master configuration file. The native port 1186 is used and input it in the command line.

Go to cluster management

Ndb_mgm input in the command line

Ndb_mgm> show to view information

Start the Data Process of the Data Node

Ndbd

Start the Database Service of the SQL Node

Service mysql start is the same as that of the original database server.

Safely disable cluster services

To disable Cluster, you can simply enter the following command in Shell on the machine where the MGM node is located:

[Ndb_mgmd] root #/usr/local/mysql/ndb_mgm-e shutdown

Run the following command to disable the mysqld service of the SQL node:

[Ndb_mgmd] root #/usr/local/mysql/bin/mysqladmin-uroot shutdown

Stop ndbd with the kill-9 process number.

Conclusion: many minor problems have occurred during the construction process. You can avoid them with care, for example, the problems I encountered during configuration.

First problem: the service on the Management node cannot be started.

Ndb_mgmd-f/etc/mysql-cluster.ini

[Root @ localhost data] # ndb_mgmd-f/etc/mysql-cluster.ini

MySQL Cluster Management Server mysql-5.6.17 ndb-7.3.5

03:23:47 [MgmtSrvr] ERROR -- Directory '/usr/local/cluster/ndbdata' specified with DataDir in configuration does not exist.

At the beginning, I thought ndbdata was a file, and the directory was only created in the cluster. When all the files were created, an error was reported. After reading the configuration file, I found that ndbdata is also a directory. Note this, And the directory must be consistent with the datadir defined in the main configuration file.

The second problem: ndbd cannot be started. The error file means that it cannot be connected to the management node. Later, I went to see the configuration file on the ndbd node, I found that one cluster was missing when specifying who managed my cluster. That is, the correct one is [mysql_cluster] And I wrote it as [mysqld], so it cannot be started. Correct

Configuration of cluster servers is not prone to errors, as long as you are careful enough, you can complete one-time configuration. After that, the optimization problem is solved. You can perform optimization based on your own environment.

-------------------------------------- Split line --------------------------------------

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

-------------------------------------- Split line --------------------------------------

This article permanently updates the link address:

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.