1. 程式人生 > >Redis 最大連線數查詢與設定、釋放超時連結

Redis 最大連線數查詢與設定、釋放超時連結

開發十年,就只剩下這套架構體系了! >>>   

連線數與最大連線數

檢視:

方法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