The official redis.conf profile is the bin, and the explanatory notes in great detail in place, we can follow the prompts to block, quickly lock the target configuration items.
When actually used, first pay attention to back up the default configuration file, the second covering or comment out some of the default configuration tests used only for practice, such as the maximum number of clients, the maximum memory close to the treatment strategies.
Consolidation common configuration items are described below:
- INCLUDES multiple configuration files
analogy nginx configuration, we can configure the default main frame, and then useinclude /xx/xx.conf
the other module configurations include it - NETWORK Network configuration
port 6379
redis service start port configuration, m 6379 defaulttcp-backlog 511
Connection queue size configuration, according to the official explanatory notes:- A need to avoid the issue queue tpc slow client connections under high concurrency scenarios, where the default value 511
- However, Linux kernel will automatically truncated to proc / sys / net / core / somaxconn value /, so if tps system is large, you need to adjust / proc / sys / net / core / somaxconn and tcp-backlog to Achieve the desired effect
bind 127.0.0.1
Configuring exposure to which clients connect. The default setting can only connect as a client machine.- If you allow any machine connected, comment out all bind to the configuration, but then configure redis password alone.
- If you specify several machines can access, continue to add items to bind.
timeout 0
redis-cli client idle timeout time setting, default 0 for constantly open connectiontcp-keepalive 300
Heartbeat tcp connection time setting, redis3.2.1 recommended setting the default time is 300 seconds (60 seconds before the default recommended). The non-zero value, it will be redis server when the client did not move, periodically sends TCP-ACK signal to the client, because there are two (not quite understand what the meaning):- Detect dead peers.
- Take the connection alive from the point of view of network equipment in the middle.
- GENERAL common standard configuration
daemonize no
Whether to run in daemon mode redis service, the default is nopidfile /var/run/redis_6379.pid
Redis used for recording the location of the file server process.loglevel notice
redis log level configurationlogfile ''
Specify the log file output path# syslog-enabled no
The system log is disabled by default# syslog-ident redis
Text identification system log# syslog-facility local0
Specifies the syslog, it is unclear. .databases 16
Specifies the number of database initial
default 16, the client usesselect n
switching database, from n-0.
- SNAPSHOTTING snapshot configuration, to be joined == redis persistence of RDB == comb.
- APPEND ONLY MODE, to be bonded AOF of persistent == == Redis comb.
- REPLICATION configuration copy to be copied from the primary binding == == Redis comb.
- SECURITY security-related settings
# requirepass foobared
The default redis-cli on redis-server connection without a password.
After the client connectionconfig get requirepass
will be an empty string, and only the default service the machine can be connected. Notes can be used to open the configuration, you can also connect input after theconfig set requirepass xxx
start auth password, but we can recommend the official, the security to the server operation and maintenance, after all redis focus on the cache.
- MEMORY MANAGEMENT Memory management configuration
# maxclients 10000
The maximum number of client connections# maxmemory <bytes>
The maximum memory configuration# maxmemory-policy noeviction
When the strategy adopted when approaching the maximum memory configuration redis memory footprint, there are eight kinds: noeviction not default processing algorithm, being given to re-write- volatile-lru -> Evict using approximated LRU among the keys with an expire set.
- allkeys-lru -> Evict any key using approximated LRU.
- volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
- allkeys-lfu -> Evict any key using approximated LFU.
- volatile-random -> Remove a random key among the ones with an expire set.
- allkeys-random -> Remove a random key, any key.
- volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
- noeviction -> Don't evict anything, just return an error on write operations.
# maxmemory-samples 5
LRU, and LFU algorithms are not precise minimum ttl algorithm, but approximation algorithm. Sample number keys may be configured to adjust their speed and accuracy. The default value of 5 to generate enough good results, very close to the real lru, but requires more cpu. 3 faster, but less accurate.- Other configuration blocks