Redis configuration file redis.conf parameter description

Source: Internet
Author: User
Tags shared hosting strong password redis server

# By default, Redis does not run as a daemon. Use ' yes ' if you need it.# Note that Redis would write a PID file in/var/run/redis.pid when daemonized. #Redis默认不是以守护进程的方式运 Line, which can be modified by this configuration item, using Yes to enable the daemon daemonize No# when running daemonized, Redis writes a PID file in/var/run/redis.pid by# default. You can specify a custom PID file locations here. #当 Redis runs as a daemon, redis defaults to placing PID files on/var/run/redis.pid# configurable to other addresses when running multiple Redis service, you need to specify a different PID file and port Pidfile/var/run/redis.pid# Accept connections on the specified port, default was 6379.# If Port 0 is specified Redis won't listen on a TCP socket . #端口 Port 6379# If you want your can bind a single interface if the BIND option was not# specified all the interfaces would listen for Inc oming connections. #指定Redis可接收请求的IP地址, do not set will process all requests, recommend setting in production environment # bind 127.0.0.1# Close the connection after a client was idle for N seconds (0 to disable) #客户端连接的超时时间, in seconds, after timeout will close the connection Timeout 0# Set Server verbosity to ' debug ' # It can is one of:# debug (a lot of information, useful for development/testing) # Verbos E (many rarely useful info, but not a mess like the "Debug level") # Notice (moderately verbose, what are want in production Probably) # warning (only very important/critical messages is logged) #日志记录等级, 4 selectable values loglevel Notice# Specify the log file name. Also ' stdout ' can is used to force# Redis-Log on the standard output. Note that if the standard# output for logging but daemonize, logs'll be sent to/dev/null# configuration log file address, default print on the Command Line Terminal window , can also be set to/dev/null masking log, logfile stdout# Set the number of databases. The default database is DB 0, you can select# a different one in a per-connection basis using Select where# dbid is a numb Er between 0 and ' databases ' -1# set the number of databases, you can use the SELECT command to switch the database. databases# Save the DB on disk:## save## would Save the DB if both the given number of seconds and the given# number of write Operations against the DB occurred.## in the example below the behaviour would be is to save:# after the SEC (min) if At least 1 key changed# after the SEC (5 min) If at least the keys changed# after ten sec if at least 10000 keys changed # # Note:you can disable saving at all commenting all the "save" lines. #设置 how often Redis does database mirroring. The strategy of saving data to disk #900 1 keys changes within seconds, 10 keys change within #30 seconds and 10,000 keys change within #60 seconds Save 1 Save Save 10000# Compress String objects using LZF when dump. RDB databases?# for default this ' s set to ' yes ' as it's almost always a win . # If you want to save some CPU in the saving child set it to ' No ' but# the dataset would likely be bigger If you have comp Ressible values or keys #在进行镜像备份时, whether to compress rdbcompression Yes# The filename where to dump the db# image backup file dbfilename Dump.rdb# The working directory.## the DB would be written inside this directory, with the filename specified# above using the ' DBF Ilename ' Configuration directive.# # Also The Append only File would be a created inside this directory.# # Note so you mus T specify a directory here, not a file name. #数据库镜像备份的文件放置的路径 # The path is configured separately from the file name because the state of the current database is first written to a temporary file # when the backup is completed. Then 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 # The default value is. dir/var/lib/redis/# Master-slave replication. Use slaveof to make a Redis instance a copy of# another Redis server. Note that the configuration was local to the slave# so for example it was possible to configure the slave to save the DB wit h a# different interval, or to listen to another ports, and so on. #设置该数据库为其他数据库的从数据库 #slaveof <masterip> <masterpor t> set the IP and port of the primary service when this machine is from service # slaveof# If The master is password protected (using the "Requirepass" configuration# directive below) It's possible to tell the Slave to authenticate before# starting the replication synchronization process, otherwise the master will# refuse the Slav E request. #指定与主数据库连接时需要的密码验证 #masterauth <master-password> When this machine is from service, set the connection password for the master service # Masterauth # when a slave lost the connection and the master, or when the replication# are 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#    sti ll reply to client requests, possibly with out of data data, or the#    data set may just is empty if this is the first synchronization.## 2) if Slave-serve-stale data are set to ' no ' the slave would reply with#    a N Error "SYNC with Master in progress" to all the kind of commands#    but to INFO and slaveof. #当slave丢失与ma Ster connection, or slave is still in sync with master (not consistent with master) #slave可有两种方式来响应客户端请求: #1) If Slave-serve-stale-data is set to ' Yes ' (default), Slave will still respond to the client request, there may be a problem # # # #) If Slave-serve-stale-data is set to ' no ', slave will return "SYNC with the Master in progress" error message, but info Except for the slaveof command. Slave-serve-stale-data yes # Require clients to issue AUTH before processing any other# commands.  this might is 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 compat Ibility and because most# people do not need auth (e.g. they run their own servers). # # warning:since Redis is Prett Y fast an outside user can try up to# 150k passwords per second against a good box. This means, should# use a very strong password otherwise it'll be very easy to break. #设置客户端连接后进行任何其他指定前需要使用的密码 #r Edis speed is quite fast, an external user in a second to 150K password attempts, need to specify a strong password to prevent brute force # Requirepass foobared# Set The max number of connected clients at the same time. By default there# is no limit, and it's up to the number of file descriptors the Redis process# are able to open. The special value ' 0 ' means no limits.# Once the limit is reached Redis would close all the new connections sending# an err or ' max number of clients reached '. #限制同时连接的客户数量. #当连接数超过这个值时, Redis will no longer receive additional connection requests and will receive an error message when the client tries to connect # maxclients # Don ' t use more memory than the specified amount of bytes.# when the memory limit is reached Redis would try to Remo ve keys# accordingly to the eviction policy selected (see Maxmemmory-policy). # # If Redis can ' t remove keys according to th e policy, or if the policy is# set to ' noeviction ', Redis would start to reply with errors to commands# that would use more Memory, like SET, Lpush, and so on, and would continue# to reply to read-only commands like get.## this option is usually Useful when using the Redis as a LRU cache, or to set# a hard memory limit for a instance (using the ' noeviction ' policy). # # warning:if You has slaves attached to a instance with MaxMemory on,# the size of the output buffers needed to feed th E Slaves is subtracted# from the used memory count, so this network Problems/resyncs will# not trigger a loop where key S was evicted, and in turn the output# buffer of slaves was full with DELs of keys evicted triggering the deletion# of more Keys, and so forth UntiL The database is completely emptied.## in short ... if you had slaves attached it is suggested so you set a lower# Limi T for MaxMemory So, there is some free RAM on the system for slave# output buffers (it is not needed if the Poli Cy is ' Noeviction '). #设置redis能够使用的最大内存. #达到最大内存设置后, Redis will first attempt to clear the expired or expiring key (key that sets the expire information) #在删除时, delete by expiration time, the first key to be expired will be deleted first # if expired or expiring key is erased, The set operation is still performed, then the error # will be returned # at this point Redis will no longer receive write requests, only receive get requests. #maxmemory的设置比较适合于把redis当作于类似memcached Cache to use # maxmemory <bytes>  # By default Redis asynchronously dumps the dataset on disk. If you can live# with the idea that the latest records would be be lost if something like a crash# happens this is the Preferr Ed to run Redis. If instead a lot# about your data and don ' t want to that a single record can get lost you should# enable the AppE nd only mode:when This mode is enabled Redis would append# every write operation received in the file appendonly.aof. This file will# is read on startup in order to rebuild the full dataset in memory.## Note so can have both the async Dumps and the append only file if you# like (you have to comment the "save" statements above to disable the dumps). # Stil L If append only mode is enabled Redis would load the data from the# log file at startup ignoring the Dump.rdb file.## impo Rtant:check the bgrewriteaof to Check what rewrite the append# log file in background when it gets too big. #redis   The default is to asynchronously back up the database image to disk in the background after each update operation, but the backup is time consuming and the backup is not too frequent #redis the synchronization data file isSave condition to synchronize # if there are conditions such as power cuts, unplug, and so on, it will result in a wide range of data loss # so Redis offers another more efficient way to database backup and disaster recovery # after opening append only mode, Redis Appending each write request to the Appendonly.aof file #redis the previous state from the file when it restarts. #但可能会造成 appendonly.aof file is too large, Redis supports bgrewriteaof instructions, and appendonly.aof re-organizes appendonly No# The name of the Append only file (default: "Appendonly.aof") # #更新日志文件名, the default value is Appendonly.aof # appendfilename Appendonly.aof # the Fsync () call tells the Operating System to actually write data on disk# instead to wait for more data in the O Utput buffer. Some OS would really flush # data on disk, Some other OS would just try to do it asap.## Redis supports three different modes:## No:don ' t fsync, just let the OS flush the data when it wants. faster.# Always:fsync after every write to the append only log. Slow, safest.# Everysec:fsync only if one second passed since the last fsync. compromise.## The default is "Everysec", that ' s usually, the right compromise between# speed and data safety. It's up to understand if you can relax this to# "no" so would'll let the operating system flush the output Buffe R when# It wants, for better performances (and if you can live with the idea of# some data loss consider the default Persi Stence mode that's snapshotting), # or on the contrary, use "always" that's very slow but a bit safer than# everysec.## If Unsure, use "everysec". #设置对 appendonly.aof files for synchronizationThe frequency #always indicates that each write operation is synchronized, and Everysec indicates that the write operation is cumulative and synchronized once per second. #no表示等操作系统进行数据缓存同步到磁盘, synchronization is performed, everysec means that the write operation is cumulative and synchronized once per second # Appendfsync always Appendfsync everysec # Appendfsync No# Virtual Memory allows Redis to work with datasets bigger than the actual# amount of RAM needed to hold the whole dataset In memory.# of order to does so very used keys is taken in memory and the other keys# is swapped into a swap file, Simi Larly to what operating systems do# with memory pages.## to enable VMS just set ' vm-enabled ' to Yes, and set the following three# VM parameters accordingly to your needs. #是否开启虚拟内存支持. #redis is a memory database, when the memory is full, unable to receive new write requests, so after redis2.0, provide virtual memory support # but note that all of the Redis key will be in memory, when the memory is not enough, only put value values into the Swap area # Although using virtual memory, But the performance is basically not affected, you need to be careful to set the vm-max-memory enough to put down all the key 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.## the best kind of storage for the Redis swap file (that's access Ed at random) # was a Solid state Disk (SSD). # # * * * * * * * WARNING * * * is using a shared hosting the default of putting# T He 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. #设置虚拟内存的交换文件路径, not multiple Redis instance Sharing 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, that# are, 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 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. #设置开启虚拟内存后, the maximum amount of physical memory that Redis will use Small. #默认为0, Redis will put all of his swap files into the swap file to minimize the use of physical memory # that is, when the vm-max-memory is set to 0, in fact, all value is present in the disk # in the production environment, you need to set the value according to the actual situation, It is best not to use the default 0 vm-max-memory 0# Redis swap files are split into pages. An object can is saved using multiple# contiguous pages, but pages can ' t being shared between different objects.# so if your Page is too big, small objects swapped off on disk would waste# a lot of space. If you are too small, there is less space in the swap# file (assuming you configured the same number of Total swap fil e pages). # # If you use a lot of small objects, use a page size of up or bytes.# If you use a lot of big objects, use a Bigger page size.# if unsure, use the default:) #设置虚拟内存的页大小如果 value is larger, if you want to place all the content of the blog, News, and so on in value, set a larger vm-page-size# Number of total memory pages in the swap file.# Given, the page table (a bitmap of free/used pages) is taken in memo ry,# every 8 pages on disk would consume 1 byte of ram.## The total swap size are 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 would use a. MB of RAM for the page Ta ble.## It's better to use the smallest acceptable value for your application,# and the default is large in order to work I n Most conditions. #设置交换文件的总的 page Number # Note that the page table information is placed in physical memory, and each 8 page occupies 1 byte# total virtual memory size in RAM = Vm-page-size * Vm-pages 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, sinc E they# also encode and decode objects from disk to memory or the reverse, a bigger# number of threads can help with Big O Bjects even if they can ' t help with# I/O itself as the physical device may isn't being able to couple with many# reads/writes O Perations at the same time.## the special value of 0 turn off threaded I/O and enables the blocking# Virtual Memory Implem Entation. #设置 the number of threads used by VM IO concurrently. Vm-max-threads 4# 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. #redis 2.0 introduced a hash data structure. #hash contains more than the specified number of elements and the largest element when no more than the critical, the hash will be stored in Zipmap #zipmap is also known as the small hash, can greatly reduce the use of memory hash-max-zipmap-entries Hash-max-zipmap-value # Active rehashing uses 1 millisecond every $ milliseconds of CPU time in# order to help 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 times every second I n Order to# Active rehashing the main dictionaries, freeing memory when possible.## If unsure:# use "activerehashing no" I f You has hard latency requirements and it is# not a good thing in your environment so Redis can reply form time to Tim e# to queries with 2 milliseconds delay.## use "activerehashing yes" if you don ' t has such hard requirements but# want to Free memory asap when possible. #是否重置Hash表 # After set to Yes, Redis will use 1 milliseconds of CPU time per 100 milliseconds to re-have the Redis hash table.H, can reduce the use of memory # When the usage scenario has a stricter real-time requirement, you cannot accept Redis's occasional 2 millisecond delay for requests, and configure this as No. #如果没有这么严格的实时性要求, you can set to Yes so that you can free up memory as quickly as possible activerehashing Yes   The Redis Official documentation provides some recommendations for the use of VMS:
    • When the key is small and the value is large, the effect of using the VM is better. Because it saves a lot of memory.
    • When the key is not small, you can consider using some very important methods to turn a large key into a large value, such as the ability to combine key,value into a new value
    • It is best to use Linux ext3 to support a better file system for sparse files to save your swap files
    • The Vm-max-threads parameter sets the number of threads to access the swap file, preferably not exceeding the machine's number of cores; set to 0 all operations on swap files are serial and may result in long delays, but with good assurance of data integrity
Redis Data StorageThe Redis storage is divided into memory storage, disk storage, and log files, which are configured with three parameters in the configuration file.
    • The Save seconds Updates,save configuration, indicating how many times the update operation is synchronized to the data file. Multiple conditions can be mated, with three conditions configured by default.
    • AppendOnly yes/no, appendonly configuration, indicates whether logging occurs after each update operation and, if not turned on, may result in 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.
    • Appendfsync no/always/everysec, Appendfsync configuration, no indicates that the operating system data cache synchronization to disk, always indicates that each update operation after the manual call Fsync () write data to disk, EVERYSEC indicates synchronization once per second

Redis configuration file redis.conf parameter description

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.