1 where is it
2 units unit
- 1 Configure some basic units of measurement in the definition. Bytes are supported, but bits are not supported
- 2 is case insensitive
3 INCLUDES including
4 GENERAL GENERAL
- Daemonize
- Pidfile
- Port
- Tcp-backlog
Set the TCP backlog. The backlog is actually a connection queue. The total backlog = incomplete three-handshake queue + completed three-handshake queue.
In high-concurrency environments you need a high backlog value to avoid slow client connection issues. Pay attention to the Linux kernel will reduce this value to the/proc/sys/net/core/somaxconn values, so you need to confirm increase somaxconn and tcp_max_syn_backlog two values to achieve the desired effect
- Timeout
- Bind
- Tcp-keepalive
The unit is second. If the value is 0, Keepalive detection is not performed. You are advised to set the value to 60
- Loglevel
- Logfile
- Syslog-enabled
Whether to output logs to syslog
- Syslog-ident
Specifies the log flag in syslog
- Syslog-facility
Specifies a syslog device. The value can be USER or local0-local7
- Databases
5 SNAPSHOTTING snapshot
- Save
- Stop-writes-on-bgsave-error
If set to NO, you do not care about data inconsistencies or other means of discovery and control
- rdbcompression
Rdbcompression: For snapshots stored in disks, you can set whether to compress them. If so, Redis uses the LZF algorithm for compression. If you don’t want to use CPU for compression, you can turn this feature off
- rdbchecksum
Rdbchecksum: After storing the snapshot, you can also have Redis use the CRC64 algorithm to verify the data, but this increases performance by about 10%. You can turn this off if you want the maximum performance gain
- dbfilename
- dir
6 the REPLICATION copy
7 SECURITY safety
View, set, and cancel access passwords
8 LIMITS restrictions
- Maxclients
Set how many clients Redis can connect to at the same time. The default is 10000 clients. When you cannot set the process handle limit, Redis will set the current handle limit value minus 32 because Redis will save some handles for its own internal processing logic. If this limit is reached, Redis rejects new connection requests and responds by issuing a “Max number of clients reached” to those connection requesters
- Maxmemory
Set the amount of memory redis can use. Once the memory usage limit is reached, Redis will attempt to remove internal data, which can be specified by maxmemory-policy. If Redis is unable to remove data from memory according to the remove rule, or if “remove not allowed” is SET, then Redis will return error messages for instructions that require memory allocation, such as SET, LPUSH, etc.
However, for instructions with no memory requisition, it will still respond normally, such as GET, etc. If your redis is the primary redis, then you need to set some memory space in the system for the synchronous queue cache when setting the memory usage limit, and only if you set it to “do not remove”, this factor is not taken into account
- Maxmemory-policy
(1) volatile- LRU: Use the LRU algorithm to remove the key, only for the key whose expiration time is set
(2) allkeys-lRU: remove keys with lRU algorithm (3) Volatile -random: remove random keys from expiring sets, only for keys with expiring time (4) allkeys-random: remove random keys from expiring sets (5) volatile- TTL: remove keys with expiring time Remove keys with the lowest TTL value, those keys that are expiring recently. For write operations, only error messages are returned
- Maxmemory-samples
Set the number of samples. The LRU algorithm and the minimum TTL algorithm are not exact algorithms, but estimates, so you can set the size of the sample. Redis will check the number of keys by default and select the LRU one
9 APPEND ONLY MODE APPEND
-
appendonly
-
appendfilename
-
Appendfsync
-
No-appendfsync-on-rewrite
Appendfsync (default no) should be used to ensure data security.
- Auto-aof-rewrite-min-size
Sets the override reference value
- Auto-aof-rewrite-percentage
Sets the override reference value
10 Common configurations redis.conf
- Redis does not run as a daemon by default. You can change this configuration item by using yes to enable the daemon
daemonize no
- Pid is written to the /var/run/redis.pid file by default when Redis is running as a daemon, which can be specified by pidfile
pidfile /var/run/redis.pid
- The default port is 6379. In my blog post, I explained why I chose 6379 as the default port, because 6379 corresponds to MERZ on the phone keys, and MERZ is named after The Italian singer Alessia MERZ
port 6379
- IP address of the bound host
The bind 127.0.0.1
5. Close the connection when the client is idle. If the value is 0, the function is disabled
timeout 300
- Redis supports four log levels: debug, verbose, notice, and warning. The default log level is verbose
loglevel verbose