Mysqlcluster Boot automatically

Source: Internet
Author: User

The company tested the environment and deployed MySQL cluster with two servers. Because the company's computer room is often power outages, resulting in each server restart, you have to manually restart the various servers, otherwise it can not be tested, very troublesome. So the combination before the Internet to see the monitoring script, organized an automatic startup program. The current test is normal.

MySQL cluster start-up needs to be in a fixed order: Manage node-and data node->sql nodes, if not started in this order, may cause the service to be unhealthy. At present, the following method is used to realize the automatic start of each node:

Description of server Deployment:

1.202 Server Deployment Management node, data node, SQL node. 2.204 Server Deployment Data node, SQL node.

Auto-start Scenario:

#管理节点和SQL节点的启动放到rc. Local execution # Add the following code in/etc/rc.local/usr/local/mysql/bin/ndb_mgmd-f/var/lib/mysql-cluster/ Config.ini/usr/local/mysql/bin/mysqld_safe &

The start of the data node needs to wait for the management node to start before it can be started. Therefore, a monitoring script is used to control the start of the data node, the management node listens on port 1186, and the NC detects the status of Port 1186 to determine whether the management node has been successfully started. The code for the monitoring script looks like this: #!/bin/bashwhile  :d o# detect if the management node has started nc-w 10-z 192.168.1.202 1186 >/dev/null 2>&1ndb_mgmd= ' echo $? ' If [$ndb _mgmd-eq 0];then# The Management node is started, the data node and the SQL node are instrumented. #如果数据节点未启动, start the data node and restart Mysqld. Otherwise, no action is done. Ndbd_num= ' Ps-c ndbd--no-header | Wc-l ' If [$ndbd _num-eq 0];then  /usr/local/mysql/bin/ndbd  #sleep  service mysqld restartfielse# When the management node is not started or the management node hangs, close the data node          ndbd_num= ' ps-c ndbd--no-header | wc-l '  IF [$ndbd _num! = 0];then  killall-s sigki LL ndbd  fifisleep 5done

Save the code for the monitoring script to/root/ndbd_mysql_check.sh, and add code to the rc.local to automatically start the execution of the script.

Add the following code to the/etc/rc.local, boot up monitoring script Nohup sh/root/ndbd_mysql_check.sh &





At this point, the automatic start of each node can be done. Restart each server separately for testing, if the service starts normally, indicating success.

Ps:

Problems found in the test: 1. When the data node has just started, you can connect to the database, but the query operation will be error: Error 1296 (HY000): Got error 157 ' Unknown error code ' from Ndbcluster wait a few minutes, when the query operation again, Back to normal. The guess may be that some nodes have not been fully started. 2. Also reported another error when making multiple-table union queries: sqlstate[hy000]: General error:1297 Got temporary error 20016 ' Query aborted due to node failure ' F Rom Ndbcluster back to normal after restarting 204 of the data nodes and SQL nodes. Before the test was only started 204 NDB and SQL, and did not start 202 NDB and SQL, suspect is not the two server data synchronization caused. No deep tracking.




At present, first recorded here, later encountered problems, and then back to update.





Mysqlcluster boot automatically

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.