Redis 配置
Redis 的配置文件位于Redis安装目录下,文件名为redis.conf(Windows 名为 redis.windows.conf)。
你可以通过CONFIG命令查看或设置配置项。
语法
Redis CONFIG 命令格式如下:
127.0.0.1:6379> CONFIG GET CONFIG_SETTING_NAME
实例
[root@localhost ~]# redis-cli
127.0.0.1:6379> config get loglevel
-
"loglevel"
-
"notice"
使用*号获取所有配置项:
127.0.0.1:6379> config get *
-
"dbfilename"
-
"dump.rdb"
-
"requirepass"
-
""
-
"masterauth"
-
""
-
"cluster-announce-ip"
-
""
-
"unixsocket"
-
""
-
"logfile"
-
"/usr/local/redis/redis.log"
-
"pidfile"
-
"/var/run/redis_6379.pid"
-
"slave-announce-ip"
-
""
-
"replica-announce-ip"
-
""
-
"maxmemory"
-
"0"
-
"proto-max-bulk-len"
-
"536870912"
-
"client-query-buffer-limit"
-
"1073741824"
-
"maxmemory-samples"
-
"5"
-
"lfu-log-factor"
-
"10"
-
"lfu-decay-time"
-
"1"
-
"timeout"
-
"0"
-
"active-defrag-threshold-lower"
-
"10"
-
"active-defrag-threshold-upper"
-
"100"
-
"active-defrag-ignore-bytes"
-
"104857600"
-
"active-defrag-cycle-min"
-
"5"
-
"active-defrag-cycle-max"
-
"75"
-
"active-defrag-max-scan-fields"
-
"1000"
-
"auto-aof-rewrite-percentage"
-
"100"
-
"auto-aof-rewrite-min-size"
-
"67108864"
-
"hash-max-ziplist-entries"
-
"512"
-
"hash-max-ziplist-value"
-
"64"
-
"stream-node-max-bytes"
-
"4096"
-
"stream-node-max-entries"
-
"100"
-
"list-max-ziplist-size"
-
"-2"
-
"list-compress-depth"
-
"0"
-
"set-max-intset-entries"
-
"512"
-
"zset-max-ziplist-entries"
-
"128"
-
"zset-max-ziplist-value"
-
"64"
-
"hll-sparse-max-bytes"
-
"3000"
-
"lua-time-limit"
-
"5000"
-
"slowlog-log-slower-than"
-
"10000"
-
"latency-monitor-threshold"
-
"0"
-
"slowlog-max-len"
-
"128"
-
"port"
-
"6379"
-
"cluster-announce-port"
-
"0"
-
"cluster-announce-bus-port"
-
"0"
-
"tcp-backlog"
-
"511"
-
"databases"
-
"16"
-
"repl-ping-slave-period"
-
"10"
-
"repl-ping-replica-period"
-
"10"
-
"repl-timeout"
-
"60"
-
"repl-backlog-size"
-
"1048576"
-
"repl-backlog-ttl"
-
"3600"
-
"maxclients"
-
"10000"
-
"watchdog-period"
-
"0"
-
"slave-priority"
-
"100"
-
"replica-priority"
-
"100"
-
"slave-announce-port"
-
"0"
-
"replica-announce-port"
-
"0"
-
"min-slaves-to-write"
-
"0"
-
"min-replicas-to-write"
-
"0"
-
"min-slaves-max-lag"
-
"10"
-
"min-replicas-max-lag"
-
"10"
-
"hz"
-
"10"
-
"cluster-node-timeout"
-
"15000"
-
"cluster-migration-barrier"
-
"1"
-
"cluster-slave-validity-factor"
-
"10"
-
"cluster-replica-validity-factor"
-
"10"
-
"repl-diskless-sync-delay"
-
"5"
-
"tcp-keepalive"
-
"300"
-
"cluster-require-full-coverage"
-
"yes"
-
"cluster-slave-no-failover"
-
"no"
-
"cluster-replica-no-failover"
-
"no"
-
"no-appendfsync-on-rewrite"
-
"no"
-
"slave-serve-stale-data"
-
"yes"
-
"replica-serve-stale-data"
-
"yes"
-
"slave-read-only"
-
"yes"
-
"replica-read-only"
-
"yes"
-
"slave-ignore-maxmemory"
-
"yes"
-
"replica-ignore-maxmemory"
-
"yes"
-
"stop-writes-on-bgsave-error"
-
"yes"
-
"daemonize"
-
"yes"
-
"rdbcompression"
-
"yes"
-
"rdbchecksum"
-
"yes"
-
"activerehashing"
-
"yes"
-
"activedefrag"
-
"no"
-
"protected-mode"
-
"yes"
-
"repl-disable-tcp-nodelay"
-
"no"
-
"repl-diskless-sync"
-
"no"
-
"aof-rewrite-incremental-fsync"
-
"yes"
-
"rdb-save-incremental-fsync"
-
"yes"
-
"aof-load-truncated"
-
"yes"
-
"aof-use-rdb-preamble"
-
"yes"
-
"lazyfree-lazy-eviction"
-
"no"
-
"lazyfree-lazy-expire"
-
"no"
-
"lazyfree-lazy-server-del"
-
"no"
-
"slave-lazy-flush"
-
"no"
-
"replica-lazy-flush"
-
"no"
-
"dynamic-hz"
-
"yes"
-
"maxmemory-policy"
-
"noeviction"
-
"loglevel"
-
"notice"
-
"supervised"
-
"no"
-
"appendfsync"
-
"everysec"
-
"syslog-facility"
-
"local0"
-
"appendonly"
-
"yes"
-
"dir"
-
"/data/redis"
-
"save"
-
"900 1 300 10 60 10000"
-
"client-output-buffer-limit"
-
"normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
-
"unixsocketperm"
-
"0"
-
"slaveof"
-
""
-
"notify-keyspace-events"
-
""
-
"bind"
-
"0.0.0.0"
编辑配置
你可以通过修改redis.conf 文件或使用CONFIG set命令来修改配置。
语法
CONFIG SET命令基本语法:
127.0.0.1:6379> CONFIG SET CONFIG_SETTING_NAME NEW_CONFIG_VALUE
实例
[root@localhost ~]# redis-cli
127.0.0.1:6379> CONFIG SET loglevel "notice"
OK
127.0.0.1:6379> CONFIG GET loglevel
-
"loglevel"
-
"notice"
继续阅读 Redis最后更新:2024-1-24