Think about how online queries can be updated without affecting

Source: Internet
Author: User

The following situations are currently encountered:

 

1. Database Online DDL (modifying table structure and fields)

You can also use the duplicate name. Copy a table, including the data in it. Assume the name is TMP. Execute the dll statement on the tmp table. At this time, you need to record the SQL statements that start updating the database at a certain time point and cache them.

The DLL operation is completed. Run the previously cached SQL statement in this TMP table.

 

Ii. Rebuild the index with sphinx. In this case, shpinx cannot be switched off and the query service can be properly performed.

The method of using a duplicate name is used. Store the latest index results in a file such as. New. The original file is assumed to be the master, so we need to replace the master with. New because the index is updated.

 

How can we ensure that the replacement operation does not affect the Sphinx index query on the client. It is impossible to turn off the Sphinx service.

Send sighup to searchd. Wait until the sub-process exits.

Master> Rename to> old

Rename the new file to the master to be used by the in-use sphinx query.

Then let the sphworker process load the replaced file. If the load is successful. It is normal. If loading fails, roll back:

Searchd will roll back the. Old file to the current file and rename the newly created index to. New

 

 

Iii. When synchronizing data between redis master and slave nodes, the master server has an update operation. What to do.

Now we can see that redis first caches the updated command for this situation. Then synchronize these commands to the slave server for execution.

Specifically: During synchronization, the data in the current memory database is saved as a snapshot on the disk to send the data in this file to the slave server. Load the data from the server to the memory. In the process of Synchronizing files.

The primary server can still perform query and update (write) operations on the client. Execute the update operation to cache These update commands. After the database snapshot is synchronized, these commands are sent to the slave server for execution.

Which of the following update operations are performed by the master server. Of course, it is correct to perform the update operation on the basis of the previous database snapshot.

 

The final result is that the slave server is a snapshot of the redis data of the master server. Run the command again.

Think about how online queries can be updated without affecting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.