当前位置:网站首页>Redis learning journey --redis Conf details

Redis learning journey --redis Conf details

2022-06-13 07:28:00 Zhao JC

Redis Learning journey --Redis.conf Detailed explanation


When it starts , Just start with the configuration file ! Let's take a look now Redis.conf The content of
 Insert picture description here

  • Company unit
    The configuration file unit Company Case insensitive !
     Insert picture description here
  • include contain

It's like we learn Spring、Improt, include

 Insert picture description here

  • The Internet network
bind 127.0.0.1 #  The binding of ip 
protected-mode yes #  Protected mode  
port 6379 #  Port settings 
  • Universal GENERAL
daemonize yes #  Run as a daemon , The default is  no, We need to turn it on ourselves yes! 
pidfile /var/run/redis_6379.pid #  If it runs in the background mode , We need to specify one  pid  file !
 #  journal 
 # Specify the server verbosity level. 
 # This can be one of:
 # debug (a lot of information, useful for development/testing)
 # verbose (many rarely useful info, but not a mess like the debug level) 
 # notice (moderately verbose, what you want in production probably)  Production environment  
 # warning (only very important / critical messages are logged) 
   loglevel notice 
   logfile "" #  The file location name of the log  
   databases 16  #  Number of databases , The default is  16  A database  
   always-show-logo yes #  Always show LOGO
  • snapshot SNAPSHOTTING

Persistence , Within the specified time , How many operations have been performed , Will be persisted to the file .rdb. aof
redis Is a memory database , If there is no persistence , So the data power failure and loss !

#  If 900s Inside , If there is at least one 1 key It's been modified , We do persistence operations  
save 900 1 
#  If 300s Inside , If at least 10 key It's been modified , We do persistence operations  
save 300 10 
#  If 60s Inside , If at least 10000 key It's been modified , We do persistence operations  
save 60 10000 
#  We'll learn about persistence later , Will define the test itself ! 
stop-writes-on-bgsave-error yes #  Persistence if something goes wrong , Whether you need to continue working ! 
rdbcompression yes #  Is it compressed?  rdb  file , It needs to be consumed cpu resources ! rdbchecksum yes #  preservation rdb When you file , Check for errors ! 
dir ./ # rdb  The directory where the files are saved !
  • SECURITY Security

You can set it up here redis Password , The default is no password !

127.0.0.1:6379> ping
PONG
127.0.0.1:6379> config get requirepass	# obtain Redis Password 
1) "requirepass"
2) ""
127.0.0.1:6379> config set requirepass "12345678"	# Set up Redis Password 
OK
127.0.0.1:6379> config get requirepass	# Found all commands without permission 
(error) NOAUTH Authentication required.
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 12345678	# Log in with a password !
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "12345678"

  • Master slave copy replication

 Insert picture description here

  • Limit CLIENTS
maxclients 10000 #  Settings can be connected to redis The maximum number of clients  
maxmemory <bytes> # redis  Configure maximum memory capacity  
maxmemory-policy noeviction #  The processing strategy after the memory reaches the upper limit  
1、volatile-lru: Only for key Conduct LRU( The default value is ) 
2、allkeys-lru :  Delete lru Algorithm key 
3、volatile-random: Random delete is about to expire key 
4、allkeys-random: Random delete  
5、volatile-ttl :  Delete expiring  
6、noeviction :  Never expire , Returns an error 
  • APPEND ONLY Pattern aof To configure
appendonly no #  The default is not on aof Mode , The default is to use rdb Way persistent , In most cases , rdb Quite enough ! 
appendfilename "appendonly.aof" #  The name of the persistent file  
# appendfsync always #  Every time you make a change, it will  sync. Consumption performance  
appendfsync everysec #  Once a second  sync, You may lose this 1s The data of ! 
# appendfsync no #  Don't execute  sync, At this time, the operating system synchronizes its own data , The fastest !
原网站

版权声明
本文为[Zhao JC]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270548463219.html