国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數(shù)據(jù)庫技術(shù)|

服務(wù)器之家 - 數(shù)據(jù)庫 - Redis - 詳解如何清理redis集群的所有數(shù)據(jù)

詳解如何清理redis集群的所有數(shù)據(jù)

2021-07-26 16:35前路無畏 Redis

這篇文章主要介紹了詳解如何清理redis集群的所有數(shù)據(jù),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

1. 背景:生產(chǎn)測試后redis中產(chǎn)生大量數(shù)據(jù)

 

生產(chǎn)前需要清理reids集群中的數(shù)據(jù)。、
你看有很多key呢:

使用工具

詳解如何清理redis集群的所有數(shù)據(jù)

使用命令,查看是否有數(shù)據(jù):

?
1
keys *

詳解如何清理redis集群的所有數(shù)據(jù)

2. 清理步驟

 

2.1 任意登錄一臺redis機(jī)器

執(zhí)行下面腳本:

?
1
clear_redis_cluster.sh 10.1.33.101:8001 redis

詳解如何清理redis集群的所有數(shù)據(jù)

執(zhí)行日志如下:

詳解如何清理redis集群的所有數(shù)據(jù)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
clearing 10.1.33.112:8028 ...
background append only file rewriting started
readonly you can't write against a read only replica.
clearing 10.1.33.110:8026 ...
background append only file rewriting started
readonly you can't write against a read only replica.
clearing 10.1.33.111:8027 ...
background append only file rewriting started
readonly you can't write against a read only replica.
clearing 10.1.33.107:8007 ...
background append only file rewriting started
ok
clearing 10.1.33.108:8024 ...
background append only file rewriting started
readonly you can't write against a read only replica.
clearing 10.1.33.104:8020 ...
background append only file rewriting started
readonly you can't write against a read only replica.
clearing 10.1.33.114:8014 ...
background append only file rewriting started
ok
clearing 10.1.33.109:8025 ...
background append only file rewriting started
readonly you can't write against a read only replica.
clearing 10.1.33.105:8005 ...
background append only file rewriting started
ok
clearing 10.1.33.108:8008 ...
background append only file rewriting started
ok

2.2 clear_redis_cluster.sh內(nèi)容

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# writed by yijian on 2018/8/20
# batch to clear all nodes using flushall command
# 用來清空一個redis集群中的所有數(shù)據(jù),要求 flushall 命令可用,
# 如果在 redis.conf 中使用 rename 改名了 flushall,則不能執(zhí)行本腳本。
# 可帶兩個參數(shù):
# 1)參數(shù)1 集群中的任一可用節(jié)點(diǎn)(必須)
# 2)連接redis的密碼(設(shè)置了密碼才需要)
redis_cli=${redis_cli:-redis-cli}
redis_ip=${redis_ip:-127.0.0.1}
redis_port=${redis_port:-6379}
 
# 顯示用法函數(shù)
function usage()
{
  echo "usage: clear_redis_cluster.sh a_redis_node_of_cluster redis_password"
  echo "example1: clear_redis_cluster.sh '127.0.0.1:6379'"
  echo "example2: clear_redis_cluster.sh '127.0.0.1:6379' '123456'"
}
 
# 檢查參數(shù)個數(shù)
if test $# -lt 1 -o $# -gt 2; then
  usage
  exit 1
fi
 
# 第一個參數(shù)為集群中的節(jié)點(diǎn),
redis_node="$1"
# 第二個參數(shù)為密碼
redis_password=""
if test $# -ge 2; then
  redis_password="$2"
fi
 
# 取得ip和端口
eval $(echo "$redis_node" | awk -f[\:] '{ printf("redis_ip=%s\nredis_port=%s\n",$1,$2) }')
if test -z "$redis_ip" -o -z "$redis_port"; then
  echo "parameter error: \`$redis_node\`."
  usage
  exit 1
fi
 
# 確保redis-cli可用
echo "checking \`redis-cli\` ..."
which "$redis_cli" > /dev/null 2>&1
if test $? -ne 0; then
  echo "command \`redis-cli\` is not exists or not executable."
  echo "you can set environment variable \`redis_cli\` to point to the redis-cli."
  echo "example: export redis_cli=/usr/local/bin/redis-cli"
  exit 1
fi
 
if test -z "$redis_password"; then
  redis_nodes=`redis-cli -h $redis_ip -p $redis_port cluster nodes | awk -f[\ \:\@] '!/err/{ printf("%s:%s\n",$2,$3); }'`
else
  redis_nodes=`redis-cli --no-auth-warning -a "$redis_password" -h $redis_ip -p $redis_port cluster nodes | awk -f[\ \:\@] '!/err/{ printf("%s:%s\n",$2,$3); }'`
fi
if test -z "$redis_nodes"; then
  # standlone(非集群)
  if test -z "$redis_password"; then
    $redis_cli -h $redis_ip -p $redis_port flushall async
    $redis_cli -h $redis_ip -p $redis_port bgrewriteaof
  else
    $redis_cli --no-auth-warning -a "$redis_password" -h $redis_ip -p $redis_port flushall async
    $redis_cli --no-auth-warning -a "$redis_password" -h $redis_ip -p $redis_port bgrewriteaof
  fi
else
  # cluster(集群)
  for redis_node in $redis_nodes;
  do
    if test ! -z "$redis_node"; then
      eval $(echo "$redis_node" | awk -f[\:] '{ printf("redis_node_ip=%s\nredis_node_port=%s\n",$1,$2) }')
 
      if test ! -z "$redis_node_ip" -a ! -z "$redis_node_port"; then
        # clear
        echo -e "clearing \033[1;33m${redis_node_ip}:${redis_node_port}\033[m ..."
        if test -z "$redis_password"; then
          result=`$redis_cli -h $redis_node_ip -p $redis_node_port flushall async`
          $redis_cli -h $redis_node_ip -p $redis_node_port bgrewriteaof
        else
          result=`$redis_cli --no-auth-warning -a "$redis_password" -h $redis_node_ip -p $redis_node_port flushall async`
          $redis_cli --no-auth-warning -a "$redis_password" -h $redis_node_ip -p $redis_node_port bgrewriteaof
        fi
 
        if test ! -z "$result"; then
          # success
          if test "$result" = "ok"; then
            echo -e "\033[0;32;32m$result\033[m"
          else
            echo -e "\033[0;32;31m$result\033[m"
          fi
        fi
      fi
    fi
  done
fi

這位仁兄的腳本寫的特別好。直接執(zhí)行即可。

2.3 確認(rèn)刪除成功

使用redis工具查看:

詳解如何清理redis集群的所有數(shù)據(jù)

3.清理單機(jī)redis

 

?
1
flushall

4.總結(jié)

 

使用腳本刪除redis集群中的數(shù)據(jù)。
記得地址哦:https://github.com/eyjian/redis-tools/blob/master/clear_redis_cluster.sh

到此這篇關(guān)于詳解如何清理redis集群的所有數(shù)據(jù)的文章就介紹到這了,更多相關(guān)清理redis集群數(shù)據(jù)內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://blog.csdn.net/fsjwin/article/details/111300274

延伸 · 閱讀

精彩推薦
  • RedisRedis如何實(shí)現(xiàn)數(shù)據(jù)庫讀寫分離詳解

    Redis如何實(shí)現(xiàn)數(shù)據(jù)庫讀寫分離詳解

    Redis的主從架構(gòu),能幫助我們實(shí)現(xiàn)讀多,寫少的情況,下面這篇文章主要給大家介紹了關(guān)于Redis如何實(shí)現(xiàn)數(shù)據(jù)庫讀寫分離的相關(guān)資料,文中通過示例代碼介紹...

    羅兵漂流記6092019-11-11
  • Redisredis 交集、并集、差集的具體使用

    redis 交集、并集、差集的具體使用

    這篇文章主要介紹了redis 交集、并集、差集的具體使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友...

    xiaojin21cen10152021-07-27
  • Redisredis中如何使用lua腳本讓你的靈活性提高5個逼格詳解

    redis中如何使用lua腳本讓你的靈活性提高5個逼格詳解

    這篇文章主要給大家介紹了關(guān)于redis中如何使用lua腳本讓你的靈活性提高5個逼格的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具...

    一線碼農(nóng)5812019-11-18
  • RedisRedis 事務(wù)知識點(diǎn)相關(guān)總結(jié)

    Redis 事務(wù)知識點(diǎn)相關(guān)總結(jié)

    這篇文章主要介紹了Redis 事務(wù)相關(guān)總結(jié),幫助大家更好的理解和學(xué)習(xí)使用Redis,感興趣的朋友可以了解下...

    AsiaYe8232021-07-28
  • RedisRedis全量復(fù)制與部分復(fù)制示例詳解

    Redis全量復(fù)制與部分復(fù)制示例詳解

    這篇文章主要給大家介紹了關(guān)于Redis全量復(fù)制與部分復(fù)制的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Redis爬蟲具有一定的參考學(xué)習(xí)...

    豆子先生5052019-11-27
  • Redis詳解Redis復(fù)制原理

    詳解Redis復(fù)制原理

    與大多數(shù)db一樣,Redis也提供了復(fù)制機(jī)制,以滿足故障恢復(fù)和負(fù)載均衡等需求。復(fù)制也是Redis高可用的基礎(chǔ),哨兵和集群都是建立在復(fù)制基礎(chǔ)上實(shí)現(xiàn)高可用的...

    李留廣10222021-08-09
  • Redisredis實(shí)現(xiàn)排行榜功能

    redis實(shí)現(xiàn)排行榜功能

    排行榜在很多地方都能使用到,redis的zset可以很方便地用來實(shí)現(xiàn)排行榜功能,本文就來簡單的介紹一下如何使用,具有一定的參考價值,感興趣的小伙伴們...

    乘月歸5022021-08-05
  • RedisRedis的配置、啟動、操作和關(guān)閉方法

    Redis的配置、啟動、操作和關(guān)閉方法

    今天小編就為大家分享一篇Redis的配置、啟動、操作和關(guān)閉方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧 ...

    大道化簡5312019-11-14
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 黄色毛片免费视频 | 日韩午夜 | 日韩欧美视频 | 久久精品一区二区国产 | 久久狠狠 | 日韩欧美三区 | 天堂网av在线 | 韩国精品一区二区三区 | 亚洲视频精品在线 | 亚洲视频一区在线观看 | av一级毛片 | 视频精品一区二区 | 激情久久免费视频 | 欧美精品黄色 | 日本视频在线 | 成人黄色网 | 人人叉人人 | 精品久久久久久久 | 亚洲 自拍 另类 欧美 丝袜 | www.久久 | 91免费视频观看 | 欧美在线1 | 精品av | 色天天综合 | 国产视频二区 | 亚洲国产激情 | 美女视频一区二区三区 | av在线成人 | 久久只有精品 | 久久久久综合视频 | 亚洲电影在线播放 | 国产精品国产 | 精品天堂 | 日本中文字幕在线观看 | 久久黄网| 成人精品视频 | 超碰在线免费福利 | 欧美日韩在线视频观看 | 国产一区二区三区在线 | 成年人免费看片 | 国产片免费 |