Install mysql-cluster 7.3.5-linux and mysqlcluster

Source: Internet
Author: User

Install mysql-cluster 7.3.5-linux and mysqlcluster
[Cluster Environment]

Management node 10.0.0.19
Data Node 10.0.0.12
10.0.0.17
SQL node 10.0.0.18

10.0.0.22


1. Add a mysql user

# groupadd mysql# useradd mysql -g mysql

2. Install mysql-cluster 7.3.5-linux

# Cd/usr/local/src/(the cluster version has been downloaded) # tar-xvf mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64.tar.gz # mv mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64 .. /mysql # cd .. # chown-R mysql: mysql/# cd mysql # scripts/mysql_install_db -- user = mysql

Perform the preceding steps on all five machines.

3. cluster configuration

(1) manage nodes


# Vi/var/lib/mysql-cluster/config. ini (create a directory or file. Add the following content)

[Ndbd default] NoOfReplicas = 2 [tcp default] portnumber = 3306 [NDB_MGMD] # Set the nodeid = 1 HostName = 10.0.0.19DataDir =/var/mysql/data [NDBD] id = 2 HostName = 10.0.0.12DataDir =/var/mysql/data [NDBD] id = 3 HostName = 10.0.0.17DataDir =/var/mysql/data [MYSQLD] id = 4 HostName = 10.0.0.18 [MYSQLD] id = 5 HostName = 10.0.0.22 # The mysqld node must be empty, otherwise, [MYSQLD] id = 6 [mysqld] id = 7

Copy ndb_mgm and ndb_mgmd to the bin directory.

# cd /usr/local/mysql/bin# cp ./ndb_mgm /usr/local/bin/# cp ./ndb_mgmd /usr/local/bin/

Note: The management node only needs two files, ndb_mgm and ndb_mgmd, and one configuration file.
So copy these three files to the management node.
Ndb_mgmd is the mysql cluster management server, and ndb_mgm is the client management tool.


Start a management Node

# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
Close management Node

# ndb_mgm>shutdown

Note: The ndb_mgmd in the command line is the management server of the mysql cluster, and the-f behind it indicates that the following parameter is the startup parameter configuration file.
If a data node is added several days after the startup, The -- initial Parameter must be added when the configuration file is modified. Otherwise, the added node will not work in the mysql cluster.

# ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial

# ndb_mgm
Then you can access the client to perform various operations on the mysql cluster.


# Ndb_mgm> show to view the status of each node. # Ndb_mgm> all report memory view the usage of each data node # ndb_mgm> create nodegroup 3; create a data node group # mysql> alter online table data_house reorganize partition; adjust partition data

(2) Data Nodes


# Vi/etc/my. cnf (Add the following content)

[Mysqld] datadir =/var/mysql/datasocket =/var/mysql. sockuser = mysql # Disabling symbolic-links is recommended to prevent assorted security ready-links = 0 # Run NDB storage engine ndbcluster # specify the management node ndb-connectstring = 10.0.0.19 [MYSQL_CLUSTER] ndb-connectstring = 10.0.0.19 [NDB_MGM] connect-string = 10.0.0.19 [mysqld_safe] log-error =/var/mysql/log/mysqld. logpid-file =/var/run/mysqld. pid

The -- initial Parameter must be added when the data node is started for the first time after installation, unless it is restarted after backup, recovery, or configuration change.

#/Usr/local/mysql/bin/ndbd -- initial starts normally #/usr/local/mysql/bin/ndbd
(3) SQL Node

# cd /usr/local/mysql/
Set mysql service to start automatically

# cp support-files/mysql.server /etc/rc.d/init.d/mysqld# chmod +x /etc/rc.d/init.d/mysqld# chkconfig --add mysqld
# Vi/etc/my. cnf (Add the following content)
[Mysqld] server-id = 4 # datadir =/var/mysql/datasocket =/var/mysql. sockuser = mysql # Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links = 0log-bin =/var/mysql/log/mysql-bin.logmax_connections = 1000 # The following is the configuration file for the mysql master mode # ignore mysql Database Replication binlog-ignore-db = mysql # 2auto-increment-increment = 2 # Set the offset of the automatically increasing field, the initial value is 2auto-increment-offset = 1 [mysqld_safe] log-error =/var/mysql/log/mysqld. logpid-file =/var/run/mysqld. pid [MYSQLD] ndbclusterndb-connectstring = 10.0.0.19 [MYSQL_CLUSTER] ndb-connectstring = 10.0.0.19 [NDB_MGM] connect-string = 10.0.0.19
#service mysqld start

Solution to the error: 1. can't connect to local MySQL server through socket '/tmp/mysql. sock'
Ln-s/var/mysql. soc/tmp


The start sequence of the mysql cluster is: Management node> data node> SQL node.
The mysql cluster is closed in the following order: Management node> data node> SQL node.






Mysql-cluster problem,

Check whether the network and IP address have changed. Check the configuration file,/etc/hosts, and other paths. You can start them all first. Check it step by step
 
MySQL Cluster and mysql must be installed simultaneously

Mysql cluster is a separate installation package, which includes the mysql service itself. You do not need to download the installation package of mysql separately.

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.