In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to copy the master in MySQL, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Master replication of MySQL replication Technology
1) initialize the database (master1,master2)
Master1:vm1:192.168.12.181 、 mysqld2
Master2:vm2:192.168.12.182 、 mysqld2
2) configure my.cnf
Master1:
[mysqld2]
Port=3307
Basedir=/usr
Datadir=/data/mysql/data2
Socket=/var/lib/mysql/mysql2.sock
Pid-file=/var/run/mysqld/mysqld2.pid
Log-error=/data/mysql/log2/mysqld2.log
User=mysql
Server_id=5
Log_bin=/data/mysql/log2/vm2-bin.log
Relay-log=/data/mysql/log2/vm2-slave-bin.log
Master2:
[mysqld2]
Port=3307
Basedir=/usr
Datadir=/data/mysql/data2
Socket=/var/lib/mysql/mysql2.sock
Pid-file=/var/run/mysqld/mysqld2.pid
Log-error=/data/mysql/log2/mysqld2.log
User=mysql
Server_id=6
Log_bin=/data/mysql/log2/vm2-bin.log
Relay-log=/data/mysql/log2/vm2-slave-bin.log
Log_slave_updates=on
# slave-skip-errors=all
Start mysql
Common parameters:
Binlog-do-db=db_rocky # requires a database that records binary logs. If there are multiple databases that can be separated by commas, or if you use multiple binlog-do-db options
Binlog-ignore-db=mysql # does not need a database that records binary logs. If there are multiple databases that can be separated by commas, or if you use multiple binlog-do-db options
Replicate-do-db=db_rocky # databases that need to be synchronized. If there are multiple databases that can be separated by commas, or if you use multiple replicate-do-db options
Replicate-ignore-db=mysql,information_schema # databases that do not require synchronization. If there are multiple databases that can be separated by commas, or if you use multiple replicate-ignore-db options
# synchronization parameters:
# make sure that slave hangs on any master and will receive the write message from another master
Log_bin=/data/mysql/log2/vm2-bin.log
Relay-log=/data/mysql/log2/vm2-slave-bin.log
Log_slave_updates=on
Slave-skip-errors=all # filters out some errors that are not a big deal
3) create a synchronization user
Master1:
Mysql > grant replication slave on *. * to repuser1 identified by 'aa12AA,.'
Master2:
Mysql > grant replication slave on *. * to repuser2 identified by 'aa12AA,.'
4) Connect master1 and master2
Master1:
Mysql > change master to
Master_host = '192.168.12.182'
Master_port = 3307
Master_user = 'repuser2'
Master_password = 'aa12AA,.'
(master_log_file = 'vm2-bin.000009', master_log_pos = 1;)
Mysql > start slave
Master2:
Mysql > change master to
Master_host = '192.168.12.181'
Master_port = 3307
Master_user = 'repuser1'
Master_password = 'aa12AA,.'
(master_log_file = 'vm2-bin.000009', master_log_pos = 1;)
Mysql > start slave
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.