To manage multiple MySQL database instances, use mysqld_multi!

Source: Internet
Author: User

The following articles mainly introduce the actual operation process of using mysqld_multi to manage multiple MySQL database instances. MySQL databases can be backed up in real time from multiple master nodes, in google, you can use mysqld_multi to manage multiple MySQL instances.

I have previously thought about running multiple MySQL instances on one server to implement real-time backup in the master-slave mode with multiple masters, today, we can see that mysqld-multi is used to test the configuration process as follows,

1. Modify the mysql configuration file my. cnf to configure the mysqld_multi option.

 
 
  1. [mysqld_multi]  
  2. mysqld = /usr/local/mysql/bin/mysqld_safe  
  3. mysqladmin = /usr/local/mysql/bin/mysqladmin  
  4. user = multi_admin 
  5. password = multipass 
  6. log = /usr/local/mysql/etc/mysqld_multi.log 

2. Create config-file for mysqld_multi

 
 
  1. cat /usr/local/mysql/etc/mysqld_multi.cnf   
  2. [mysqld1]  
  3. socket = /tmp/mysql.sock1  
  4. port = 3306 
  5. pid-file = /usr/local/mysql/var1/localhost.pid  
  6. datadir = /usr/local/mysql/var1  
  7. user = mysql 
  8. [mysqld2]  
  9. socket = /tmp/mysql.sock2  
  10. port = 3307 
  11. pid-file = /usr/local/mysql/var2/localhost.pid  
  12. datadir = /usr/local/mysql/var2  
  13. user = mysql 
  14. [mysqld3]  
  15. socket = /tmp/mysql.sock3  
  16. port = 3308 
  17. pid-file = /usr/local/mysql/var3/localhost.pid  
  18. datadir = /usr/local/mysql/var3  
  19. user = mysql 

3. Copy the mysqld_multi.server script to/usr/sbin in support-files in the source code.

 
 
  1. cp /mysql_source/support-files/mysqld_multi.server /usr/sbin 

4. Edit/usr/sbin/mysqld_multi.server (add the-config-file =/usr/local/mysql/etc/mysqld_multi.cnf option)

 
 
  1. 'start' )  
  2. "$mysqld_multi" start $2  
  3. ;;  
  4. 'stop' )  
  5. "$mysqld_multi" --config-file=/usr/local/mysql/etc/mysqld_multi.cnf stop $2  
  6. ;;  
  7. 'report' )  
  8. "$mysqld_multi" --config-file=/usr/local/mysql/etc/mysqld_multi.cnf report $2 

5. Start Multiple MySQL database instances

 
 
  1. mysqld_multi.server start 

6. the user and password set in my. cnf are used to disable the database instance. The shutdown permission is granted to the user according to the user name and password in the configuration.

 
 
  1. mysql -u root -S /tmp/mysql.sock1 -p  
  2. mysql> grant shutdown on *.* to multi_admin@'localhost' identified by 'multipass'; 

7. Close all database instances

 
 
  1. mysqld_multi.server stop 

8. Start and close a single database

Syntax: mysqld_multi [options] {start | stop | report} [GNR [, GNR]…]

For example, you can use mysqld_multi to start or disable mysqld1.

Start: mysqd_multi start 1

Close: mysqd_multi stop 1

You can also start and close multiple MySQL database instances at the same time.

Start: mysqd_multi start 1-3

Close: mysqd_multi stop 1-3

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.