簡體   English   中英

redis 上的 FLUSHALL 和 FLUSHDB 命令返回“unk command”

[英]FLUSHALL and FLUSHDB commands on redis return "unk command"

要刷新 redis,將使用FLUSHALL命令。

使用 Redis 2.6.16,當我在使用 redis-cli 時同時嘗試FLUSHALLFLUSHDB命令時,出現unknown command錯誤。 其他命令工作正常。

a) FLUSH*命令出了什么問題?

b) 解決方法是關閉 Redis,然后刪除 rdb 文件嗎? (我相信是這樣)

更新:

不,我們從未解決過這個問題。

(唯一已知的解決方案是使用上面的步驟“b”)

可能是您的 Redis 配置重命名了一些命令,以防止您的數據庫被意外刪除。

在 redis.conf 中查找以下行:

rename-command FLUSHDB ""
rename-command FLUSHALL ""

Redis 官方 Helm 圖表默認禁用FLUSHDBFLUSHALL命令。 在這種情況下,它沒有在容器內的任何redis.conf中指定,因此您需要在您的 Redis YAML 中指定它:

master:
  disableCommands: []

我正在使用 Helm 並且不想通過重新安裝它來 go ,所以我通過修改 Helm 生成的包含配置的配置映射來解決這個問題。

CONFIGMAP=<<value of common.names.fullname>>-configuration
kubectl edit cm $CONFIGMAP

你應該看到類似的東西:

  master.conf: |-
    dir /data
    # User-supplied master configuration:
    rename-command FLUSHDB ""
    rename-command FLUSHALL ""
    # End of master configuration
  redis.conf: |-
    # User-supplied common configuration:
    # Enable AOF https://redis.io/topics/persistence#append-only-file
    appendonly yes
    # Disable RDB persistence, AOF persistence already enabled.
    save ""
    # End of common configuration
  replica.conf: |-
    dir /data
    slave-read-only yes
    # User-supplied replica configuration:
    rename-command FLUSHDB ""
    rename-command FLUSHALL ""
    # End of replica configuration

刪除以rename-command開頭的行,使其看起來更像這樣:

  master.conf: |-
    dir /data
    # User-supplied master configuration:
    # End of master configuration
  redis.conf: |-
    # User-supplied common configuration:
    # Enable AOF https://redis.io/topics/persistence#append-only-file
    appendonly yes
    # Disable RDB persistence, AOF persistence already enabled.
    save ""
    # End of common configuration
  replica.conf: |-
    dir /data
    slave-read-only yes
    # User-supplied replica configuration:
    # End of replica configuration

重啟 redis pod

kubectl delete pods $(kubectl get pods | grep redis | awk {'print $1'})

現在執行到 master pod 並刷新所有

kubectl exec redis-master-0 -- redis-cli FLUSHALL
OK

請注意,如果您想再次使用 FLUSHALL 或 FLUSHDB,如果您重新安裝 Helm 版本,則必須再次執行此操作。

更新:雖然這有效,但當您 go 重新安裝 helm 版本時,pods 將 go 進入 crashloopbackoff,因為它們會在歷史記錄中看到您運行的命令不存在,因此您必須再次通過此 go 來獲取 pods跑步。 在這種情況下,@camilo-sampedro 的回答可能最好是 go。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM