当前位置:网站首页>Redis migration (recommended operation process) 1

Redis migration (recommended operation process) 1

2022-06-26 16:06:00 franket

Except for the following two , Other configurations are the same

router_id: Different nodes are different

priority:master Above slave

modify iptables

Add the following configuration to b and c Of filter surface , then reload

-A INPUT -d 224.0.0.18 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT

Note: Finished loading iptables To configure , It is best to perform an access test on another machine , Avoid network problems

b Synchronize to a

Select the low peak operation

SLAVEOF a 6379

You can use the following command to observe the synchronization status master_sync_in_progress

info replication

Note: b After the synchronization of , Use the same method to make c Sync b

close slave read-only

stay b Up close slave read-only

Tip: This setting was intended for security , Avoid being right slave Data inconsistency caused by write operation of , But for smooth switching , A little safety consideration in this area needs to be sacrificed , If this setting is not turned on , Some write errors will occur

CONFIG SET slave-read-only no

Switch keepalived, Publish to new VIP

1. Switch keepalived, hold ip Switch to b ( You can adjust the priority , then reload)

2. Then publish the application to the new VIP( Modify the configuration , New VIP As a pair of redis The interview of IP)

Note: If the first step 2 , The next steps 1 , For some time, this was due to arp The reason for caching , At the same time a and b Read and write , If the data read / write is well divided at the application level , In a short time , It won't cause too much problems (a b Data inconsistency ), But not for a long time , The most radical solution , Or new VIP Republish it again

Disconnect synchronization

Observe for a while , Pay attention to the following aspects

1.a Upper redis Number of network connections ( The number of connections is reduced to 0)

2.b Upper redis Number of network connections ( The number of connections gradually stabilized )

3. Log and error reporting ( There is no error message that deserves special attention )

stay b Use the following command to disconnect from a Synchronization of

slaveof no one

At this point, the switch is completed ,b Has become c Of master

Tip: You may consider reintroducing a As b Of slave, And it turns out a Of slave You can also consider recycling ( The data is old and useless ), Be careful keepalived Priority of the instance , Avoid drifting back

Original address

原网站

版权声明
本文为[franket]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261551547470.html