Redis CONFIG GET Command Explained

Have a Database Problem? Speak with an Expert for Free
Get Started >>

Introduction

In this article we’ll take a look at the CONFIG GET command. We’ll take a look at some of the command’s options and we’ll run the command on our local Redis instance so you can see what type of results to expect.

What does the CONFIG GET command do?

The CONFIG GET command lets you retrieve the configurations settings of your Redis server. It takes in one argument that uses a pattern matching system which both enables you to get a single setting, all settings, or just settings that match a certain pattern.

How to get a single setting using CONFIG GET

To get a single Redis setting use the CONFIG GET command with this syntax:

1
CONFIG GET config-setting-name

Let’s use the command to get the port Redis is running on:

1
2
3
127.0.0.1:6379> CONFIG GET port
1) "port"
2) "6379"

Note that each setting is followed by it’s value. So in the results every odd number will have a setting name, and the following even number will have it’s value.

Get all configuration settings

To get all the configuration settings pass in an asterisk to the command. Below is the command and shows the full list of settings on a Redis instance:

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
127.0.0.1:6379> CONFIG GET *
  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) ""
  5) "masterauth"
  6) ""
  7) "cluster-announce-ip"
  8) ""
  9) "unixsocket"
 69) "port"
 70) "6379"
 71) "cluster-announce-port"
 72) "0"
 73) "cluster-announce-bus-port"
 74) "0"
 75) "tcp-backlog"
 76) "511"
 77) "databases"
 78) "16"
 79) "repl-ping-slave-period"
 80) "10"
 81) "repl-timeout"
 82) "60"
 83) "repl-backlog-size"
 84) "1048576"
 85) "repl-backlog-ttl"
 86) "3600"
 87) "maxclients"
 88) "10000"
 89) "watchdog-period"
 90) "0"
 91) "slave-priority"
 92) "100"
 93) "slave-announce-port"
 94) "0"
 95) "min-slaves-to-write"
 96) "0"
 97) "min-slaves-max-lag"
 98) "10"
 99) "hz"
100) "10"
101) "cluster-node-timeout"
102) "15000"
103) "cluster-migration-barrier"
104) "1"
105) "cluster-slave-validity-factor"
106) "10"
107) "repl-diskless-sync-delay"
108) "5"
109) "tcp-keepalive"
110) "300"
111) "cluster-require-full-coverage"
112) "yes"
113) "cluster-slave-no-failover"
114) "no"
115) "no-appendfsync-on-rewrite"
116) "no"
117) "slave-serve-stale-data"
118) "yes"
119) "slave-read-only"
120) "yes"
121) "stop-writes-on-bgsave-error"
122) "yes"
123) "daemonize"
124) "no"
125) "rdbcompression"
126) "yes"
127) "rdbchecksum"
128) "yes"
129) "activerehashing"
130) "yes"
131) "activedefrag"
132) "no"
133) "protected-mode"
134) "yes"
135) "repl-disable-tcp-nodelay"
136) "no"
137) "repl-diskless-sync"
138) "no"
139) "aof-rewrite-incremental-fsync"
140) "yes"
141) "aof-load-truncated"
142) "yes"
143) "aof-use-rdb-preamble"
144) "no"
145) "lazyfree-lazy-eviction"
146) "no"
147) "lazyfree-lazy-expire"
148) "no"
149) "lazyfree-lazy-server-del"
150) "no"
151) "slave-lazy-flush"
152) "no"
153) "maxmemory-policy"
154) "noeviction"
155) "loglevel"
156) "notice"
157) "supervised"
158) "no"
159) "appendfsync"
160) "everysec"
161) "syslog-facility"
162) "local0"
163) "appendonly"
164) "no"
165) "dir"
166) "/"
167) "save"
168) "3600 1 300 100 60 10000"
169) "client-output-buffer-limit"
170) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
171) "unixsocketperm"
172) "0"
173) "slaveof"
174) ""
175) "notify-keyspace-events"
176) ""
177) "bind"
178) ""

There are lots of settings here which means there are a lot of things you can configure within your Redis instance.

Get settings that match a pattern

Maybe you’re looking for all the settings that deal with replicas, the getting all the settings that begin with repl- might be very helpful. This query uses glob-style pattern matching. To get all the replica settings perform the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
127.0.0.1:6379> CONFIG GET repl-*
 1) "repl-ping-slave-period"
 2) "10"
 3) "repl-timeout"
 4) "60"
 5) "repl-backlog-size"
 6) "1048576"
 7) "repl-backlog-ttl"
 8) "3600"
 9) "repl-diskless-sync-delay"
10) "5"
11) "repl-disable-tcp-nodelay"
12) "no"
13) "repl-diskless-sync"
14) "no"
127.0.0.1:6379>

You can use the asterisk more than once for more complex pattern matching like so:

1
2
3
4
5
6
7
127.0.0.1:6379> CONFIG GET *-max-*-entries
1) "hash-max-ziplist-entries"
2) "512"
3) "set-max-intset-entries"
4) "512"
5) "zset-max-ziplist-entries"
6) "128"

Can you get all settings?

If you are running version Redis 2.4 no all the configuration settings are available through this command but Redis 2.6 does have the capability to read all settings.

Is there a file with the configuration settings?

Yes, there’s a configuration file called redis.conf at the same level of where Redis is installed.

What if a setting is set improperly?

If a configuration setting is not what you want or expected, you’ll have to use the CONFIG SET command to reconfigure the settings for the server. You’ll receive an “OK” to indicate success or an error if not.

Conclusion

The CONFIG GET command is a good command to get to know. It let’s you know both what you’re current settings are and there are probably tons of settings you have no idea what they do but are worth exploring. We encourage you to go to the Redis documentation and learn as much about the configuration options as possible especially if you’re running a production environment.

Pilot the ObjectRocket Platform Free!

Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.

Get Started

Keep in the know!

Subscribe to our emails and we’ll let you know what’s going on at ObjectRocket. We hate spam and make it easy to unsubscribe.