四、Redis 配置

四、Redis 配置

master ,这是我的小站,欢迎访问哦~~

Redis 提供了很多配置选项来优化 Redis 服务

Redis 的配置文件位于 Redis 安装目录下,文件名为 redis.conf

可以通过 Redis CONFIG 命令查看或设置配置项

Redis CONFIG GET 命令语法格式

Redis CONFIG GET 命令语法格式如下

1
CONFIG GET CONFIG_SETTING_NAME

范例

1
2
3
4
127、0.0.1:6379> CONFIG GET loglevel

1) "loglevel"
2) "notice"

可以使用 * 号获取所有的 Redis 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
127、0.0.1:6379> CONFIG GET *
1) "dbfilename"
2) "dump.rdb"
3) "requirepass"
4) ""
5) "masterauth"
6) ""
7) "unixsocket"
8) ""
9) "logfile"
10) ""
11) "pidfile"
12) "/usr/local/var/run/redis.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) "no"
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) "no"
111) "dir"
112) "/usr/local/var/db/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) ""
129) "bind"
130) "127.0.0.1"

编辑配置

可以通过修改 redis.conf 文件或使用 CONFIG set 命令来修改配置

Redis CONFIG SET 命令

Redis CONFIG SET 命令用来设置配置选项

Redis CONFIG SET 语法

Redis CONFIG SET 命令语法格式如下

1
CONFIG SET CONFIG_SETTING_NAME NEW_CONFIG_VALUE

范例

1
2
3
4
5
6
127、0.0.1:6379> CONFIG SET loglevel "notice"
OK
127、0.0.1:6379> CONFIG GET loglevel

1) "loglevel"
2) "notice"