In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "how to solve the actual MySQL replication problem", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to solve the actual MySQL replication problem" this article.
One of the most common operations of MySQL is to copy the database between the master server and the slave server. Although most of these connections are easy to establish and maintain, there are sometimes problems, such as some master data may not be replicated on the slave device or read requests may be routed to the master device rather than the server.
It's easy to have problems, but it takes some effort to find a solution to replication failure.
Replication is the most basic operation of all databases, mainly copying data from one database server (master server) to one or more other databases (slave server). This process improves performance by allowing load to be distributed among multiple secondary servers and improving performance by restricting the primary server to writes.
The benefits of replication include improved security through slave backups, analysis that can be performed from the slave database without affecting the performance of the master database, and extensive data distribution that can be done without accessing the master data.
Like many database administration operations, replication sometimes does not work as expected, and the "troubleshooting replication" in the MySQL reference manual prompts us to check what information in the error log should be checked when there is something wrong with replication. If the error log does not point to the solution, you can enable binary logging on the primary server by issuing a SHOW MASTER STATUS statement, if it is enabled, then "status" is not zero, if not, make sure the primary server is running-- the log-bin option.
In addition, the manual provides several other steps for troubleshooting replication:
Both master and slave servers must be started with the-- server-id option, and each server must have a unique ID value
Run SHOW SLAVE STATUS to ensure that both Slave_IO_Running and Slave_SQL_ running values are "yes"
Run SHOW_PROCESSLIST and look at the State column to verify that the slave station is connecting to the primary station
If a statement succeeds on the master server but fails on the slave server, the core option is to perform a full database resynchronization, which requires deleting the database from the slave server and replicating a new snapshot from the master server.
Solve the actual MySQL replication problem
When the MySQL master-slave connection is orderly, why is the data on the master device not copied to the slave device? Let's take the problem mentioned in the Stack Overflow post as an example to see how the actual MySQL replication problem should be solved.
The first step is to run "show master status" or "show master status\ G" on the master database to get the correct value of the slave station. According to the slave station status reflected in the figure above, the slave station is connected to the master station and waiting for log events. Synchronizing the correct log file location should be restored to replication from the server.
To ensure good synchronization, stop the master log file, dump the database, record the location of the master log file, restart the master log file, import the database into the slave mode, and start the slave mode with the correct location of the master log file.
Another Stack Overflow post published in March 2014 provides master / slave settings using the JDBC driver, where transactions marked as read-only are still on the ping master device. Because the MySQL JDBC driver is managing connections to physical servers (master and slave servers), the connection pool and the Spring transaction manager do not know whether the database connection is linked to multiple servers.
The solution is to return control to Spring and then commit the transaction on the connection. The transaction debug message indicates that as long as the connection is in read-only mode, the query will be routed to the slave server. By resetting the connection and clearing the read-only mode before the connection returns to the pool, the last log message shows that the query is now being routed to the primary server.
The above is all the contents of the article "how to solve the actual MySQL replication problem". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.