MYSQL Master/Slave: Master (new example)-master (new instance, read-only)

Source: Internet
Author: User
MYSQL Master/Slave: Master (new instance)-master (new instance, read-only) 1. One machine installs two instances (3307 and 3308) According to babaoqi. iteye. build mysqld3308 using comadminblogs1954110 method II. Build dual master: 3307, 3308 (read-only) # disable two mysql services servicemysqld3307stop; servicemysqld3308stop

MYSQL Master/Slave: Master (new instance)-master (new instance, read-only) 1. install two instances on one machine (3307 and 3308) at http://babaoqi.iteye.com/admin/blogs/1954110 build mysqld3308 and set up dual masters: 3307, 3308 (read-only) # disable two mysql Services service mysqld3307 stop; service mysqld3308 stop

MYSQL Master/Slave: Master (new instance)-master (new instance, read-only)
1. install two instances on one machine (3307 and 3308)
Follow http://babaoqi.iteye.com/admin/blogs/1954110.pdf to build mysqld3308

2. Set up dual-MASTER: 3307, 3308 (read-only)

# Disable two mysql services
Service mysqld3307 stop; service mysqld3308 stop;

# Configure 3307 my. cnf
Vim/home/bbq/mysql/mysql-3307/cnf/my. cnf
Log-bin = mysql-bin
Binlog_format = mixed
Auto_increment_increment = 2
Auto_increment_offset = 1
# Run show slave hosts on the master database to display and use
Report_host = localhost # local address
Report_port = 3307 # current instance Port
Log_slave_updates
Servers-id = 3307

# Configure 3308 my. cnf
Vim/home/bbq/mysql/mysql-3308/cnf/my. cnf
Log-bin = mysql-bin
Binlog_format = mixed
Auto_increment_increment = 2
Auto_increment_offset = 2
Read_only
# Run show slave hosts on the master database to display and use
Report_host = localhost # local address
Report_port = 3308 # current instance Port
Log_slave_updates
Servers-id = 3308

# Start two mysql services
Service mysqld3307 start; service mysqld3308 start;

# Enter the root directory of the two instances
Cd/home/bbq/mysql

# Authorize a synchronization account
Mysql-3307/install/bin/mysql-uroot-ppwd-e "grant replication slave on *. * to 'repl' @ '%' identified by 'repl @ pwd'; flush privileges ;"
Mysql-3308/install/bin/mysql-uroot-ppwd-e "grant replication slave on *. * to 'repl' @ '%' identified by 'repl @ pwd'; flush privileges ;"

# Generate a new binlog
Mysql-3307/install/bin/mysql-uroot-ppwd-e "FLUSH binary logs ;"
Mysql-3308/install/bin/mysql-uroot-ppwd-e "FLUSH binary logs ;"

# Set the start position of synchronization. Run 'show MASTER status' on 3307 and 3308 respectively to record File and Position
# Change master to master_host = 'master database ip', master_port = master database port, master_user = 'synchronization account name', master_password = 'synchronization account password', master_log_file = 'master-file ', master_log_pos = master-Position;
# This example File = mysql-bin.000003, Position = 107
Mysql-3307/install/bin/mysql-uroot-ppwd-e "change master to master_host = 'localhost', master_port = 3308, master_user = 'repl ', master_password = 'repl @ pwd', master_log_file = 'mysql-bin.000003 ', master_log_pos = 107 ;"
Mysql-3308/install/bin/mysql-uroot-ppwd-e "change master to master_host = 'localhost', master_port = 3307, master_user = 'repl ', master_password = 'repl @ pwd', master_log_file = 'mysql-bin.000003 ', master_log_pos = 107 ;"

# View synchronization status
Mysql-3307/install/bin/mysql-uroot-ppwd-e "start slave; select sleep (1); show slave status \ G ;"
Mysql-3308/install/bin/mysql-uroot-ppwd-e "start slave; select sleep (1); show slave status \ G ;"
If both the SQL thread (Slave_IO_Running) and I/O thread (Slave_ SQL _Running) are displayed as YES, the setup is successful.

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.