Use mysqld_multi to manage multiple MySQL instances

Source: Internet
Author: User

Today, a colleague asked me if MySQL could be backed up in real time from multiple master nodes to one slave node. Google 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, I just saw mysqld-Multi under a hands-on test.

The configuration process is as follows,
1. Modify the MySQL configuration file my. CNF to configure the mysqld_multi option.

[Mysqld_multi]
Mysqld =/usr/local/MySQL/bin/mysqld_safe
Mysqladmin =/usr/local/MySQL/bin/mysqladmin
User = multi_admin
Password = multipass
Log =/usr/local/MySQL/etc/mysqld_multi.log


2. Create config-file for mysqld_multi

CAT/usr/local/MySQL/etc/mysqld_multi.cnf
[Mysqld1]
Socket =/tmp/MySQL. sock1
Port = 3306
PID-file =/usr/local/MySQL/var1/localhost. PID
Datadir =/usr/local/MySQL/var1
User = MySQL

[Mysqld2]
Socket =/tmp/MySQL. sock2
Port = 3307
PID-file =/usr/local/MySQL/var2/localhost. PID
Datadir =/usr/local/MySQL/var2
User = MySQL

[Mysqld3]
Socket =/tmp/MySQL. sock3
Port = 3308
PID-file =/usr/local/MySQL/var3/localhost. PID
Datadir =/usr/local/MySQL/var3
User = MySQL
3. Copy mysqld_multi.server (in Source code To/usr/sbin.

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)

'Start ')
"$ Mysqld_multi" Start $2
;;
'Stop ')
"$ Mysqld_multi" -- config-file =/usr/local/MySQL/etc/mysqld_multi.cnf stop $2
;;
'Report ')
"$ Mysqld_multi" -- config-file =/usr/local/MySQL/etc/mysqld_multi.cnf report $2
5. Start Multiple MySQL instances

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.

Mysql-u root-S/tmp/MySQL. sock1-P
Mysql> grant shutdown on *. *Multi_admin @ 'localhost'Identified by 'multipass ';
7. Close all database instances

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 database instances at the same time.
Start: mysqd_multi start 1-3
Close: mysqd_multi stop 1-3

 

Http://www.sanote.cn/mysqld-multi.html

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.