Redis--安全策略

  可信环境下的可信用户才可访问redis。这意味着,将redis服务器直接暴露在Internet或者不可信用户可直接访问Redis的tcp端口或Unix套接字的环境,是不安全的。redis着重于高性能和简单易用,在安全方面做得并不好。

网络安全

bind参数(在redis.conf配置文件,添加bind可以让数据库只能在指定IP下访问)。
bind 127.0.0.1 [192.168.3.1 ……]
注意:bind后面指定的ip只能是本机的ip。

认证

设置数据库密码

  1. 修改配置requirepass password
  2. 验证密码auth password
  • 实例 : 修改密码为xiaoxiaomo
    1
    2
    3
    4
    #requirepass foobared
    requirepass xiaoxiaomo

    # Command renaming.

命令重命名

修改命令的名称 : rename-command flushall cleanall
禁用命令 : rename-command flushall “”

调试命令

monitor,可以监控当前操作

1
2
3
4
5
6
7
8
9
10
11
[root@momo2 momo2]# redis-cli
127.0.0.1:6379> monitor
OK
1461856075.682226 [0 192.168.33.88:6379] "PING"
1461856085.788001 [0 192.168.33.88:6379] "PING"
1461856086.421633 [0 192.168.33.88:6379] "set" "b" "123"
1461856095.887983 [0 192.168.33.88:6379] "PING"
1461856105.986328 [0 192.168.33.88:6379] "PING"
1461856106.884941 [0 192.168.33.88:6379] "set" "d" "999"
1461856116.086099 [0 192.168.33.88:6379] "PING"
1461856126.187827 [0 192.168.33.88:6379] "PING"

当前网速较慢或者你使用的浏览器不支持博客特定功能,请尝试刷新或换用Chrome、Firefox等现代浏览器