REDIS.CONF Configuration Detailed

Source: Internet
Author: User
Tags allkeys syslog shared hosting strong password

# Redis configuration file

# When you need to configure memory size in the configuration, you can use 1k, 5GB, 4M and other similar formats, which are converted in the following ways (case insensitive)
#
# 1k = bytes
# 1kb = 1024x768 bytes
# 1m = 1000000 bytes
# 1MB = 1024*1024 bytes
# 1g = 1000000000 bytes
# 1GB = 1024*1024*1024 bytes
#
# memory configuration case is the same. For example, 1GB 1Gb 1GB 1gB

# Daemonize No by default, Redis is not running in the background, and if it needs to run in the background, change the value of the item to Yes
Daemonize Yes

# when Redis runs in the background, Redis defaults to placing the PID file in/var/run/redis.pid, which you can configure to a different address.
# when running multiple Redis services, you need to specify a different PID file and port
Pidfile/var/run/redis.pid

# Specify the port on which Redis runs, default is 6379
Port 6379

# Specifies that Redis receives only requests from that IP address, and if not set, all requests are processed,
# It is best to set this item in a production environment
# bind 127.0.0.1

# Specify the path for the UNIX sockets that would be used to listen for
# Incoming connections. There is no default, so Redis would not listen
# on a UNIX socket if not specified.
#
# Unixsocket/tmp/redis.sock
# unixsocketperm 755

# Sets the time-out period in seconds for client connections. When the client has not issued any instructions during this time, the connection is closed
# 0 is to turn off this setting
Timeout 0

# Specify logging Levels
# Redis supports a total of four levels: Debug, verbose, notice, warning, default = verbose
# DebugRecord a lot of information for development and testing
# VarboseUseful information, not as much as debug will record
# NoticeCommon verbose, often used in production environments
# warningOnly very important or critical information is recorded in the log
LogLevel Debug

# Configure log file address
# default value is stdout, standard output, if background mode is 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

################################ Snapshot #################################
#
# Save data to disk in the following format:
#
# Save <seconds> <changes>
#
# indicates how many times the update operation will synchronize the data to the data file RDB.
# equivalent to conditional trigger fetch snapshot, this can be combined with multiple conditions
#
# For example settings in the default profile, three conditions are set
#
# Save 900 1 900 seconds at least 1 keys have been changed
# Save 300 10 300 seconds at least 300 keys have been changed
# Save 60 10000 60 seconds at least 10,000 keys have been changed

Save 900 1
Save 300 10
Save 60 10000

# Whether to compress data when storing to a local database (persisted to an RDB file), by default Yes
Rdbcompression Yes


# Local Persistent database file name, default value is Dump.rdb
Dbfilename Dump.rdb

# working Directory
#
# The path to the file placement of the database mirroring backup.
# The path here is configured separately from the file name because Redis writes the state of the current database to a temporary file when it is being backed up, and when the backup is complete,
# Replace the temporary file with the file specified above, and the temporary file and the backup file configured above will be placed in the specified path.
#
# aof files will also be stored under this directory
#
# Note that a directory, not a file, must be developed here
Dir./

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

# Master-slave replication. Set the database from the database for the other database.
# Set the IP address and port of the master service when this machine is a Slav service, and it will automatically synchronize data from master when Redis boots
#
# slaveof <masterip> <masterport>

# When the master service is password protected (password set with Requirepass)
# Slav The password of the service connection master
#
# Masterauth <master-password>


# When a connection is lost from the library to the host or the replication is in progress, there are two modes of operation from the hangar:
#
# 1) If Slave-serve-stale-data is set to Yes (the default setting), the request from the corresponding client will continue from the library
#
# 2) If slave-serve-stale-data refers to no, any request outside the info and SLAVOF commands will return a
# error "SYNC with Master in progress"
#
Slave-serve-stale-data Yes

# from the library, the pings is sent to the main library at a time interval. This interval can be set by Repl-ping-slave-period, which is 10 seconds by default
#
# Repl-ping-slave-period 10

# Repl-timeout Set the main library bulk data transfer time or ping reply interval, the default value is 60 seconds
# Make sure Repl-timeout is greater than repl-ping-slave-period
# Repl-timeout 60

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

# Set the password to be used before any other specified client connection is made.
# Warning: Because the Redis speed is quite fast, under a better server, an external user can make a 150K password attempt in a second, which means you need to specify a very strong password to prevent brute force.
#
# Requirepass Foobared

# command renamed.
#
# in a shared environment, you can rename a relatively dangerous command. For example, the name of Config is a character that is not easy to guess.
#
For example
#
# Rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# If you want to delete a command, simply rename it to a null character "", as follows:
#
# Rename-command CONFIG ""

################################### constraint ####################################

# Set the maximum number of client connections at the same time, the default is no limit, Redis can open the number of client connections for the Redis process can open the maximum number of file descriptors,
# If you set maxclients 0, it means no limit.
# when the number of client connections reaches the limit, Redis closes the new connection and returns max number of clients reached error message to the client
#
# maxclients 128

# Specifies the Redis maximum memory limit, which will be loaded into memory by Redis at boot time, and Redis will attempt to clear the expired or expiring key first when it reaches the maximum memory.
# Redis also removes empty list objects
#
# When this method is processed, the maximum memory setting is still reached and the write operation is no longer available, but the read operation is still possible
#
Note: Redis's new VM mechanism will store the key in memory, and value will be stored in the swap area.
#
# MaxMemory's settings are more appropriate for using Redis as a memcached-like cache than for a real db.
# when using Redis as a real database, memory usage will be a big expense
# maxmemory <bytes>

# What data does Redis choose to delete when the memory reaches its maximum value? There are five different ways to choose
#
# VOLATILE-LRU using the LRU algorithm to remove key (LRU: Recently used Least recently used) with set expiration time
# ALLKEYS-LRU using the LRU algorithm to remove any key
# volatile-random, removing the random key set over expiration time
# allkeys->random, remove a random key, any key
# Volatile-ttl Remove Expiring key (minor TTL)
# noeviction not remove any can, just return a write error
#
Note: For the above policy, if no appropriate key can be removed, 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), optionally you can choose the sample size to detect.
# redis Default Gray Select 3 samples for detection, you can set through Maxmemory-samples
#
# Maxmemory-samples 3

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

# By default, Redis backs up database mirroring to disk asynchronously in the background, but the backup is very time-consuming and cannot be backed up very often, resulting in a wide range of data loss if such conditions as power cuts, unplug, etc. occur.
# so Redis offers another more efficient way to database backup and disaster recovery.
# when append only mode is turned on, Redis appends every write request received to the Appendonly.aof file, and when Redis restarts, the previous state is recovered from the file.
# But this will cause the appendonly.aof file to be too large, so Redis also supports the BGREWRITEAOF instructions and re-organizes the appendonly.aof.
# You can open asynchronous dumps and AOF at the same time

AppendOnly No

# aof file name (default: "Appendonly.aof")
# Appendfilename Appendonly.aof


# Redis supports three different policies for synchronizing aof files:
#
# No: Do not synchronize, the system to operate. Faster.
# always:always indicates that each write operation is synchronized. Slow, safest.
# Everysec: Indicates that the write operation is cumulative and synchronized once per second. Compromise.
#
# default is "Everysec", according to speed and security compromise this is the best.
# If you want Redis to run more efficiently, you can set it to "no" and let the OS decide when to execute
# or on the contrary to make the data more secure you can also set it to "always"
#
# use "Everysec" if you're not sure.

# Appendfsync Always
Appendfsync everysec
# Appendfsync No

# When the AOF policy is set to always or EVERYSEC, the background processing process (background save or AOF log rewrite) performs a number of I/O operations
# in some Linux configurations, too long Fsync () requests are blocked. Note that there is now no fix, even if fsync is processing on another thread
#
# to mitigate this problem, you can set the following parameter No-appendfsync-on-rewrite
#
# This means and another child are saving the durability of Redis is
# the same as "Appendfsync none", that's in pratical terms means that it's
# possible to lost up to $ seconds of log in the worst scenario (with the
# default Linux settings).
#
# If You have latency problems turn the "yes". Otherwise Leave it as
# "No" that's the safest pick from the point of view of durability.
No-appendfsync-on-rewrite No

# Automatic Rewrite of the append only file.
# AOF Auto Rewrite
# Redis can call bgrewriteaof to rewrite log files when the AoF file grows to a certain size
#
# It works like this: Redis remembers the size of the file after the last log (if it hasn't been rewritten since the boot, the day size is determined at boot time)
#
# The base size is compared with the current size. If the size is now larger than the base size, the override feature will start
# at the same time you need to specify a minimum size for aof overrides, which prevents the file from being rewritten even though it is small but grows very large aof
# 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 specific execution time. Execution time does not include I/O calculations such as connecting clients, returning results, etc., just the command execution time
#
# Slow log can be set by two parameters: one is to tell Redis how much time is logged for the parameters Slowlog-log-slower-than (subtle),
# The other is the length of the slow log. The oldest command is removed from the queue when a new command is recorded


# The time below is in subtle micro-units, so 1000000 stands for one minute.
# Note A negative number will turn off slow logging, and setting to 0 will force each command to be logged
Slowlog-log-slower-than 10000


# There is no limit to the log length, just be aware that it consumes memory
# memory consumed by slow logs can be reclaimed by 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 datasets in memory.
# in order to do so very used keys is taken in memory and the other keys
# is 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 is running. Redis would complain if the
# swap file is already on use.
#
# The best kind of storage for the Redis swap file (so ' 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
#-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 would be swapped on disk *if* possible, which
# is, if there are still enough contiguous space in the swap file.
#
# with vm-max-memory 0 The system would swap everything it can. Not a good
# default, just specify the max amount of RAM can in bytes, but it ' s
# better to leave some margin. For instance specify an amount of RAM
# That's more or less between, and 80% of your free RAM.
Vm-max-memory 0

# Redis swap files are 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 was too big, small objects swapped out on disk would waste
# A lot of space. If You page is too small, there are less space in the swap
# file (assuming configured the same number of total swap file pages).
#
# If You use a lot of small objects, use a page size of up or bytes.
# If You use a lot of the 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) was taken in memory,
# every 8 pages on disk would 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 would
# Use a 4 GB swap file, that would use the MB of RAM for the page table.
#
# It ' s better to use the smallest acceptable value for your application,
# But the default was 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 is 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
# I/O itself as the physical device may is 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 critical,
# hash will be stored in a special coding way (greatly reduced memory usage), where you can set both thresholds
# Redis hash corresponds to value inside is actually a hashmap, actually there will be 2 different implementations,
# This hash of the members relatively young Redis in order to save memory will be similar to a one-dimensional array of compact storage, without the use of real hashmap structure, the corresponding value Redisobject encoding is Zipmap,
# when the number of members increases, it automatically turns into a real hashmap, at which time encoding is HT.
Hash-max-zipmap-entries 512
Hash-max-zipmap-value 64

# The list data type how many nodes below will use a compact storage format for pointers.
# The list data type node value size is less than how many bytes are in compact storage format.
List-max-ziplist-entries 512
List-max-ziplist-value 64

# Set data type internal data if all are numeric, and how many nodes are included the following are stored in a compact format.
Set-max-intset-entries 512

# Zsort data type How many nodes below will use a compact storage format for pointers.
# Zsort data Type node value size is less than how many bytes are in a compact storage format.
Zset-max-ziplist-entries 128
Zset-max-ziplist-value 64


# Redis will use 1 milliseconds of CPU time every 100 milliseconds to re-hash the Redis hash table, which can reduce the use of memory
#
# When you have a very strict real-time requirement in your usage scenario, you cannot accept Redis's occasional 2 millisecond delay for requests, and configure this as No.
#
# If you don't have such strict real-time requirements, you can set it to Yes so that you can free up memory as quickly as possible
activerehashing Yes

################################## includes ###################################

# Specifies that other profiles can be used to use the same configuration file across multiple Redis instances on the same host, while each instance has its own specific configuration file

# include/path/to/local.conf
# include/path/to/other.conf


Reference recommendation:

redis.conf Configuration Parameters Detailed

Redis System Management (classification Management)

Redis.conf parameter Description (Chinese and English)

A detailed Redis profile (Chinese)

Why use Redis and its product positioning

Redis memory usage optimization and storage

Redis replication and scalable cluster setup

Redis Learning Manual (Master-slave replication)

Redis design and implementation (recommended)

REDIS.CONF Configuration Detailed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.