redis查看最大連接數及其他參數

場景

集羣項目總是報連接超時,想看下到底是有多少連接。

過程

連接並查看參數

客戶端可以看redis參數麼,肯定是可以的,命令:

/usr/bin/redis -a ***password  # 連接redis

查看參數:

info # 查看所有信息
info clients # 查看連接數等客戶端信息,可用值有server,memory等

info命令報錯:NOAUTH Authentication required.

無密碼連接,然後輸入 info 命令就會報這個錯。 是因爲默認連接方式沒有查看權限。
使用帶密碼的登錄方式即可。

info參數列表

info可以查看所有參數。
info 模塊名可以看對應的模塊,如 info server,info memory等。
一般用 info clients 命令就可以了,輸出內容如下:

# Clients
connected_clients:865  # 鏈接數
client_recent_max_input_buffer:4
client_recent_max_output_buffer:0
blocked_clients:0

client list 查看連接列表

有很多字段,age表示創建時間(秒) idle表示空閒時間(秒)
idle時間過長 表示一直空置,可以幹掉
age=idle 表示創建後就沒有用過,也可以幹掉

查看超時設置

config get timeout  # 查看超時設置
config set timeout 300 # 設置超時時間(秒)

config get *   # 查看所有的配置列表 

info 所有參數列表

所有參數列表:

# Server
redis_version:3.2.12
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7897e7d0e13773f
redis_mode:standalone
os:Linux 3.10.0-957.21.3.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:29031
run_id:c810b029bd8eea504cbcd4b466cf1e18c6948f7e
tcp_port:6379
uptime_in_seconds:7308611
uptime_in_days:84
hz:10
lru_clock:13908165
executable:/usr/bin/redis-server
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:813696
used_memory_human:794.62K
used_memory_rss:1810432
used_memory_rss_human:1.73M
used_memory_peak:5022056
used_memory_peak_human:4.79M
total_system_memory:3973533696
total_system_memory_human:3.70G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:2.22
mem_allocator:jemalloc-3.6.0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1590722687
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:446262
total_commands_processed:1143019
instantaneous_ops_per_sec:0
total_net_input_bytes:110594091
total_net_output_bytes:724507868
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:9814
evicted_keys:0
keyspace_hits:54673
keyspace_misses:10209
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:212
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:2315.55
used_cpu_user:1439.36
used_cpu_sys_children:1.90
used_cpu_user_children:1.28

# Cluster
cluster_enabled:0

# Keyspace

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