MySQL cluster architecture and my configuration process problems and solutions

Source: Internet
Author: User

First, the pros and cons of MySQL

Advantages

Solve a single point of failure

Data redundancy is automatically implemented


The disadvantage is that it is too cumbersome to maintain.



The condition of the cluster is that all the machines are installed MySQL cluster software, I installed the mysql-cluster-gpl-7.3.5-1.el6.x86_64.rpm RPM package, not the source package installation. If the system installed in the Mysql-server and other database services software to write their own down.


There are three roles in the MySQL cluster, the following are three roles and their role

Role

Data nodes: NDBD nodes stored in table data (records in tables)

SQL node: does not store data for users to access and execute SQL operations

Management node: Used to manage the cluster, specify the configuration file to use when the host computer starts the management process



The next step is the point. The configuration file for the cluster.

First of all, the main configuration file of the management node, the main configuration file to the end of the. ini file, I stored the directory in the/etc/mysql-cluster.ini, which is my Management node configuration file.

Format:

Tag: The label is in brackets below [].

[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] Specifies the configuration of the data node

[MYSQLD] Specifies the configuration of the SQL node

Note: At this point you have several nodes to write several times the label, that is, if you have 2 machines to do SQL node, you must define 2 [mysqld] tags. This is also true for data nodes. Here is my own configuration.


[NDBD Default]

noofreplicas=2 a copy of several data backups, typically the same number of data nodes

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

INDEXMEMORY=18M uses more physical memory to hold the indexed field statements and execution results


[NDB_MGMD]

Nodeid=1 (the ID number in the same network cannot be duplicated and must be unique.) In general, you can set the master camera for the IP address of the machine, but in RedHat6, it seems that the Nodeid cannot exceed 50. )

IP address of the hostname=192.168.1.1 management host

Datadir=/usr/local/cluster/ndbddata the storage path of the cluster information collected when managing the cluster

(This directory must exist in the system, not manually established, the permissions do not matter)

[NDBD]

Nodeid=30

hostname=192.168.1.30

Datadir=/usr/local/cluster/ndbddata the path of the SQL node to store data

(This directory must exist in the system, not manually established, the permissions do not matter)

[NDBD]

Nodeid=40

hostname=192.168.1.40

Datadir=/usr/local/cluster/ndbddata

[Mysqld] does not specify the location of the datastore because it only provides MySQL services

nodeid=10

hostname=192.168.1.10

[Mysqld]

Nodeid=20

hostname=192.168.1.20


Note: Do not forget the contents of the above written, and so on. We've written the main configuration file and then we'll create our datadir. Don't forget.



To configure the data node:

Handwriting configuration file (all data nodes need to be configured, can be copied to other data nodes and then modified)

Its configuration file and Mysql-server configuration file with the same name, that is, MY.CNF, pay attention to the Mysql-server configuration file mv Go or rename

[Mysqld]

Datadir=/usr/local/cluster/ndbdata//This directory must be consistent with the directory specified in the management configuration file and not manually established

ndb-connectstring=192.168.1.1 point to the IP address of the person who manages my host

What storage engine is running on Ndbcluster

[Mysql_cluster] Specifies who manages the cluster

ndb-connectstring=192.168.1.1 managing hosts for a cluster



To configure the SQL node:

Writing a configuration file

VIM/ETC/MY.CNF is also a configuration file that needs to be created manually

[Mysqld]

Ndbcluster

DEFAULT-STORAGE-ENGIN=NDBCLUSTER Specifies the database storage engine to use

[Mysql_cluster] Specifies who manages the cluster

ndb-connectstring=192.168.1.1



Here, all the cluster computers are configured, and then we can start the service.


The order in which the clusters are started:

Start the process for the management node first

NDB_MGMD-F/Manage the path to the master profile, which uses the 1186 port of the native, and is entered at the command line


Access to cluster management

NDB_MGM input at the command line

Ndb_mgm>show View information


Start data process for data node

ndbd


Start the SQL Node database service

Service MySQL start is the same as the original database server



Secure shutdown of Cluster service

To turn off Cluster, simply enter the following command in the shell on the same machine as the MGM node:

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

Run the following command to close the SQL node's mysqld service:

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

Stop NDBD by kill-9 process number




Summary: In the process of building, there are a lot of small problems, as long as we are careful to avoid, for example, I encountered in the configuration of the problem.


First problem: The service of the management node cannot start

Ndb_mgmd-f/etc/mysql-cluster.ini

[Email protected] data]# ndb_mgmd-f/etc/mysql-cluster.ini

MySQL Cluster Management Server mysql-5.6.17 ndb-7.3.5

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

At first I thought Ndbdata is a file, the directory is only built to cluster, all the error, see the configuration file no problem, later found the Ndbdata is also a directory. This is a point to note, and this directory is consistent with the DataDir defined in the master configuration file.


The second problem: NDBD can not start, the error file means that the management node is not contacted, and then to see the configuration file on the NDBD node, found that the designated who manage my cluster when a cluster, that is, the right is [mysql_cluster] and I wrote [Mysqld], Will not start. Correct to change



Configuring a clustered server is not prone to error, as long as you are careful enough to be able to configure successfully once. After that is the question of tuning, you can according to the respective environment for tuning.

This article is from "Linux rookie" blog, please be sure to keep this source http://ludihua.blog.51cto.com/4601284/1410137

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.