Redis6 服务端配置 config命令介绍

  • config命令介绍(都有默认值)

    • 可以动态地调整 Redis 服务器的配置(configuration)而无须重启
    • config get xxx、config set xxx

登录redis客户端

[root@localhost bin]# ./redis-cli -a 1qazXSW@

键入 config get * 可查看所有配置信息

127.0.0.1:6379> config get *
  1) "rdbchecksum"
  2) "yes"
  3) "daemonize"
  4) "yes"
  5) "io-threads-do-reads"
  6) "no"
  7) "lua-replicate-commands"
  8) "yes"
  9) "always-show-logo"
 10) "no"
 11) "protected-mode"
 12) "yes"
 13) "rdbcompression"
 14) "yes"
 15) "rdb-del-sync-files"
 16) "no"
 17) "activerehashing"
 18) "yes"
 19) "stop-writes-on-bgsave-error"
 20) "yes"
 21) "set-proc-title"
 22) "yes"
 23) "dynamic-hz"
 24) "yes"
 25) "lazyfree-lazy-eviction"
 26) "no"
 27) "lazyfree-lazy-expire"
 28) "no"
 29) "lazyfree-lazy-server-del"
 30) "no"
 31) "lazyfree-lazy-user-del"
 32) "no"
 33) "lazyfree-lazy-user-flush"
 34) "no"
 35) "repl-disable-tcp-nodelay"
 36) "no"
 37) "repl-diskless-sync"
 38) "no"
 39) "gopher-enabled"
 40) "no"
 41) "aof-rewrite-incremental-fsync"
 42) "yes"
 43) "no-appendfsync-on-rewrite"
 44) "no"
 45) "cluster-require-full-coverage"
 46) "yes"
 47) "rdb-save-incremental-fsync"
 48) "yes"
 49) "aof-load-truncated"
 50) "yes"
 51) "aof-use-rdb-preamble"
 52) "yes"
 53) "cluster-replica-no-failover"
 54) "no"
 55) "cluster-slave-no-failover"
 56) "no"
 57) "replica-lazy-flush"
 58) "no"
 59) "slave-lazy-flush"
 60) "no"
 61) "replica-serve-stale-data"
 62) "yes"
 63) "slave-serve-stale-data"
 64) "yes"
 65) "replica-read-only"
 66) "yes"
 67) "slave-read-only"
 68) "yes"
 69) "replica-ignore-maxmemory"
 70) "yes"
 71) "slave-ignore-maxmemory"
 72) "yes"
 73) "jemalloc-bg-thread"
 74) "yes"
 75) "activedefrag"
 76) "no"
 77) "syslog-enabled"
 78) "no"
 79) "cluster-enabled"
 80) "no"
 81) "appendonly"
 82) "yes"
 83) "cluster-allow-reads-when-down"
 84) "no"
 85) "crash-log-enabled"
 86) "yes"
 87) "crash-memcheck-enabled"
 88) "yes"
 89) "use-exit-on-panic"
 90) "no"
 91) "disable-thp"
 92) "yes"
 93) "aclfile"
 94) ""
 95) "unixsocket"
 96) ""
 97) "pidfile"
 98) "/var/run/redis.pid"
 99) "replica-announce-ip"
100) ""
101) "slave-announce-ip"
102) ""
103) "masteruser"
104) ""
105) "cluster-announce-ip"
106) ""
107) "syslog-ident"
108) "redis"
109) "dbfilename"
110) "xdclass.rdb"
111) "appendfilename"
112) "appendonly.aof"
113) "server_cpulist"
114) ""
115) "bio_cpulist"
116) ""
117) "aof_rewrite_cpulist"
118) ""
119) "bgsave_cpulist"
120) ""
121) "ignore-warnings"
122) ""
123) "proc-title-template"
124) "{title} {listen-addr} {server-mode}"
125) "masterauth"
126) "1qazXSW@"
127) "requirepass"
128) "1qazXSW@"
129) "supervised"
130) "no"
131) "syslog-facility"
132) "local0"
133) "repl-diskless-load"
134) "disabled"
135) "loglevel"
136) "notice"
137) "maxmemory-policy"
138) "noeviction"
139) "appendfsync"
140) "everysec"
141) "oom-score-adj"
142) "no"
143) "acl-pubsub-default"
144) "allchannels"
145) "sanitize-dump-payload"
146) "no"
147) "databases"
148) "16"
149) "port"
150) "6379"
151) "io-threads"
152) "1"
153) "auto-aof-rewrite-percentage"
154) "100"
155) "cluster-replica-validity-factor"
156) "10"
157) "cluster-slave-validity-factor"
158) "10"
159) "list-max-ziplist-size"
160) "-2"
161) "tcp-keepalive"
162) "300"
163) "cluster-migration-barrier"
164) "1"
165) "active-defrag-cycle-min"
166) "1"
167) "active-defrag-cycle-max"
168) "25"
169) "active-defrag-threshold-lower"
170) "10"
171) "active-defrag-threshold-upper"
172) "100"
173) "lfu-log-factor"
174) "10"
175) "lfu-decay-time"
176) "1"
177) "replica-priority"
178) "100"
179) "slave-priority"
180) "100"
181) "repl-diskless-sync-delay"
182) "5"
183) "maxmemory-samples"
184) "5"
185) "maxmemory-eviction-tenacity"
186) "10"
187) "timeout"
188) "0"
189) "replica-announce-port"
190) "0"
191) "slave-announce-port"
192) "0"
193) "tcp-backlog"
194) "511"
195) "cluster-announce-bus-port"
196) "0"
197) "cluster-announce-port"
198) "0"
199) "repl-timeout"
200) "60"
201) "repl-ping-replica-period"
202) "10"
203) "repl-ping-slave-period"
204) "10"
205) "list-compress-depth"
206) "0"
207) "rdb-key-save-delay"
208) "0"
209) "key-load-delay"
210) "0"
211) "active-expire-effort"
212) "1"
213) "hz"
214) "10"
215) "min-replicas-to-write"
216) "0"
217) "min-slaves-to-write"
218) "0"
219) "min-replicas-max-lag"
220) "10"
221) "min-slaves-max-lag"
222) "10"
223) "maxclients"
224) "10000"
225) "active-defrag-max-scan-fields"
226) "1000"
227) "slowlog-max-len"
228) "128"
229) "acllog-max-len"
230) "128"
231) "lua-time-limit"
232) "5000"
233) "cluster-node-timeout"
234) "15000"
235) "slowlog-log-slower-than"
236) "10000"
237) "latency-monitor-threshold"
238) "0"
239) "proto-max-bulk-len"
240) "536870912"
241) "stream-node-max-entries"
242) "100"
243) "repl-backlog-size"
244) "1048576"
245) "maxmemory"
246) "0"
247) "hash-max-ziplist-entries"
248) "512"
249) "set-max-intset-entries"
250) "512"
251) "zset-max-ziplist-entries"
252) "128"
253) "active-defrag-ignore-bytes"
254) "104857600"
255) "hash-max-ziplist-value"
256) "64"
257) "stream-node-max-bytes"
258) "4096"
259) "zset-max-ziplist-value"
260) "64"
261) "hll-sparse-max-bytes"
262) "3000"
263) "tracking-table-max-keys"
264) "1000000"
265) "client-query-buffer-limit"
266) "1073741824"
267) "repl-backlog-ttl"
268) "3600"
269) "auto-aof-rewrite-min-size"
270) "67108864"
271) "logfile"
272) "/usr/local/redis/log/redis.log"
273) "watchdog-period"
274) "0"
275) "dir"
276) "/usr/local/redis/data"
277) "save"
278) "3600 1 300 100 60 10000"
279) "client-output-buffer-limit"
280) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
281) "unixsocketperm"
282) "0"
283) "slaveof"
284) ""
285) "notify-keyspace-events"
286) ""
287) "bind"
288) "0.0.0.0"
289) "oom-score-adj-values"
290) "0 200 800"

config 都是 key value形式,可以 congfig get xxx

 redis常用配置

# 后端运行
daemonize

# ip绑定
bind

# 客户端连接时的超时时间,单位为秒。当客户端在这段时间内没有发出任何指令,那么关闭该连接
timeout

# 设置数据库的个数,可以使用 SELECT 命令来切换数据库。默认使用的数据库是 0
databases

# 设置 Redis 进行rdb持久化数据库镜像的频率。
save

# 在进行镜像备份时,是否进行压缩
rdbcompression

# 设置该数据库为其他数据库的从数据库
slaveof

# 当主数据库连接需要密码验证时,在这里配置
masterauth

# 限制同时连接的客户数量,当连接数超过这个值时,redis 将不再接收其他连接请求,返回error
maxclients

# 设置 redis 能够使用的最大内存
maxmemory

其中

  • maxmemory #设置 redis 能够使用的最大内存,

  • 备注

    • 防止所用内存超过服务器物理内存, maxmemory限制的是Redis实际使用的内存量, 也就是used_memory统计项对应的内存
    • 由于内存碎片率的存在, 实际消耗的内存可能会比maxmemory设置的更大, 实际使用时要小心这部分内存溢出
    • 默认无限使用服务器内存, 为防止极端情况下导致系统内存耗尽, 建议所有的Redis进程都要配置maxmemory
    • 在64bit系统下,maxmemory设置为0表示不限制Redis内存使用,在32bit系统下,maxmemory不能超过3GB
  • 注意:

    • redis在占用的内存超过指定的maxmemory之后,通过maxmemory_policy确定redis是否释放内存以及如何释放内存

猜你喜欢

转载自blog.csdn.net/ElendaLee/article/details/124910658