Detailed description of redis.conf:

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

Detailed description of redis.conf:
Reference: http://blog.csdn.net/vv_demon/article/details/7676384


# By default, Redis does not run as a daemon. Use the ' yes ' if you need it.
# Note that Redis would write a PID file in/var/run/redis.pid when daemonized.
#Redis默认不是以守护进程的方式运行, you can enable the daemon with Yes by modifying the configuration item
daemonize No



# when running daemonized, Redis writes a PID file in/var/run/redis.pid by
# Default. You can specify a custom PID file from here.
#当 Redis runs as a daemon, redis defaults to putting PID files on/var/run/redis.pid, which you can configure to other addresses. When running multiple Redis services, you need to specify a different PID file and port
Pidfile/var/run/redis.pid

# Accept connections on the specified port, default is 6379.
# If Port 0 is specified Redis would not listen on a TCP socket.
#端口没什么好说的
Port 6379

# If you want your can bind a single interface if the BIND option isn't
# specified all the interfaces would listen for incoming connections.
#指定Redis可接收请求的IP地址, do not set up will process all requests, recommended in production environment
# bind 127.0.0.1

# Close The connection after a client are idle for N seconds (0 to disable)
#客户端连接的超时时间, the unit is seconds, and the connection is closed after the timeout. Set to 0 is no timeout limit
Timeout 0

# Specify the log file name. Also ' stdout ' can is used to force
# Redis to log on the standard output. Note If you use the standard
# Output for logging but daemonize, logs'll be sent To/dev/null
#配置 log file address, which is printed by default on the command-line terminal window
logfile stdout

# 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
#设置数据库的个数, you can use the SELECT <dbid> command to switch the database. The default database used is 0
databases



#
# Save the DB on disk:
#
# Save <seconds> <changes>
#
# 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 ten keys changed
# after the SEC if at least 10000 keys changed
#
# note:you can disable saving at all commenting all the "save" lines.
the frequency #设置 Redis for database mirroring.
#900秒之内有1个keys发生变化时
#30秒之内有10个keys发生变化时
#60秒之内有10000个keys发生变化时
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 on the saving child set it to ' no ' but
# The DataSet would likely is bigger if you have compressible values or keys.
#在进行镜像备份时, whether to compress
rdbcompression Yes

# The filename where to dump the DB
#镜像备份文件的文件名
dbfilename Dump.rdb

# The working directory.
#
# The DB would be is written inside this directory, with the filename specified
# above using the ' dbfilename ' configuration directive.
#
# Also The Append only File is created inside this directory.
#
# Note that you must specify a directory here, not a file name.
#数据库镜像备份的文件放置的路径. The path and file name to be configured separately because Redis in the backup, the state of the current database will be written to a temporary file, when the backup is complete, then the temporary file is replaced with the file specified above,
#而这里的临时文件和上面所配置的备份文件都会放在这个指定的路径当中
dir./

# 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's possible to configure the slave to save the DB with a
# different interval, or to listen to another ports, and so on.
#设置该数据库为其他数据库的从数据库
# slaveof <masterip> <masterport>

# 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 would
# refuse the slave request.
#指定与主数据库连接时需要的密码验证
# Masterauth <master-password>

# Require clients to issue AUTH <PASSWORD> before processing
# commands. This might is useful in environments in which don't 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 a outside user can try up to
# 150k passwords per second against a good box. This means, you should
# Use a very strong password otherwise it'll be very easy to break.
#设置客户端连接后进行任何其他指定前需要使用的密码.
Warning: Redis is quite fast, and an external user can make a 150K password attempt in a second, and you need to specify a very 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
# is able to open. The special value ' 0 ' means no limits.
# Once The limit is reached Redis would close all the new connections sending
# an error ' max number of clients reached '.
#限制同时连接的客户数量. When the number of connections exceeds this value, Redis will no longer receive additional connection requests, and the client will receive an error message when attempting to connect
# maxclients

# Don ' t use more memory than the specified amount of bytes.
# When the memory limit is reached Redis would try to remove keys
# Accordingly to the eviction policy selected (see Maxmemmory-policy).
#
# if Redis can ' t remove keys according to the policy, or if the policy is
# set to ' Noeviction ', Redis'll start to reply with errors to commands
# that would with more memory, like SET, Lpush, and so on, and would continue
# to reply-read-only commands like GET.
#
# This option was usually useful when using a Redis as an LRU cache, or to set
# A hard memory limit for an 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 the slaves is subtracted
# from the used memory count, so the network Problems/resyncs would
# not trigger a loop where keys is evicted, and in turn the output
# Buffer of slaves is 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
# limit for MaxMemory so there are some free RAM on the system for Slave
# output buffers (needed if the policy is ' noeviction ').
#设置redis能够使用的最大内存. When the memory is full, if the SET command is also received, Redis will first attempt to remove the key that set the expire information, regardless of the key's expiration time has not arrived.
#在删除时, it will be deleted by the expiration time and the first key to be expired will be deleted first. If the key with expire information is erased, an error is returned.
#这样, Redis will no longer receive write requests and receive only get requests. MaxMemory settings are more appropriate for using Redis as a memcached-like cache .
# maxmemory <bytes>

# By default Redis asynchronously dumps the datasets on disk. If You can live
# with the idea, the latest records would be lost if something like a crash
# happens this is the preferred-to-run Redis. If instead a lot
# about your data and don ' t want to the a single record can get lost you should
# enable the Append only mode:when this mode is enabled Redis would append
# every write operation received in the file appendonly.aof. This file would
# be-Read on startup ' order to rebuild the full dataset in memory.
#
# Note So you can have both the async dumps and the append only file if you
# like (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.
#
# Important:check The bgrewriteaof to Check what to rewrite the append
# log file in background when it gets too big.
#默认情况下, Redis backs up database mirroring to disk asynchronously in the background, but the backup is time-consuming and cannot be backed up very often, resulting in a wide range of data loss if conditions such as power cuts, unplug, etc., occur.
#所以redis提供了另外一种更加高效的数据库备份及灾难恢复方式.
#开 Append only mode, Redis appends every write request received to the Appendonly.aof file, and when Redis restarts, the previous state is recovered from the file.
#但是这样会造成 The appendonly.aof file is too large, Redis also supports the bgrewriteaof command to rearrange the appendonly.aof
appendonly No

# the Fsync () call tells the Operating System to actually write data on disk
# instead to wait for more data in the output 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" that would would let the operating system flush the output buffer when
# It wants, for better performances (and if you can live with the idea of
# Some data loss consider the default persistence mode that ' s snapshotting),
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
#
# If unsure, use "everysec".
#设置对 the frequency at which appendonly.aof files are synchronized. Always means that each time a write operation is synchronized, everysec indicates 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 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.
#是否开启虚拟内存支持. Because Redis is a memory database and cannot receive new write requests when the memory is full, it provides support for virtual memory in redis2.0.
#但是需要注意的是, in Redis, all keys are placed in memory, and only value values are placed in the swap area when there is not enough memory.
#这样保证了虽然使用虚拟内存, but performance is fundamentally unaffected, and you need to be aware that you're going to set the vm-max-memory to enough to put down all of your keys
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.
#这里设置开启虚拟内存之后, the maximum amount of physical memory that Redis will use. By default, 0,redis will put all of the files that he can put into the swap file to minimize the use of physical memory.
#在生产环境下, you need to set this 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 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
#设置虚拟内存的页大小, if your value is large, say you want to put in the value of the blog, the news and so on all the article content, set a larger point, if you want to place a small content, then set a smaller
vm-page-size

# 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.
#设置交换文件的总的 page count, note that the page table information is placed in physical memory, and each 8 page occupies 1 bytes 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, 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.
#设置 The number of threads used concurrently with VM IO.
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 the biggest element does not
# exceed a given threshold. Can configure this limits with the following
# Configuration directives.
a hash data structure was introduced in #redis 2.0.
#hash contains more than the specified number of elements and the largest element when no more than the critical, hash will be Zipmap (also known as small hash greatly reduce memory use) to store, here can set these two thresholds
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 you run to an hash table
# That's rhashing, the more rehashing ' steps ' is performed, so if the
# server is idle the rehashing are never complete and some more memory is used
# By the hash table.
#
# The default is to use this millisecond times every second in order to
# active rehashing The main dictionaries, freeing memory when possible.
#
# If Unsure:
# use "Activerehashing no" if you had hard latency requirements and it was
# a good thing in your environment. Redis can reply form time to time
# to queries with 2 milliseconds delay.
#
# use "Activerehashing yes" if you don ' t have such hard requirements but
# Want to free memory asap when possible.
#开启之后, Redis will use 1 milliseconds of CPU time every 100 milliseconds to hash the Redis hash table to reduce memory usage.
#当你的使用场景中, there is a very strict real-time requirement, and it is not possible to accept that Redis has a 2 millisecond delay to the request, which is configured as No.
#如果没有这么严格的实时性要求, you can set to Yes so that you can free up memory as quickly as possible
activerehashing Yes

Detailed description of redis.conf:

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.