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
MySQL reports an error when executing multi-table...
Table of contents 1. Use slots to make components...
Using the Vue language and element components, we...
1 Introduction PostgreSQL is a free software obje...
Glass Windows What we are going to achieve today ...
view: Views in MySQL have many similarities with ...
MySQL database crashes after entering password an...
Installation path: /application/mysql-5.5.56 1. P...
Table of contents 1. Concept 1.1 What are errors ...
Insert Baidu Map into the web page If you want to...
Discuz! Forum has many configuration options in th...
Table of contents Presentation Layer Business Lay...
In CSS, text is one of the most common things we ...
I don't know if it's because the binary d...
Table of contents 1. What is the use of provide/i...