Installation process operation of mysql master-slave replication
This article mainly explains "the installation process operation of mysql master-slave replication". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "mysql master-slave replication installation process operation" it!
Mysql master-slave replication
One master and one slave
1. A brief introduction to the steps of creating two instances, master and slave
two。 Enter the slave library slave and execute the following instructions
# template
CHANGE MASTER TO MASTER_HOST='localhost',MASTER_USER='user',MASTER_PASSWORD='passwd',MASTER_PORT=port,MASTER_AUTO_POSITION=0
# modified sample
CHANGE MASTER TO MASTER_HOST='192.168.180.128',MASTER_USER='replic',MASTER_PASSWORD='oracle',MASTER_PORT=55293,MASTER_AUTO_POSITION=0
Start the slave library
The Start slave picture is as follows
Second, one master and two slaves, use mysql logical backup (dump) (create an empty instance slave1 steps briefly)
Enter the main library master under pressurized environment
Sysbench-threads=10-tables=10-table-size=100000-rand-type=uniform-report-interval=1-time=10-mysql-user=root-mysql-password=oracle-mysql-socket=/mysqldb/db_master1/mysql.sock / usr/share/sysbench/oltp_read_write.lua prepare
Sysbench-threads=10-tables=10-table-size=100000-rand-type=uniform-report-interval=1-time=1000-mysql-user=root-mysql-password=oracle-mysql-socket=/mysqldb/db_master1/mysql.sock / usr/share/sysbench/oltp_read_write.lua run
two。 Backup
Mysqldump-uroot-poracle-S / mysqldb/db_master/mysql.sock-- master-data=2-- single-transaction-- all-database-- set-gtid-purged=OFF-- compact > test.dump
3. Restore
Enter the slave library source test.dump
4. View backup points for binlog
Vi test.dump finds backup point xx writes to MASTER_LOG_POS=xx
5. Master and subordinate are consistent
Enter the new slave library slave1
CHANGE MASTER TO
MASTER_HOST='192.168.180.128'
MASTER_USER='replic'
MASTER_PASSWORD='oracle'
MASTER_PORT=55293
MASTER_LOG_FILE='master1-bin.000004'
MASTER_LOG_POS=194
MASTER_CONNECT_RETRY=10
Start slave in the new slave library slave1
Start slave
Enter the view state from the library
Show slave status\ G
Enter the main library master
Show slave hosts
The above situation and success.
III. Solutions
Encounter the following circumstances
Stop slave # stop slave slave library
Reset slave all # reset slave settings
Make a master-slave connection
CHANGE MASTER TO
MASTER_HOST='192.168.180.128'
MASTER_USER='replic'
MASTER_PASSWORD='oracle'
MASTER_PORT=55293
MASTER_LOG_FILE='master1-bin.000004'
MASTER_LOG_POS=194
MASTER_CONNECT_RETRY=10
Start slave # starts the slave slave library
Show slave status\ G
At this point, I believe that everyone on the "mysql master-slave replication installation process operation" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!