Redis的配置文件位于Redis安装目录下,文件名为 redis.conf(Windows名为redis.windows.conf)。 你可以通过CONFIG命令查看或设置配置项。 Redis CONFIG 命令格式如下: redis 127.0.0.1:6379> CONFIG GET CONFIG_SETTING_NAME 实例: redis 127.0.0.1:6379> CONFIG GET loglevel "loglevel" "notice" 使用 * 号获取所有配置项: 实例: redis 127.0.0.1:6379> CONFIG GET * "dbfilename" "dump.rdb" "requirepass" "" "masterauth" "" "unixsocket" "" "logfile" "" "pidfile" "/var/run/redis.pid" "maxmemory" "0" "maxmemory-samples" "3" "timeout" "0" "tcp-keepalive" "0" "auto-aof-rewrite-percentage" "100" "auto-aof-rewrite-min-size" "67108864" "hash-max-ziplist-entries" "512" "hash-max-ziplist-value" "64" "list-max-ziplist-entries" "512" "list-max-ziplist-value" "64" "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" "tcp-backlog" "511" "databases" "16" "repl-ping-slave-period" "10" "repl-timeout" "60" "repl-backlog-size" "1048576" "repl-backlog-ttl" "3600" "maxclients" "4064" "watchdog-period" "0" "slave-priority" "100" "min-slaves-to-write" "0" "min-slaves-max-lag" "10" "hz" "10" "no-appendfsync-on-rewrite" "no" "slave-serve-stale-data" "yes" "slave-read-only" "yes" "stop-writes-on-bgsave-error" "yes" "daemonize" "no" "rdbcompression" "yes" "rdbchecksum" "yes" "activerehashing" "yes" "repl-disable-tcp-nodelay" "no" "aof-rewrite-incremental-fsync" "yes" "appendonly" "no" "dir" "/home/deepak/Downloads/redis-2.8.13/src" "maxmemory-policy" "volatile-lru" "appendfsync" "everysec" "save" "3600 1 300 100 60 10000" "loglevel" "notice" "client-output-buffer-limit" "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60" "unixsocketperm" "0" "slaveof" "" "notify-keyspace-events" "" "bind" "" 编辑配置 你可以通过修改redis.conf文件或使用CONFIG set命令来修改配置。 语法 CONFIG SET 命令基本语法: redis 127.0.0.1:6379> CONFIG SET CONFIG_SETTING_NAME NEW_CONFIG_VALUE 实例: redis 127.0.0.1:6379> CONFIG SET loglevel "notice" OK redis 127.0.0.1:6379> CONFIG GET loglevel "loglevel" "notice" redis.conf 配置项说明如下:
1、daemonize no
2、pidfile /var/run/redis.pid
3、port 6379
4、bind 127.0.0.1
5、timeout 300
6、loglevel notice
7、logfile stdout
8、databases 16 9、save <seconds> <changes> Redis 默认配置文件中提供了三个条件: save 900 1 save 300 10 save 60 10000 分别表示 900 秒(15 分钟)内有 1 个更改,300 秒(5 分钟)内有 10 个更改以及 60 秒内有 10000 个更改。 指定在多长时间内,有多少次更新操作,就将数据同步到数据文件,可以多个条件配合
10、rdbcompression yes
11、dbfilename dump.rdb
12、dir ./
13、slaveof <masterip> <masterport>
14、masterauth <master-password>
15、requirepass foobared
16、maxclients 128
17、maxmemory <bytes>
18、appendonly no
19、appendfilename appendonly.aof 20、appendfsync everysec 指定更新日志条件,共有 3 个可选值: no:表示等操作系统进行数据缓存同步到磁盘(快)always:表示每次更新操作后手动调用 fsync() 将数据写到磁盘(慢,安全)everysec:表示每秒同步一次(折中,默认值)
21、vm-enabled no
22、vm-swap-file /tmp/redis.swap
23、vm-max-memory 0
24、vm-page-size 32
25、vm-pages 134217728
26、vm-max-threads 4
27、glueoutputbuf yes
28、hash-max-zipmap-entries 64hash-max-zipmap-value 512
29、activerehashing yes
30、include /path/to/local.conf (责任编辑:yang) |