解决redis连接数,最大连接数和NOAUTH Authentication问题

连接数与最大连接数

1、Redis (error) NOAUTH Authentication required.解决方法

127.0.0.1:6379> auth "yourpassword"

修改redis参数时:

> redis-cli

> auth "password"

2、连接redis数据库时突然报错:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

究其原因是因为强制把redis快照关闭了导致不能持久化的问题,在网上查了一些相关解决方案,

通过stop-writes-on-bgsave-error值设置为no即可避免这种问题。

有两种修改方法,一种是通过redis命令行修改,另一种是直接修改redis.conf配置文件

命令行修改方式示例:

127.0.0.1:6379> config set stop-writes-on-bgsave-error no

查看:

方法1:在redis-cli命令行使用:info clients可以查看当前的redis连接数

127.0.0.1:6379> info clients
#Clients
connected_clients:621
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
127.0.0.1:6379>

方法2:config get maxclients 可以查询redis允许的最大连接数

127.0.0.1:6379> CONFIG GET maxclients
    ##1) "maxclients"
    ##2) "10000"
127.0.0.1:6379>

设置:

1. 在2.6之后版本,可以修改最大连接数配置,默认10000,可以在redis.conf配置文件中修改

...
# maxclients 10000
...

2.config set maxclients num 可以设置redis允许的最大连接数

127.0.0.1:6379> CONFIG set maxclients 10
OK
127.0.0.1:6379>


3.启动redis.service服务时加参数--maxclients 100000来设置最大连接数限制

redis-server --maxclients 100000 -f /etc/redis.conf

获取客户端信息命令

CLIENT LIST 获取客户端列表

CLIENT SETNAME 设置当前连接点redis的名称

CLIENT GETNAME 查看当前连接的名称

CLIENT KILL ip:port 杀死指定连接

CLIENT LIST
    ##id=3 addr=127.0.0.1:36588 fd=5 name= age=7 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
CLIENT SETNAME js
    ##OK
CLIENT LIST
    ##id=3 addr=127.0.0.1:36588 fd=5 name=js age=37 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
CLIENT GETNAME
    ##"js"
CLIENT KILL id 3
    ##(integer) 0

释放超时链接配置

查看超时配置
config get timeout

设置超时配置
config set timeout 600
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章