Install MySQL multi-instance in Linux as the data backup server to back up multiple master instances to one slave multi-instance

Source: Internet
Author: User

1. Download the MySQL source code version from the MySQL official website [must be the source code version]
2. follow these steps: Code Type Linux Command Line Copy code The Code is as follows: [note] adding a MySQL group and a user
# Groupadd MySQL
# Useradd-G MySQL
[Note] unpackage to/usr/local
# Tar-xzf mysql-standard-4.1.9-pc-linux-gnu-i686.tar.gz-C/usr/local
[Note] creating a soft link is convenient (this connection can be named mysql001 or another name)
# Cd/usr/local
# Ln-s mysql-standard-5.0.15-linux-i686-glibc23 mysql001
# Cd mysql001
# Scripts/mysql_install_db
# Chown-r root.
# Chown-r Mysql Data
# Chgrp-r MySQL.
[Note] Copy Data for allocation of multiple instances in a single version
# Cp-a data data_1
# Cp-a data data_2
[Note] Add a multi-instance configuration file
# Cd/usr/local/mysql001/bin
# Cat> my_multi.cnf
[Note] the following is the configuration information of my_multi.cnf, which can be copied accordingly.
[Mysqld_multi]
Mysqld =/usr/local/mysql001/bin/mysqld_safe
Mysqladmin =/usr/local/mysql001/bin/mysqladmin
User = root
Password = root
[Mysqld1]
Socket =/tmp/mysql_001.sock
Port = 3301
PID-file =/usr/local/mysql001/data_1/hostname. PID
Datadir =/usr/local/mysql001/data_1
Log =/usr/local/mysql001/data_1/hostname. Log
User = MySQL
# Slave setting
Server-id = 2
Master-host = 192.168.1.85
Master-Port = 3306
Master-user = backup
Masters-Password = 123456
Replicate-do-DB = gs_database
Replicate-do-DB = gs_log
Master-connect-retry = 30
[Mysqld2]
Socket =/tmp/mysql_5_2.sock
Port = 3302
PID-file =/usr/local/mysql001/data_2/hostname. PID
Datadir =/usr/local/mysql001/data_2
Log =/usr/local/mysql001/data_2/hostname. Log
User = MySQL
# Slave setting
Server-id = 3
Master-host = 192.168.1.69
Master-Port = 3306
Master-user = backup
Masters-Password = 123
Replicate-do-DB = gs_databaes
Replicate-do-DB = gs_log
Master-connect-retry = 30

CTRL + D to exit.Copy codeThe Code is as follows: # vi/etc/profile # Add system environment variables.
Export mysql_home =/usr/local/mysql001/bin
Export Path = $ path: $ mysql_home

Restart the system to make environment variables take effect.
Add to enable automatic start. [do not add this parameter here. You can decide whether to enable automatic start based on your situation]Copy codeThe Code is as follows: VI/etc/rc. Local
# Add
Mysqld_multi -- defaults-extra-file =/usr/local/src/mysql_dir/bin/my_multi.cnf start 1, 2

3. Other skills
# Access an instance:
Mysql-u root-S/tmp/mysql_5_1.sock-P

# Set the password of each instance:
Mysqladmin-u Root Password 'root'-S/tmp/mysql_5_1.sock

# Manually start each instance:
Mysqld_multi -- defaults-extra-file =/usr/local/src/mysql_dir/bin/my_multi.cnf start 1, 2

# Stop instances:
Mysqld_multi -- defaults-extra-file =/usr/local/src/mysql_dir/bin/my_multi.cnf stop 1, 2

# ReferenceArticle
Http://blog.liuts.com/post/13/

It took three days for me to get started with Linux for the first time. I hope it will bring convenience to everyone.

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.