Install Mysql multiple instances under Linux as a data backup server to achieve multiple-master to one from multiple instances of backup _mysql

Source: Internet
Author: User
Tags mysql version
1, from MySQL official download mysql version of the source code "must be the source version"
2, the following code type Linux command line
Copy Code code as follows:

[note] Add MySQL group and user
#groupadd MySQL
#useradd-G MySQL MySQL
[note] Unpack to/usr/local
# TAR-XZF Mysql-standard-4.1.9-pc-linux-gnu-i686.tar.gz-c/usr/local
[note] Establish a soft link to facilitate the operation (this connection is named mysql001, also can be other 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 single version multiple instance allocation
#cp-A data data_1
#cp-A data data_2
[note] Adding multiple instance configuration files
#cd/usr/local/mysql001/bin
#cat >my_multi.cnf
[note] The following is the configuration information for MY_MULTI.CNF, which can be replicated
[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
Master-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
Master-password = 123
Replicate-do-db = Gs_databaes
Replicate-do-db = Gs_log
Master-connect-retry=30

Ctrl+d exit.
Copy Code code as follows:

#vi/etc/profile # adds system environment variables.
Export Mysql_home=/usr/local/mysql001/bin
Export path= $PATH: $MYSQL _home

Reboot the system for the environment variable to take effect.
Add to boot automatically "do not add here, depending on your personal situation to determine whether the need to set up automatic startup"
Copy Code code 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. Some other skills
# access to an instance:
Mysql-u root-s/tmp/mysql_5_1.sock-p

# Set Individual instance passwords:
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 each instance:
Mysqld_multi--defaults-extra-file=/usr/local/src/mysql_dir/bin/my_multi.cnf Stop 1,2

# Reference Articles
http://blog.liuts.com/post/13/

Due to the first contact with Linux, it took three days to achieve success, send out hope can bring convenience to everyone
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.