Redis configuration file details

  • Redis

Start the way

By default, redis is not run in the background. If it is, change the value of this item to yes daemonize noCopy the code

Pid file path

When redis is running in the background, redis will put the pid file in /var/run/redis. Pid by default, you can configure it to other addresses. Pidfile /var/run/redis.pid Specifies a different PID file and port when running multiple Redis servicesCopy the code

Specify receiving address

Specifies that Redis will only receive requests from this IP address, if not set, all requests will be processed, >bind 127.0.0.1
Copy the code

timeout

> timeout 0
Copy the code

Number of database

> databases 16
Copy the code

Save data to disk in the following format:

#
# save <seconds> <changes>
#
Data will be synchronized to the data file RDB over how long and how many update operations.
# equivalent to conditional trigger snapshot capture, this can be multiple conditions with
#
For example, in the default configuration file, there are three conditions
#
At least one key has been changed within 900 seconds
At least 300 keys were changed in 300 seconds
At least 10000 keys were changed in 60 seconds

save 900 1
save 300 10
save 60 10000
Copy the code

Maximum number of connections

The number of client connections that Redis can open at the same time is the maximum number of file descriptors that the Redis process can open.
If maxClients is set to 0, no limit is set.
Redis will close new connections and return a Max number of clients reached error message to the client
#
# maxclients 128
Copy the code

Specifies the maximum Redis memory limit

# specifies the maximum memory limit for Redis. When Redis starts up, data will be loaded into memory. When the maximum memory is reached, Redis will first attempt to clear expired or expiring keys
# Redis also removes empty list objects
#
# When the Max memory setting is still reached, no more writing can be done, but reading can still be done
#
# Note: The new VM mechanism of Redis will store keys in memory and values in swap
#
The # maxMemory setup is more suitable for redis to be used as a memcached-like cache than as a real DB.
Memory usage can be a significant overhead when using Redis as a real database
# maxmemory <bytes>
Copy the code

What data does Redis choose to delete when memory reaches its maximum? There are five ways to choose from

# volatile-lru -> Use the lRU algorithm to remove keys that have expired.
# allkeys-lRU -> Remove any keys using the LRU algorithm
# volatile-random -> Remove random keys that have expired
# allkeys->random -> remove a random key, any key
# volatile- TTL -> Remove keys that are about to expire (minor TTL)
# noeviction -> Does not remove anything that can, just returns a write bug
#
# Note: For the above policy, Redis will return an error when writing if there is no suitable key to remove
Copy the code

password

Set the password to be used after the client connects before any other specification is made.
# Warning: Because Redis is so fast, an external user can make 150K password attempts per second on a good server, which means you need to specify very, very strong passwords to prevent brute force cracking
#
# requirepass foobared

# when password protection is set for master service (requirePass password)
Slav service connection master password
#
# masterauth <master-password>
Copy the code