Redis禁用或重新命名危險命令
良好的配置能夠杜絕誤操作引發的Redis事故。
一: Redis線上不能使用危險的命令
1:keys *
雖然其模糊匹配功能使用非常方便也很強大,在小資料量情況下使用沒什麼問題,資料量大會導致 Redis 鎖住及 CPU 飆升,在生產環境建議禁用或者重新命名!
2:flushdb
刪除 Redis 中當前所在資料庫中的所有記錄,並且此命令從不會執行失敗
3:flushall
刪除 Redis 中所有資料庫中的所有記錄,不只是當前所在資料庫,並且此命令從不會執行失敗。
4:config
客戶端可修改 Redis 配置。
二:如何禁用或者重新命名危險命令
1:看下 redis.conf 預設配置檔案,找到 SECURITY 區域,如以下所示:
################################## SECURITY ###################################
# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
# Command renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possible to completely kill a command by renaming it into
# an empty string:
#
# rename-command CONFIG ""
#
# Please note that changing the name of commands that are logged into the
# AOF file or transmitted to slaves may cause problems.
2:禁用命令
rename-command KEYS ""
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command CONFIG ""
3:重新命名命令
rename-command KEYS "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
rename-command FLUSHALL "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
rename-command FLUSHDB "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
rename-command CONFIG "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
相關文章
- Linux的10個最危險命令Linux
- Linux的10個最危險的命令Linux
- 兒童安全定位手錶有漏洞:孩子或更危險?
- 一些極度危險的linux命令Linux
- 在Linux執行的10個最危險的命令Linux
- 運維危險操作之windows server開啟或關閉windows功能運維WindowsServer
- 使用已破解或危險的加密演算法導致的漏洞加密演算法
- php 的 危 險 參 數PHP
- Alex Maccaw:簡歷危險Mac
- Linux系統中10個最危險的命令詳解Linux
- 危險的 target=”_blank” 與 “opener”
- 危險的 target="_blank" 與 “opener”
- 棕櫚油挺危險的
- 9個“非常危險”的Linux命令,千萬不要隨意執行!Linux
- 谷歌為機器人學習加快步伐 機器人危險不危險?谷歌機器人
- Linux 下 10 個最“危險”的命令,運維必知必防!Linux運維
- 永遠不要在 Linux 執行的 10 個最危險的命令Linux
- 永遠不要在Linux執行的10個最危險的命令Linux
- 危險就是一封郵件
- php常見的危險函式PHP函式
- (十九)冒險和預測,解決危險就能抓住機會
- 使用WiFi真的有那麼危險嗎?WiFi
- Android 中的危險許可權Android
- 13 種危險的網路攻擊
- 深入SQLite,一網打盡“危險操作”SQLite
- IIHS:美國最危險車型TOP 10
- 最危險的程式設計錯誤程式設計
- Nimb智慧戒指:能自動報警或發求救訊號讓你遠離危險
- 危險!水很深,讓叔來 —— 談談命令查詢權責分離模式(CQRS)模式
- 七類最危險的網路管理員
- Mac OS X 驚現最危險木馬Mac
- Java開發中常見的危險訊號Java
- 軟體開發中最危險的詞語
- 微軟SQLServer密碼管理的危險判斷微軟SQLServer密碼
- 目錄檔案有寫許可權 危險
- canvas旋轉核輻射危險警告標誌Canvas
- 危險字元過濾的類(最新完善版)(1)字元
- 微軟SQLServer密碼管理六個危險判斷微軟SQLServer密碼