Install Mysql multi-instance in Linux as the data backup server to implement multi-master to one-slave multi-instance _ MySQL

Source: Internet
Author: User
Install Mysql multi-instance in Linux as the data backup server to implement multi-master to one backup bitsCN. com1 from multiple instances. download the MYSQL source code version from the MYSQL official website [must be the source code version]
2. press the following code to type the LINUX command line

[Note] adding mysql groups and users
# 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.

# 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]

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

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

Since it took three days to get started with LINUX for the first time, I hope it will bring convenience to bitsCN.com.

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.