当前位置:网站首页>Redis configuration file details

Redis configuration file details

2022-06-27 08:17:00 Little moon 6

Linux Next Redis After the successful installation of src Next redis.conf yes redis Primary profile , See this article for details Linux Next Redis Installation

that redis.conf What are the main functions

Redis.conf

Universal :

  daemonize Whether to let redis The process becomes a daemon thread

################################# GENERAL #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.             By default ,Redis Do not run as Daemons . if necessary , Please use “ yes ”.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.     Be careful Redis Will be in /var/run Write a pid file /redis.pid When guarding . Process pipeline path , Do not know what that mean? 
daemonize yes      

  Port number port

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379

  tcp-backlog 

   Set up tcp Of backlog, backlog Actually Is a connection queue ,backlog The sum of the queues = Three handshake queues not completed + Three handshake queues have been completed . In a high concurrency environment, you need - One high backlog Value to avoid slow client connection problems . Be careful Linux The kernel will reduce this value to   proc/sys/net/core/ somaxconn So you need to confirm that it increases somaxconn and tcp_ max_ syn_ backlog Two values to achieve the desired effect ( Not quite understand )

# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the Linux kernel    In an environment with high requests per second , You need a tall backlog In order to avoid the problem of slow client connection 
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
tcp-backlog 511

 timeout

# Close the connection after a client is idle for N seconds (0 to disable)     The client is idle N Close the connection in seconds (0 Indicates that the connection is not closed )
timeout 0

  tcp-keepalive

    It's like a heartbeat , Check if there is still , Not downtime


# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Take the connection alive from the point of view of network
#    equipment in the middle.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
tcp-keepalive 300

 loglevel 

  The level of logging

# 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)
# warning (only very important / critical messages are logged)
loglevel notice

  logfile

  Log file name and storage path

# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile ""

  syslog-enabled 

  The system log is turned off by default

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no

# Specify the syslog identity.
# syslog-ident redis

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0

  databases 

  redis The default number of databases is 16 individual

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 16

 

Security

 /SECURITY Press enter n seek

  The default password is "" empty , You can set the password manually

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared

  You can set the password manually  

[[email protected]_SW_5748F_1 config]# redis-server /usr/config/redis.conf
3819:C 01 Apr 00:00:56.073 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3819:C 01 Apr 00:00:56.073 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=3819, just started
3819:C 01 Apr 00:00:56.073 # Configuration loaded
[[email protected]_SW_5748F_1 config]# redis-cli -p 6379
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""
127.0.0.1:6379> config get dir
1) "dir"
2) "/usr/config"
127.0.0.1:6379> config set requirepass 123456
OK
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> 
127.0.0.1:6379> config set requirepass ""
OK
127.0.0.1:6379> set key00 value00
OK
127.0.0.1:6379> 

Limit

  The default maximum number of connections is 10000

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000

Redis Elimination strategy :

# maxmemory <bytes>

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#
# 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.
#
# LRU means Least Recently Used
# LFU means Least Frequently Used
#
# Both LRU, LFU and volatile-ttl are implemented using approximated
# randomized algorithms.
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
#
#       At the date of writing these commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
#
# maxmemory-policy noeviction

1.volatile-lru
From a dataset with expiration set , Select the least recently used data ;

2.volatile-ttl
From a dataset with expiration set , Select the data that will be out of date ;

3.volatile-random
From a dataset with expiration set , Choose any data to eliminate ;

4.allkeys-lru
When the memory is not enough to hold the newly written data , Remove the least recently used key;

5.allkeys-random
Choose data elimination from data set ;

6.noeviction( Default )
Ban data obsolescence , That is, when the memory is low , Error will be reported in new write operation .
7.volatile-lfu
From a dataset with expiration set , Pick the least frequently used data and eliminate them ( Be careful lfu and lru The difference between );
8.allkeys-lfu
When the memory is not enough to hold the newly written data , Remove the least frequently used key.

 

  Company

  Cells are not case sensitive , therefore 1GB 1Gb It's all the same

# Note on units: when memory size is needed, it is possible to specify    Description of the unit : When memory size is required , You can specify 
# it in the usual form of 1k 5GB 4M and so forth:      It usually uses 1k 5GB 4M The form such as :

# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.    Cells are not case sensitive , therefore 1GB 1Gb It's all the same .

redis persistence RDB and aof Configuration of

About redis persistence RDB and aof See this article for the configuration of 《Redis Persistence mechanism of 》

原网站

版权声明
本文为[Little moon 6]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270806050929.html