mysql master-slave configuration 1. Preparation
Configuring the Host 2. Authorize the slave server GRANT REPLICATION SLAVE ON *.* to 'rep1'@'192.168.244.130' identified by 'root@bisnow'; FLUSH PRIVILEGES; Here it means that the slave login username is configured as rep1, the password is 123, and it must be logged in from the address 192.168.248.139. After a successful login, you can operate any table in any database. If you do not need to restrict the login address, you can change the IP address to a %. 3. Modify the main library configuration file vi /etc/my.cnf [mysqld] log-bin=/var/lib/mysql/binlog server-id=130 binlog-do-db = cmdb server-id: ID number of the master; log-bin: Synchronized log path and file name. Be sure to note that this directory must be written by MySQL (I was lazy here and put it directly under the datadir below); binlog-do-db: the name of the database to be synchronized 4. Restart the MySQL service after configuration is complete systemctl restart mysqld.service 5. Check the current binary log name and offset of the master server. The purpose of this operation is to recover data from this point after starting the slave database. mysql> show master status; Configuring the Slave 6. Add the following configuration in /etc/my.cnf server-id=131 Note: If the slave is copied from the master, the uuids of the two mysqls are the same and need to be modified manually. The modification location is in the auto.cnf file in the data directory. 7. Use commands to configure the slave: change master to master_host='192.168.244.128',master_port=3306,master_user='rep1',master_password='root@bisnow',master_log_file='binlog.000002',master_log_pos=120; 8. Start the slave process 9. Check the slave status. If the following two values are YES, the configuration is correct:
At this point, the configuration is complete. The host creates a library, adds data, and the slaves are automatically synchronized. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: WeChat applet learning notes: page configuration and routing
>>: Linux CentOS 6.5 Uninstall, tar and install MySQL tutorial
Result: Implementation code: html <div class=&...
tcpdump is a flexible and powerful packet capture...
I divide the whole process into four steps: Downl...
Sometimes we may need to run some commands on a r...
Before introducing the new CSS property contain, ...
Preface The master-slave replication relationship...
This article shares the installation and configur...
The image of the microservice will be uploaded to...
This article example shares the specific code of ...
Preface Reduce is one of the new conventional arr...
Introduction to XHTML tags <br />Perhaps you...
Table of contents webpack5 Official Start Buildin...
"Development is more than just writing code&q...
By chance, I discovered that a SQL statement prod...
When developing a backend management project, it ...