Description of the redis.conf configuration file

# Redis configuration file

# When the memory size needs to be configured in the configuration, 1k, 5GB, 4M and other similar formats can be used. The conversion method is as follows (case insensitive)
#
# 1k =>
1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb =>
1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024
bytes
#
# The case of memory configuration is the same. For example, 1gb 1Gb 1GB 1gB

# daemonize no By default, redis does not run in the background, if you need to run in the background, change the value of this item to yes
daemonize
yes

# 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.
#When
running multiple redis services, you need to specify different pid files and ports
pidfile /var/run/redis.pid

# Specify the port where redis runs, the default is 6379
port 6379

# Specify that redis only receives requests from this IP address. If it is not set, all requests will be processed.
# It is best to set this item in a production environment.
# bind
127.0.0.1

# Specify the path for the unix socket that will be used to listen for
#
incoming connections. There is no default, so Redis will not listen
# on a
unix socket when not specified.
#
# unixsocket /tmp/redis.sock
#
unixsocketperm 755

# Set the timeout for client connection, in seconds. When the client does not issue any instructions within this period, then closing the connection
# 0 is to close this setting
timeout
0

# Specify the logging level
# Redis supports a total of four levels: debug, verbose, notice, warning, the default is verbose
#
debug records a lot of information for development and testing
# varbose useful information, not as much as debug records
#
notice Ordinary verbose, often used in production environments
# warning Only very important or serious information will be recorded in the log
loglevel
debug

# Configure the log file address
# The default value is stdout, standard output, if the background mode will output to /dev/null
#logfile
stdout
logfile /var/log/redis/redis.log

# 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

# Number of available databases
# The default value is 16, the default database is 0, and the database range is between 0-(database-1)
databases 16

################################ Snapshots
################## #################
#
# Save the data to the disk, the format is as follows:
#
# save
<seconds> <changes>
#
#Indicate
how many update operations in a long time, The data is synchronized to the data file rdb.
# Equivalent to a conditional trigger to capture a snapshot, this can be combined with multiple conditions
#
#
For example, the settings in the default configuration file, three conditions are set
#
# save 900 1 At least 1 key has been changed within 900 seconds
# save 300
10 At least 300 keys were changed in 300 seconds
# save 60 10000 At least 10000 keys were changed in 60 seconds

save 900 1
save 300 10
save 60 10000

# Whether to compress the data when storing to the local database (persisting to the rdb file), the default is yes
rdbcompression yes

# Local persistent database file name, the default value is dump.rdb
dbfilename dump.rdb

# Working Directory
#
# Path where the files for database mirroring backups are placed.
#The
path and file name here should be configured separately because when redis is backing up, it will first write the current database state to a temporary file, and when the backup is complete,
#replace
the temporary file with the one specified above file, and the temporary file here and the backup file configured above will be placed in this specified path.
#
#
AOF files will also be stored in this directory
#
# Note that a directory must be specified here instead of a file
dir ./

################################# Copy
################ #################


# Master-slave replication. Set the database as the slave database of other databases.
#Set the IP address and port of the master service when the machine is the slave service. When Redis starts, it will automatically synchronize data from the master
#
# slaveof
<masterip> <masterport>

# When password protection is set for the master service (password made with requirepass)
# The password for the slav service to connect to the master
#
#
masterauth <master-password>


# When the slave library loses connection with the host or the replication is in progress, the slave library has two operation modes:
#
# 1)
If slave-serve-stale-data is set to yes (the default setting), the slave library will continue the request of the corresponding client
#
# 2)
If slave-serve-stale-data is specified as no, any request other than out INFO and SLAVOF commands will return a
# error "SYNC with
master in progress"
#
slave-serve-stale-data yes

# The slave library will send PINGs to the master library at a time interval. This time interval can be set by repl-ping-slave-period, the default is 10 seconds
#
#
repl-ping-slave-period 10

# repl-timeout Set the main database batch data transmission time or ping reply time interval, the default value is 60 seconds
#
Make sure that repl-timeout is greater than repl-ping-slave-period
# repl-timeout 60

###################################Safety
################ ####################

# Set the password that the client needs to use after connecting before making any other assignments.
#WARNING
: Because redis is quite fast, under a good server, an external user can make 150K password attempts per second, which means you need to specify very, very strong passwords to prevent brute force cracking
#
#
requirepass foobared

# Command renaming.
#
# Relatively dangerous commands can be renamed in a shared environment. For example, renaming CONFIG to a character that is not easy to guess.
# #Example :
# # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 # #If you want to delete a command , just rename it to an empty character "", as follows: # # rename-command CONFIG ""








################################### Constraints
############## ###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

# Set the maximum number of client connections at the same time. The default is unlimited. 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 0, it means there is no limit.
# When the number of client connections reaches the limit, Redis will close the new connection and return the max number of clients
reached error message to the client
#
# maxclients 128

# Specify the maximum memory limit of Redis. Redis will load data into memory when it starts up. After reaching the maximum memory, Redis will first try to clear the keys that have expired or are about to expire
#
Redis will also remove empty list objects
#
#When
this method is processed, the maximum memory setting is still reached, and the write operation will no longer be possible, but the read operation can still be performed
#
#Note
: The new vm mechanism of Redis will store the Key in the memory and the Value in the swap area
#
#
The setting of maxmemory is more suitable for using redis as a cache similar to memcached, not as a real DB.
#
When using Redis as a real database, memory usage will be a big overhead
# maxmemory <bytes>

# When the memory reaches the maximum value, which data will Redis choose to delete? There are five ways to choose from
#
# volatile-lru ->
use LRU algorithm to remove the key with expired time (LRU: Least Recently Used)
# allkeys-lru ->
use LRU algorithm to remove any key
# volatile- random -> remove a random key with an expired time
#
allkeys->random -> remove a random key, any key
# volatile-ttl ->
remove the key that is about to expire (minor TTL)
# noeviction -> do not remove any Yes, just return a write error
. #
#
Note: For the above strategy, if there is no suitable key to remove, Redis will return an error when writing.
#
# Write commands include: 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
#
# Default is:
#
#
maxmemory-policy volatile-lru

# LRU and minimal TTL algorithms are not accurate algorithms, but relatively accurate algorithms (in order to save memory), you can choose the sample size for detection at will.
#
Redis default gray selects 3 samples for detection, you can set it through maxmemory-samples
#
# maxmemory-samples
3

############################## AOF ###############################


#By
default, redis will asynchronously back up the database image to disk in the background, but the backup is very time-consuming, and the backup cannot be very frequent. A wide range of data is lost.
#So
redis provides another more efficient way of database backup and disaster recovery.
#
After the append only mode is enabled, redis will append each write request received to the appendonly.aof file. When redis is restarted, the previous state will be restored from the file.
#But
this will cause the appendonly.aof file to be too large, so redis also supports the BGREWRITEAOF instruction to rearrange appendonly.aof.
#You
can enable asynchronous dumps and AOF at the same time

appendonly no

# AOF file name (default: "appendonly.aof")
# appendfilename appendonly.aof

# Redis supports three strategies for synchronizing AOF files:
#
# no: No synchronization, the system will operate. Faster.
# always:
always means to synchronize every time there is a write operation. Slow, Safest.
# everysec: means to write operations Accumulate, sync every second.
Compromise.
#
# The default is "everysec", which is the best compromise between speed and security.
#If
you want Redis to run more efficiently, you can also set it to "no", let the operating system decide when to execute it
#Or
conversely want to make data more secure you can also set it to "always"
# #If
you are not sure, just Use "everysec".

# appendfsync always
appendfsync everysec
# appendfsync no

# When the AOF policy is set to always or everysec, the background processing process (background saving or AOF log rewriting) will perform a large number of I/O operations
#
In some Linux configurations, it will prevent excessively long fsync() requests. Note that there is no fix now, even if the fsync is processed in another thread
#
#
To slow down this problem, you can set the following parameter no-appendfsync-on-rewrite
#
# This means that while
another child is saving the durability of Redis is
# the same as "appendfsync
none", that in pratical terms means that it is
# possible to lost up to 30
seconds of log in the worst scenario (with the
# default Linux
settings).
#
# If you have latency problems turn this to "yes ". Otherwise
leave it as
# "no" that is the safest pick from the point of view of
durability.
no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
# AOF automatic rewrite
#
When the AOF file grows to a certain size, Redis can call BGREWRITEAOF to rewrite the log file
#
#
It works like this: Redis will remember the last time The size of the file after the log (if it has not been rewritten since booting, the size will be determined when booting)
#
#The
base size will be compared with the current size. If the current size is larger than the base size by a specified percentage, the rewriting function will start
. #At the
same time, you need to specify a minimum size for AOF rewriting. This is used to prevent the AOF file from being rewritten even if the file is small but the growth rate is large. Case
# Set percentage
to 0 to turn off this feature

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

################################## SLOW LOG
###################################

# Redis Slow Log records commands that exceed a certain execution time. The execution time does not include I/O calculations such as connecting to the client, returning results, etc., but only the command execution time
#
#
You can set the slow log through two parameters: one is the parameter slowlog-log-slower- that tells Redis how much time is recorded for execution. than (subtle),
#The
other is the length of the slow log. The oldest command will be removed from the queue when a new command is recorded

# The times below are in micro-units, so 1000000 represents one minute.
#Note that specifying
a negative number will turn off the slow log, while setting it to 0 will force each command to log
slowlog-log-slower-than 10000

# There is no limit to the length of the log, just be aware that it will consume memory # The memory consumed by the slow log
can be reclaimed through SLOWLOG RESET slowlog-max-len 1024

################################ VM ###############################

### WARNING! Virtual Memory is deprecated in Redis 2.4
### The use of
Virtual Memory is strongly discouraged.

# Virtual Memory allows Redis to work with datasets bigger than the
actual
# amount of RAM needed to hold the whole dataset in memory.
# In
order to do so very used keys are taken in memory while the other keys
# are
swapped into a swap file, similarly to what operating systems do
# with
memory pages.
#
# To enable VM just set 'vm-enabled' to yes, and set the
following three
# VM parameters accordingly to your needs.

vm-enabled no
# vm-enabled yes

# This is the path of the Redis swap file. As you can guess, swap
files
# can't be shared by different Redis instances, so make sure to use a
swap
# file for every redis process you are running. Redis will complain if
the
# swap file is already in use.
#
# The best kind of storage for the
Redis swap file (that's accessed at random)
# is a Solid State Disk
(SSD).
#
# *** WARNING *** if you are using a shared hosting the default
of putting
# the swap file under /tmp is not secure. Create a dir with access
granted
# only to Redis user and configure Redis to create the swap file
there.
vm-swap-file /tmp/redis.swap

# vm-max-memory configures the VM to use at max the specified amount
of
# RAM. Everything that deos not fit will be swapped on disk *if* possible,
that
# is, if there is still enough contiguous space in the swap
file.
#
# With vm-max-memory 0 the system will swap everything it can. Not
a good
# default, just specify the max amount of RAM you can in bytes, but
it's
# better to leave some margin. For instance specify an amount of
RAM
# that's more or less between 60 and 80% of your free
RAM.
vm-max-memory 0

# Redis swap files is split into pages. An object can be saved using
multiple
# contiguous pages, but pages can't be shared between different
objects.
# So if your page is too big, small objects swapped out on disk will
waste
# a lot of space. If you page is too small, there is less space in the
swap
# file (assuming you configured the same number of total swap file
pages).
#
# If you use a lot of small objects, use a page size of 64 or 32
bytes.
# If you use a lot of big objects, use a bigger page size.
# If
unsure, use the default :)
vm-page-size 32

# Number of total memory pages in the swap file.
# Given that the page
table (a bitmap of free/used pages) is taken in memory,
# every 8 pages on
disk will consume 1 byte of RAM.
#
# The total swap size is vm-page-size *
vm-pages
#
# With the default of 32-bytes memory pages and 134217728 pages
Redis will
# use a 4 GB swap file, that will use 16 MB of RAM for the page
table.
#
# It's better to use the smallest acceptable value for your
application,
# but the default is large in order to work in most
conditions.
vm-pages 134217728

# Max number of VM I/O threads running at the same time.
# This threads
are used to read/write data from/to swap file, since they
# also encode and
decode objects from disk to memory or the reverse, a bigger
# number of
threads can help with big objects even if they can't help with
# I/O itself
as the physical device may not be able to couple with many
# reads/writes
operations at the same time.
#
# The special value of 0 turn off threaded
I/O and enables the blocking
# Virtual Memory
implementation.
vm-max-threads 4

############################### ADVANCED CONFIG
###############################

# When the hash contains more than the specified number of elements and the largest element does not exceed the threshold,
#
hash will be stored in a special encoding method (greatly reducing memory usage), and these two thresholds can be set here
# Redis
Hash corresponds to The value inside is actually a HashMap. In fact, there will be two different implementations here.
#When
the members of this Hash are relatively small, Redis will use a one-dimensional array-like method for compact storage in order to save memory, instead of using the real HashMap structure. The corresponding The encoding of value
redisObject is zipmap, #When the
number
of members increases, it will be automatically converted to a real HashMap, and the encoding is ht.
hash-max-zipmap-entries
512
hash-max-zipmap-value 64

# The number of nodes in the list data type will be in a compact storage format without pointers.
#
The size of the node value of the list data type is less than how many bytes will use the compact storage format.
list-max-ziplist-entries
512
list-max-ziplist-value 64

# Set data type If the internal data is all numeric, and the number of nodes below it is contained, it will be stored in a compact format.
set-max-intset-entries
512

# The number of nodes below the zsort data type will use a compact storage format without pointers.
#
zsort data type node value size is less than how many bytes will use compact storage format.
zset-max-ziplist-entries
128
zset-max-ziplist-value 64

# Redis will use 1 millisecond of CPU time to re-hash the redis hash table every 100 milliseconds, which can reduce memory usage
#
#
When your usage scenario has very strict real-time requirements, Redis cannot be accepted To have a 2ms delay to requests from time to time, configure this to no.
#
#If
there is no such strict real-time requirements, it can be set to yes, so that the memory can be released as quickly as possible
activerehashing yes

################################## INCLUDES
###################################

# Specify to include other configuration files, you can use the same configuration file between multiple Redis instances on the same host, and each instance has its own specific configuration file
#
include /path/to/local.conf
# include /path /to/other.conf

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324652865&siteId=291194637