Redis配置

Redis配置文件名

系统 文件名 路径
linux redis.conf 安装目录
Windows redis.windows.conf 安装目录

Redis CONFIG命令

定义

使用 redis-cli 客户端连接上 redis 服务器之后,使用 config 命令可以查看或者设置 redis 的配置。

命令语法

命令 功能
CONFIG GET key 获取 key 的配置。
CONFIG GET * 获取所有的配置。
CONFIG SET key value 设置 key 的值为 value。

CONFIG GET命令实例

获取配置项为 dbfilename 的配置

192.168.98.70:6379> config get dbfilename 1) "dbfilename" 2) "dump.rdb"

获取不存在的键的配置

192.168.98.70:6379> config get www.haicoder.net (empty list or set)

获取所有的配置

192.168.98.70:6379> config get * 1) "dbfilename" 2) "dump.rdb" 3) "requirepass" 4) "" 5) "masterauth" 6) "" 7) "unixsocket" 8) "" 9) "logfile" 10) "/var/log/redis/redis-server.log" 11) "pidfile" 12) "/var/run/redis/redis-server.pid" 13) "maxmemory" 14) "0" 15) "maxmemory-samples" 16) "5" 17) "timeout" 18) "0" 19) "tcp-keepalive" 20) "0" 21) "auto-aof-rewrite-percentage" 22) "100" 23) "auto-aof-rewrite-min-size" 24) "67108864" 25) "hash-max-ziplist-entries" 26) "512" 27) "hash-max-ziplist-value" 28) "64" 29) "list-max-ziplist-entries" 30) "512" 31) "list-max-ziplist-value" 32) "64" 33) "set-max-intset-entries" 34) "512" 35) "zset-max-ziplist-entries" 36) "128" 37) "zset-max-ziplist-value" 38) "64" 39) "hll-sparse-max-bytes" 40) "3000" 41) "lua-time-limit" 42) "5000" 43) "slowlog-log-slower-than" 44) "10000" 45) "latency-monitor-threshold" 46) "0" 47) "slowlog-max-len" 48) "128" 49) "port" 50) "6379" 51) "tcp-backlog" 52) "511" 53) "databases" 54) "16" 55) "repl-ping-slave-period" 56) "10" 57) "repl-timeout" 58) "60" 59) "repl-backlog-size" 60) "1048576" 61) "repl-backlog-ttl" 62) "3600" 63) "maxclients" 64) "10000" 65) "watchdog-period" 66) "0" 67) "slave-priority" 68) "100" 69) "min-slaves-to-write" 70) "0" 71) "min-slaves-max-lag" 72) "10" 73) "hz" 74) "10" 75) "cluster-node-timeout" 76) "15000" 77) "cluster-migration-barrier" 78) "1" 79) "cluster-slave-validity-factor" 80) "10" 81) "repl-diskless-sync-delay" 82) "5" 83) "cluster-require-full-coverage" 84) "yes" 85) "no-appendfsync-on-rewrite" 86) "no" 87) "slave-serve-stale-data" 88) "yes" 89) "slave-read-only" 90) "yes" 91) "stop-writes-on-bgsave-error" 92) "yes" 93) "daemonize" 94) "yes" 95) "rdbcompression" 96) "yes" 97) "rdbchecksum" 98) "yes" 99) "activerehashing" 100) "yes" 101) "repl-disable-tcp-nodelay" 102) "no" 103) "repl-diskless-sync" 104) "no" 105) "aof-rewrite-incremental-fsync" 106) "yes" 107) "aof-load-truncated" 108) "yes" 109) "appendonly" 110) "yes" 111) "dir" 112) "/usr/local/redis" 113) "maxmemory-policy" 114) "noeviction" 115) "appendfsync" 116) "everysec" 117) "save" 118) "900 1 300 10 60 10000" 119) "loglevel" 120) "notice" 121) "client-output-buffer-limit" 122) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60" 123) "unixsocketperm" 124) "0" 125) "slaveof" 126) "" 127) "notify-keyspace-events" 128) "xE" 129) "bind" 130) "192.168.98.70"

Redis CONFIG SET命令实例

可以通过修改 redis.conf 文件或使用 CONFIG SET 命令来修改配置。设置日志级别为 notice:

192.168.98.70:6379> CONFIG SET loglevel "notice" OK 192.168.98.70:6379> CONFIG GET loglevel 1) "loglevel" 2) "notice"

Redis配置总结

Linux 下 Redis 的配置文件为 redis.conf,在安装的目录下。Windows 下 Redis 的配置文件为 redis.windows.conf,也在安装目录下。