Redis default configuration file redis.conf detailed

Source: Internet
Author: User
Tags syslog password protection strong password

# Redis configuration File Sample # Note on units:when memory size is needed, it's possible to specifiy# it in the usual form of 1k 5GB 4M an D so forth:## 1k + bytes# 1kb = 1024x768 bytes# 1m = 1000000 bytes# 1mb = 1024*1024 bytes# 1g = 10000 00000 bytes# 1GB = 1024*1024*1024 bytes## units is case insensitive so 1GB 1Gb 1gB is all the same.# redis default to Daemon mode, which can be modified by using Yes to enable the daemon # after the daemon is enabled, Redis writes the PID to a pidfile,/var/run/redis.piddaemonize no# when Redis runs as a daemon, Redis defaults to write the PID to the/var/run/redis.pid file, you can specify the Redis listening port by Pidfile specify pidfile/var/run/redis.pid#, the default port is 6379# if you specify 0 port, Indicates that Redis does not listen for TCP connections port 6379# bound host address # You can tie an order to an interface, and if there is no binding, all interfaces will listen to the incoming connection # bind 127.0.0.1# Specify the path for the UNIX socket th At'll 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# Unixsock Etperm 755# When the client is idle for how long to close the connection, if specified as 0, to turn off the function timeout 0# Specify the logging level, Redis supports four levels: Debug, verbose, notice, warning, Default to verbose# DebUG (a lot of information, useful for dev/test) # Verbose (many rarely useful info, but not a mess like the "Debug level") # Notice (moderately verbose, What is want in production probably) # warning (only very important/critical messages is logged) LogLevel verbose# logging mode, which defaults to standard output, and if it is configured to run as a daemon and is configured as standard output, the log will be sent to the/dev/nulllogfile stdout# 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 n  o# Specify the syslog identity.# syslog-ident redis# Specify the syslog facility. Must be USER or between local0-local7.# syslog-facility local0# set the number of databases, the default database is 0, you can use the Select <dbid> command to specify the database on the connection id# Dbid is from 0 to ' databases '-1 of the number databases 16################################ snapshotting ############################### # # # Specifies how long, how many update operations, to synchronize data to the data file, can be multiple condition mates # Save the DB on disk:## save <seconds> <changes>## will Save th E DB If both the given number of seconds and the given# number of write OperatIons against the DB occurred.## the following conditions will synchronize the data: # 900 seconds (15 minutes) with 1 changes # 300 seconds (5 minutes) 10 changes in # 60 seconds with 10,000 changes # Note: You can put all "sa VE "Line commented out, so that the synchronization operation of the Save 1save 10save 60 10000# Specifies whether to compress the data when stored to the local database, the default is Yes,redis with LZF compression, if in order to save CPU time, you can turn off this option, But it can cause the database file to become huge rdbcompression yes# specifies the local database filename, the default value is dump.rdbdbfilename dump.rdb# working directory. # Specify the local database to hold the directory, The file name is specified by the previous Dbfilename configuration Item # # ALSO The Append only file will is created inside this directory.# # Note that only one directory can be specified here, and the file name dir cannot be specified./# ################################ REPLICATION ################################## master-slave replication. Use slaveof to copy a Redis instance from a Redis server. Note that this configuration is limited to the current slave valid # So for example it's possible to configure the slave to save the DB with a# different interval, or to Listen to another ports, and so on.# set the IP address and port of the master service when this machine is a Slav service, and it automatically synchronizes data from Master when Redis starts # slaveof <masterip& Gt <masterport># "Requirepass" Configuration entry for Slav Service Connection Master Password # can specify a password # Masterauth <master-password when the master service has password protection set ># when a slave lost the connection and the master, or when the Replication# is still in progress, the slave can act in both different ways:## 1) if Slave-serve-stale-data is set to ' Yes ' (the Default) the slave will# still reply to client requests, possibly with out of data data, or the# data set may just    Be empty If this is the first synchronization.## 2) if Slave-serve-stale data are set to ' no ' the slave would reply with# An error ' SYNC with Master in progress ' to all the kind of commands#, to INFO and slaveof. #slave-serve-stale-data y es# slaves send PINGs to server in a predefined interval. It ' s possible to change# this interval with the Repl_ping_slave_period option. The default value is 10# seconds.## repl-ping-slave-period 10# The following option sets a timeout for both Bulk transfer I/O timeout and# master data or ping response timeout. The default value is seconds.## It's important to make sure, the this value was greater than the value# specified for R Epl-ping-slave-period otherwise a timeout would be detected# every time there is low traffic between the master and the slave.## repl-timeout 60################################## SECURITY ########### ######################### warning:since Redis is pretty fast a outside user can try up to# 150k passwords per second Aga Inst a good box. This means the should# use a very strong password otherwise it'll be very easy to break.# set the Redis connection password, if the connection password is configured, the client  You need to provide a password via auth <password> command when you connect to Redis, and by default close # requirepass foobared# command renaming.## It's possilbe to change the name of dangerous commands in a shared# environment. For instance the CONFIG command is renamed into something# of hard-to-guess so that it'll be still available for int ernal-use# tools available for general clients.## example:## Rename-command CONFIG b840fc02d524045429941cc15f59e4 1cb7be6c52## It is also possilbe-completely kill a command renaming it into# an empty string:## rename-command CONFIG " "################################### LIMITS ##################################### Set the maximum number of client connections at the same time, the default is unlimited, Redis can open at the same number of client connections for the Redis process can open the maximum number of file descriptors, # If set maxclients 0, indicating no restrictions. When the number of client connections reaches the limit, Redis closes the new connection and returns the max number of clients reached error message to the client # maxclients 128# Don ' t use more memory than the Specifie D amount of bytes.# when the memory limit is reached Redis would try to remove keys with an# EXPIRE set. It'll try to start freeing keys this is going to expire# in little time and preserve keys with a longer time to live.# Redis would also try to remove objects from free lists if possible.## if all this fails, Redis would start to reply with err ORS to commands# that would use more memory, like SET, Lpush, and so on, and would continue# to reply to the most read-only comm ANDs like get.## Warning:maxmemory can is a good idea mainly if you want the use of Redis as a# ' state ' server or cache, not As a real DB. When Redis is used as a real# database the memory usage would grow over the weeks, it'll be obvious if# it's going to us E Too much memory in the long run, and you'll have the time# to upgrade. With MaxMemory after the limit was reached you'll start to get# errors for write operations, and this may even leads to DB I nconsistency.# Specifies the Redis maximum memory limit, Redis will load data into memory at startup, and Redis will attempt to purge expired or expiring key,# when this method is processed, the maximum memory setting is still reached, and no further write operations can be made , but the read operation can still be performed. # Redis New VM mechanism, will store key memory, value will be stored in the Swap area # maxmemory <bytes># maxmemory policy:how Redis will select what to remove WH En maxmemory# is reached? You can select among five behavior:# # VOLATILE-LRU, remove the key with a expire set using an LRU algorithm# Allkey  S-LRU, remove any key accordingly to the LRU algorithm# volatile-random, remove a random key with an expire set# Allkeys->random, remove a random key, any key# Volatile-ttl-and remove the key with the nearest expire time (MI Nor TTL) # noeviction, don ' t expire at all, just return a error on write operations# # note:with all the kind of pol Icies, Redis would return an error in write# operations, when there is not suitable keys for eviction.## at the date of writing this commands are:set setnx setex append# incr decr rpush lpush rpushx Lpushx Lin SERT LSet rpoplpush sadd# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby# zunionstore Zin Terstore hset hsetnx hmset hincrby incrby decrby# getset mset msetnx exec sort## the default is:## maxmemory-policy volatile-lru# LRU and minimal TTL algorithms is not precise algorithms if approximated# algorithms (in order to save Mem Ory), so you can select as well the sample# size to check. For instance for default Redis would check three keys and# pick the one that is used less recently and you can change the SAM PLE size# using the following configuration directive.## maxmemory-samples 3############################## APPEND only MO DE ################################ # Note that can has both the async dumps and the append only file if you# like (y OU has to comment the ' save ' statements above to disable the dumps). # still if append Only mode is enabled Redis would load the data from the# log file at startup ignoring the Dump.rdb file.# specifies if logging after each update operation , Redis, by default, writes data to disk asynchronously and, if not turned on, may cause data loss over a period of time when power is lost. # because the Redis itself synchronizes data files in sync with the save conditions above, some data will only exist in memory for a period of time. The default is no# Important:check the bgrewriteaof to Check what to rewrite the append# log file in background when it gets too big.a Ppendonly no# Specifies the update log file name, the default is appendonly.aof# appendfilename appendonly.aof# the Fsync () call tells the Operating System to a Ctually write data on disk# instead to wait for more data in the output buffer. Some OS will really flush # data on disk, Some other OS would just try to do it asap.# specify an update log condition, total 3 optional values: # No: Indicates that the data cache is Step to disk (FAST) # Always: Call Fsync () manually after each update operation to write data to disk (slow, secure) # Everysec: Indicates synchronization once per second (tradeoff, default) Appendfsync everysec# appendfsync no# When the AOF fsync policy was set to always or everysec, and a background# saving process (a background save or AOF log BAC Kground rewriting) is# performing a lot of I/O against the disk, in some Linux configurations# Redis may block too long on the Fsync () call. Note that there are no fix for# this currently, as even performing fsync in a different thread would block# our synchronous Write (2) call.## in order to mitigate this problem it's possible to use the following option# that'll prevent Fsync () fr Om being called in the main process while a# BGSAVE or bgrewriteaof are in progress.## this means so while another child  is saving the durability of Redis is# the same as "Appendfsync none", which in pratical terms means that it is# possible to Lost up to $ seconds of log in the worst scenario (with the#, default Linux settings). # If You have latency problems tu RN this to "yes". Otherwise Leave it as# "No" that's the safest pick from the point of view of Durability.no-appendfsync-on-rewrite no# Aut Omatic rewrite of the append only file.# Redis are able to automatically rewrite the log file implicitly calling# Bgrewrite AOF when the AOF log size would growth by the specified percentage.# # this is HoW It Works:redis remembers the size of the AOF file after the# latest rewrite (or if no rewrite happened since the Restar T, the size of# the AOF at startup is used). # # This base size was compared to the current size. If the current size is# bigger than the specified percentage, the rewrite is triggered.  also# need to specify a minimal size for the AOF file to being rewritten, this# is useful to avoid rewriting the AOF file Even if the percentage increase# was reached but it was still pretty small.## specify a precentage of zero in order to DISA ble the automatic aof# rewrite feature.auto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mb################# ################# SLOW Log #################################### The Redis SLOW log is a system to LOG queries that Exceede D a specified# execution time.  The execution time does not include the I/O operations# like talking with the client, sending the reply and so forth,# but Just the time needed to actually execute the command (this Is the only# stage of command execution where the thread is blocked and can not serve# other requests in the meantime). # # can configure the slow log with a parameters:one tells Redis# what's the execution time, in microseconds, to exc Eed in order for the# command to get logged, and the other parameter is the length of the# slow log. When a new command is logged the oldest one was removed from the# queue of logged commands.# the following time is Expresse D in microseconds, so 1000000 are equivalent# to one second. Note that a negative number disables the slow log, while# a value of zero forces the logging of every command.slowlog-log- Slower-than 10000# There is the no limit to this length.  Just be aware that it'll consume memory.# you can reclaim memory used by the slow log with Slowlog Reset.slowlog-max-len 1024################################ VIRTUAL MEMORY ################################## warning! Virtual memory is deprecated in Redis 2.4### the use of virtual memory is StronGly discouraged.### warning! Virtual memory is deprecated in Redis 2.4### the use of virtual memory is strongly discouraged.# virtual memory allows Red  IS-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 is taken in memory and the other keys# is swapped into a swap file, similarly to what operating sys TEMs do# with memory pages.# Specifies whether the virtual memory mechanism is enabled, the default value is the no,# VM mechanism to store data paging, and Redis will have less access to the page that is cold data swap to disk, access to more pages from the disk automatically swapped out into memory # Set vm-enabled to Yes and set up the next three VM parameters as needed, you can start the VM vm-enabled no# vm-enabled yes# This is the path of the Redis swap file. As you can guess, swap files# can ' t is shared by different Redis instances, so make sure to use a swap# file for every red is process running. Redis would complain if the# swap file is already in use.## Redis swap files The best storage is SSD (SSD) # Virtual memory file path, default value is/tmp/redis.swap, not multiple Redi s instance Share # * * * * WARNING * * * * If you are using a GKFX hosting the default of putting# the swap file under/tmp is Not secure. Create a dir with Access granted#-to-redis user and configure Redis to create the swap file there.vm-swap-file/tmp/r edis.swap# 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 s# better to leave some margin. For instance specify a amount of ram# that ' s greater or less between, and 80% of your free ram.# all data larger than vm-max-memory into virtual Memory, regardless of how much vm-max-memory is set, all index data is memory stored (REDIS index data is keys) # that is, when Vm-max-memory is set to 0, all value is actually present on disk. The default value for 0vm-max-memory 0# Redis swap files is divided into a number of page, an object can be saved on more than one page, but a page can not be shared by multiple objects, Vm-page-size is to be based on the size of the stored data set. # It is recommended that if you store many small objects, the page size is last set to 32 or 64bytes, if you store large objects, you can use a larger page, and if you are unsure, use the default value Vm-page-size 32# Set the number of pages in a swap file because the page table (a bitmap that indicates that the page is idle or used) is stored in memory and consumes 1byte of memory per 8 pages on disk # Swap space Total capacity 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, which would use a. MB of RAM for The page table.## It ' s BEtter to use the smallest acceptable value for your application,# and the default is large in order to work on most Condit Ions.vm-pages 134217728# Max Number of VMS 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 thre Ads can help with big objects even if they can ' t help with# I/O itself as the physical device may isn't being able to couple WI Th many# reads/writes operations at the same time.# set the number of I/O threads to access the swap file, and finally do not exceed the machine's core number, if set to 0, then all operations on the swap file are serial, May cause a longer delay, the default value is 4vm-max-threads 4############################### advanced CONFIG ############################### # hashes is encoded in a special to (much more memory efficient) when they# has at Max a given numer of elements, and T He biggest element does not# exceed a given threshold. You can configure this limits with the following# configuration directives.# to specify a special hash when exceeding a certain number or maximum element beyond a certain thresholdAlgorithm Hash-max-zipmap-entries 512hash-max-zipmap-value 64# similarly to hashes, small lists is also encoded in a special approach In order# to save a lot of space. The special representation is a used when# you are under the following limits:list-max-ziplist-entries 512LIST-MAX-ZIPL Ist-value 64# Sets has a special encoding in just one case:when a set is composed# of just strings this happens to being in Tegers in Radix in the range# of a signed integers.# the following configuration setting sets the limit in the Siz E of the# set in order special memory saving encoding.set-max-intset-entries 512# similarly to hashes and list s, sorted sets is also specially encoded in# order to save a lot of space. This encoding was only used if the length and# elements of a sorted set is below the following LIMITS:ZSET-MAX-ZIPLIST-E Ntries 128zset-max-ziplist-value 64# Active rehashing uses 1 millisecond every of milliseconds of CPU time in# order to H ELP rehashing the main Redis hash taBLE (the one mapping top-level# keys to values). The hash Table implementation Redis uses (see DICT.C) # Performs a lazy rehashing:the more operation your run into a hash table# that's rhashing, the more rehashing ' steps ' is performed, so if the# server is idle the rehashing is never comple Te and some more memory are used# by the hash table.# # The default was to use this millisecond ten times every second in Ord  Er to# active rehashing the main dictionaries, freeing memory when possible.## if unsure:# use "Activerehashing no" if you  The latency requirements and it is# not a good thing in your environment the Redis can reply form time to time# Queries with 2 milliseconds delay.# Specifies whether to activate reset hash, the default is to turn on Activerehashing yes################################## includes # # # ################################# Specifies that other configuration files are included, and that you can use the same profile between 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

Redis default configuration file redis.conf 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.