Redis basics: 4, parsing configuration files

Where is it?

redis unzip the redis.conf in the package

Remember to back up its original files~

Units

Insert picture description here
  • Some basic measurement units are defined at the beginning, only bytes are supported, not bits
  • Not case sensitive

INCLUDES contains

Insert picture description here


Other configuration files can be included through INCLUDES.

GENERAL

1、daemonize

Whether to run as a daemon.

Insert picture description here


2. pidfile

If running as a daemon process, where is the process pipe id file placed. (I don’t understand this for the time being)

Insert picture description here


3. port

Port number, the default is 6379

Insert picture description here


4. tcp-backlog

In the initial learning stage, just keep the official default value, don't make mistakes.

Insert picture description here


Translation: Set the backlog of tcp. The backlog is actually a connection queue. The sum of the backlog queues = the unfinished three-way handshake queue + the completed three-way handshake queue. In a high-concurrency environment, you need a high backlog value to avoid slow client connection problems. Note that the linux kernel will reduce this value to the value of /proc/sys/net/core/somaxconn, so you need to make sure to increase the two values ​​of somaxconn and tcp_max_syn_backlog to achieve the desired effect.

5. Gateway

Insert picture description here


6, timeout

How many seconds after being idle to close the redis connection

Insert picture description here

7、tcp-keepalive

If it is 0, keep it on

Insert picture description here


8, loglevel

Log level, use debug

Insert picture description here


9, logfile in the development phase

Set the name of the log file

Insert picture description here


10, syslog-enabled/syslog-ident/syslogfacility

System log

Insert picture description here


related11, databases

Set the number of databases, the default is 16

Insert picture description here

SNAPSHOTTING snapshot

1、save

save [seconds] [changes]Save [changes] changes within [seconds]

save ""This function can be disabled, or no save command can be set.

Insert picture description here

Enter in the client saveto manually save the snapshot

2、stop-writes-on-bgsave-error

When an error occurs in the backup process, the main process stops accepting new write operations. This is to maintain persistent data consistency issues.

3、rdbcompression

For the snapshots stored in the disk, you can set whether to compress the storage. If it is, redis will use the LZF algorithm for compression. If you don't want to consume CPU for compression, you can set to turn off this feature.

4、rdbchecksum

After storing the snapshot, redis can also use the CRC64 algorithm for data verification, but doing so will increase the performance consumption by about 10%. If you want to get the maximum performance improvement, you can turn off this feature

5、dbfilename

The name of the snapshot file

6 、 you

Storage path of the snapshot file

REPLICATION

SECURITY

config get requirepassGet password

config set requirepass [password]set password

After setting the password, if you do any operation, you will be prompted that there is no permission:

Insert picture description here


auth [password]so there is permission~

config get dirGet current path

LIMITS limit

1、Maxclients

Maximum number of clients

Insert picture description here


2, maxmemory

The maximum memory size that can be used

Insert picture description here


3, maxmemory-policy

When the memory is not enough, the old data needs to be removed to add the new one, so the removal strategy is set here.

Insert picture description here


There are six strategies:

  • Volatile-lru: the least recently used algorithm, select the key-value pair with the longest idle time from the keys with the expiration time set and clear it
  • allkeys-lru: Use the least recently used algorithm for all keys
  • volatile-random: randomly remove a key with expiration time
  • allkeys-random: randomly remove a key
  • volatile-ttl: Remove the key with the smallest ttl value, of course, provided that there is an expiration time
  • noeviction: Do not remove. Report an error when the memory is full

4. Maxmemory-samples

Insert picture description here


sets the number of samples. The LRU algorithm and the minimum TTL algorithm are not accurate algorithms, but estimated values. Generally speaking, the higher the samples value, the closer it is to the real LRU algorithm, but it will consume more CPU resources. The default setting is 5.