Understanding: the built-in replication function of Mysql is the basis for building large and high-performance applications.
Understanding: the built-in replication function of Mysql is the basis for building large and high-performance applications.
Understanding:
The built-in replication function of Mysql is the basis for building large and high-performance applications. This distribution mechanism replicates data from a Mysql host to another Server Load balancer instance, and execute it again. During the replication process, one server acts as the master server, and one or more other servers act as slave servers. The master server writes updates to the binary log file and maintains an index of the file to track log loops. These logs can record updates sent to the slave server. When a slave server connects to the master server, it notifies the master server of the last successful update location read from the server in the log. The slave server receives any updates from that time, blocks them, and waits for the master server to notify you of new updates.
The master server writes all commands to the binary log. The slave server copies the binary log from the master server to the relay log. After the command is executed, the system copies the log.
Method 1:
1. master Server Configuration:
1. Stop the service: 2. modify the configuration file:
3. Create a directory and modify a group:
4. Start the service and Port:
5. Authorized Users
Ii. slave server configuration: 1. Stop the service:
2. modify the configuration file:
3. Create a directory and modify a group:
4. Start the service:
5. Connect to mysql to view the relay log status:
6. view the verification (there is no file at this time ):
7. Set connection to the master server:
3. view the status of the master and slave nodes and start the slave node: 1. view the number of master processes:
2. view the operation log status on the master node:
3. Check the synchronization status of the slave node:
4. Start the synchronous connection service:
5. view the verification file on the slave node:
6. Check the synchronization status of the slave node:
4. Verify synchronization from 0: 1. Create a database on the master node: 2. view the created database on the master node:
3. view the operation log status on the master node:
4. view the synchronization status on slave:
5. Run the slave command to check whether synchronization is performed:
6. Create a table on the master node and insert data into the table:
7. view the operation log status on the master node:
8. view the synchronization status on slave:
9. view the synchronized table:
9. Stop using
10. Now I stopped the mysqld service, and then I want to enable the mysqld service. Do you say this will cause an error?
11. Can you start it directly at this time? An error will be reported at this time. Please refer:
12. At this time, mysql will automatically start the service when you stop the service and connect again. See: 12.1 stop the Connection Service:
12.2 stop the service before starting:
12.3 view synchronization status:
Method 2:
I. Requirements:
1. the demo starts copying from half the time, instead of starting from 0: 2. To demonstrate the effect, let the server directly import the prepared database, then let the slave server do not start copying from 0, this will be very slow, we back up from the master to restore from half, see how to operate? 3. In order to demonstrate the effect, we deleted the data we just made,
Ii. master and slave configurations: 1. Delete and stop the Server Load balancer (it cannot be modified as a matter of fact ):
2. Delete the master:
3. import data from the master:
4. view the operation log status (a lot of information is generated now)
4.1 What should I do if I cannot copy the slave server from 0? Lock location. copy from the lock location:
Iii. Backup and synchronization of data: 1. create databases, tables, and insert data on the master node:
2. Back up data from the master:
3. master Data replication on slave:
4. confirm that the transmission is stopped:
5. slave import data and connect to mysql:
5.1 View:
5.2 slave authorization:
5.3 Start the transmission service
5.4 check whether synchronization is Enabled:
6. master Test Data creation:
6.1 view operation logs:
7. Check whether the synchronization is complete and check the synchronization status:
7.1 check whether the testdb database is synchronized:
OK !!!