MySQL-Cluster7.2.5 installation and configuration

Source: Internet
Author: User


Environment: One 10.32.33.120 is used as a data node, an SQL node, and a management node 10.32.34.116 as a data node and an SQL node. The operating system is CentOS5.4 64-bit.
1. Download MySql Cluster7.2.5 http://www.mysql.com/downloads/cluster/ NOTE: If MySql already exists, delete it first. If you can connect to yum remove mysql, or manually delete mysql, first check which packages are installed: # rpm-qa | grep MySQL and then uninstall these packages rpm-e MySQL-server-5.5.21-1.linux2. 6rpm-e MySQL-client-5.5.20-1.linux2.6 two download unzip www.2cto.com first set 10.32.33.120, download the MySql Cluster to the/downfiles # cd downfiles # tar-zxvf mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz // extract three to copy the extracted files to/usr/local, name: mysql # cp/downfiles/mysql-cluster-gpl-7.2.5-linux2.6-x86_64/usr /Local/mysql # cd/usr/local/mysql # chown-R root. // set the mysql directory to root # chown-R mysql/data // set the data directory to mysql # chgrp-R mysql. // change the group to mysql # cd scripts/# mysql_install_db-user = mysql. In this case, the mysql service is installed to start automatically at startup # chmod + x/etc/rc. d/init. d/mysqld // grant the modifiable permission to this file # The chkconfig -- add mysqld // chkconfig command is mainly used to update (start or stop) and query the running level information of the system service, chkconfig -- add name: add a new service. You cannot start the service after it is started. You also need to set the environment variable # vi/etc/profile. $ PATH:/usr/local/mysql/binexport PATH the preceding operations are performed on the two servers. V. Configuration 1. Copy/usr/local/mysql/bin/ndb_mgm from the Configuration Management node, two ndb_mgmd files:/usr/local/bin # cp/usr/local/mysql/bin/ndb_mgm */usr/local/bin # mkdir/var/lib/mysql-cluster # vim/var/lib/mysql-cluster/config. enter the following content in ini: [ndbd default] NoOfReplicas = 1 # number of images on each data node DataMemory = 200 M # Memory IndexMemory = 20 M allocated to data in each data node # allocate indexes to each data node memory [ndb_mgmd] # Configuration Management node NodeId = 1 www.2cto. comhostname = 10.32.34.w.datadir =/var/lib/mysql-cluster/# manage node data (log) [Ndbd] # data node configuration NodeId = 2 hostname = 10.32.33.120datadir =/usr/local/mysql/data/# data node directory [ndbd] NodeId = 3 hostname = 10.32.34.116datadir =/usr /local/mysql/data/[mysqld] hostname = 10.32.33.120 [mysqld] hostname = 10.32.34.116 [mysqld] # Be sure to leave an empty one, for extension purposes, otherwise Failed to allocate nodeid No free node id found for ndbd (NDB) error [mysqld] Note: Do not add the comment on the Right of [] During configuration, otherwise, the system does not recognize it. [Ndbd default]: indicates that the DEFAULT configuration of each data node does not need to be written in [NDBD] of each node. There can only be one. [NDB_MGMD]: indicates the configuration of the Management node, only one. [NDBD]: indicates the configuration of each data node, which can have multiple. [MYSQLD]: indicates the configuration of SQL nodes. You can enter multiple IP addresses of different SQL nodes. 2. When the mysql service is started on the data node and SQL node,/etc/my is loaded by default. cnf is used as its configuration file to modify my on 10.32.33.120. cnf [mysqld] ndbcluster # Run NDB storage engine datadir =/usr/local/mysql/databasedir =/usr/local/mysqlport = 3306 www.2cto.com [mysql_cluster] ndb-connectstring = connector # statement copy one copy of the Management node to another 10.32.34.116 # scp/etc/my. cnf 10.32.34.116:/etc/6 start nodes in the order of management nodes-> data nodes-> SQL nodes. 1. Start the management node # cd/usr/local/bin # on 120 #. /ndb_mgmd-f/var/lib/mysql-cluster/config. ini // ndb_mgmd is the Management Server of mysqlcluster.-f indicates that the following parameter is the startup parameter configuration file. If a data node is added several days after startup, The -- initial Parameter must be added when the configuration file is modified to start, otherwise, the added node will not work in mysql cluster. 2. Add the -- initial Parameter when starting the data node for the first time after the data node is installed, unless it is restarted after backup, recovery, or configuration change # cd/var/local/mysql/bin/ndbd-initial2012-03-28 02:01:38 [ndbd] INFO -- Angel connected to '10. 32.33.120: 1186 '2017-03-28 02:01:38 [ndbd] INFO -- Angel allocated nodeid: 36 this message indicates that the startup is successful. 3. Start the SQL node # mysqld_safe -- ndb_nodeid = 5 -- user = mysql & in the same way, start another machine. Pay attention to the nodeid number. 4. Check the Client # cd/usr/local/bin #. showCluster Configuration ------------------- ndb_mgm> showCluster Configuration region [ndbd (NDB)] 2 node (s) id = 2 @ 10.32.33.120 (mysql-5.5.20 ndb-7.2.5, Nodegroup: 0, Master) id = 3 @ 10.32.34.116 (mysql-5.5.20 ndb-7.2.5, Nodegroup: 1) [ndb_mgmd (MGM)] 1 node (s) www.2cto. comid = 1 @ 10.32.34.116 (mysql-5.5.20 ndb-7.2.5) [mysqld (API)] 4 node (S) id = 4 @ 10.32.33.120 (mysql-5.5.20 ndb-7.2.5) id = 5 @ 10.32.34.116 (mysql-5.5.20 ndb-7.2.5) id = 6 (not connected, accepting connect from any host) id = 7 (not connected, accepting connect from any host). You can see that each node is connected and the mysql cluster configuration is complete. if you cannot see the above information, it may be a firewall problem. You can choose to turn off the CentOS firewall with the command:/etc/init. d/iptables stop management node is closed. Enter shutdown at the ndb_mgm> prompt, and then enter exit to exit. 7. Test. 1. Log On from SQL node A, create A database and A table, and perform A simple test. Mysql> create database zxztest; mysql> use zxztest; Database changedmysql> create table test1 (id int, name varchar (10) engine = ndb; mysql> insert into test1 values (1, 'zhaoxuezhi'); mysql> select * from test1; + ------ + --------- + | id | name | + ------ + --------- + | 1 | zhaoxuezhi | + ------ + --------- + log on to Node B to view the effect, database, table, and data. Insert A data entry from Node B and log on to node A to see that the data has been synchronized. Author: Zhao xuezhi

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.