In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Description
Redis cluster sometimes need to delete multiple keys, you must log in to each node, and it is possible that this key is not in this node, so it is more troublesome to delete, the following provides a convenient way to achieve
2. View the master node in the redis cluster
First, you need to confirm which master nodes there are. You can check them with the following command:
#./ redis-cli cluster nodes | grep master
PS: Here I have 3 master nodes, all port 6379
3. Write redis_del.sh script
#!/ bin/bash
redis_comm=/usr/local/redis/bin/redis-cli
redis_ser01=172.18.18.107
redis_ser02=172.18.18.108
redis_ser03=172.18.18.109
$redis_comm -c -h $redis_ser01 keys $1 | xargs -i ./ redis-cli -h $redis_ser01 del {}
$redis_comm -c -h $redis_ser02 keys $1 | xargs -i ./ redis-cli -h $redis_ser02 del {}
$redis_comm -c -h $redis_ser03 keys $1 | xargs -i ./ redis-cli -h $redis_ser03 del {}
Parameter Description:
-c: Start cluster mode and enter redis cluster service
-h: redis host address
xargs -i: The-i option tells xargs that {} can be used instead of the passed parameter
Use redis_del.sh script
For example, we now have a requirement to delete all keys that start with UP in the redis cluster.
First, let's log in to the redis cluster and see:
Then, use the redis_del.sh script to remove:
# ./ redis_del.sh UP*
PS: As shown above, all keys at the beginning of UP have been deleted.
Script Usage: sh redis_del.sh key parameter
For example, you want to delete other key values:
./ redis_del.sh a* #Remove key values starting with a
./ redis_del.sh b* #Remove key values starting with b
Or, delete the keys value ending with:
./ redis_del.sh *ab #Remove key values ending in ab
./ redis_del.sh *123 #Remove key values ending in 123
...... wait
Well, feel useful friends can forward or collection, everyone has questions can be discussed in the following message, there are better suggestions can also be posted in the comment area!!!
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.