Redis配置文件詳解

001  
# Redis configuration file example  
002  
   
003  
# Note on units: when memory size is needed, it is possible to specifiy  
004  
# it in the usual form of 1k 5GB 4M and so forth:  
005  
#  
006  
# 1k => 1000 bytes  
007  
# 1kb => 1024 bytes  
008  
# 1m => 1000000 bytes  
009  
# 1mb => 1024*1024 bytes  
010  
# 1g => 1000000000 bytes  
011  
# 1gb => 1024*1024*1024 bytes  
012  
#  
013  
# units are case insensitive so 1GB 1Gb 1gB are all the same.  
014  
   
015  
# By default Redis does not run as a daemon. Use 'yes' if you need it.  
016  
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.  
017  
daemonize no   
018  
Redis默認(rèn)不是以守護(hù)進(jìn)程的方式運(yùn)行荷腊,可以通過該配置項修改荧降,使用yes啟用守護(hù)進(jìn)程  
019  
   
020  
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by  
021  
# default. You can specify a custom pid file location here.  
022  
pidfile /var/run/redis.pid  
023  
當(dāng)Redis以守護(hù)進(jìn)程方式運(yùn)行時璃氢,Redis默認(rèn)會把pid寫入/var/run/redis.pid文件,可以通過pidfile指定  
024  
# Accept connections on the specified port, default is 6379.  
025  
# If port 0 is specified Redis will not listen on a TCP socket.  
026  
port 6379  
027  
指定Redis監(jiān)聽端口艺配,默認(rèn)端口為6379  
028  
# If you want you can bind a single interface, if the bind option is not  
029  
# specified all the interfaces will listen for incoming connections.  
030  
#  
031  
# bind 127.0.0.1  
032  
綁定的主機(jī)地址  
033  
# Specify the path for the unix socket that will be used to listen for  
034  
# incoming connections. There is no default, so Redis will not listen  
035  
# on a unix socket when not specified.  www.2cto.com    
036  
#  
037  
# unixsocket /tmp/redis.sock  
038  
# unixsocketperm 755  
039  
   
040  
# Close the connection after a client is idle for N seconds (0 to disable)  
041  
timeout 0  
042  
當(dāng) 客戶端閑置多長時間后關(guān)閉連接,如果指定為0顷帖,表示關(guān)閉該功能  
043  
# Set server verbosity to 'debug'  
044  
# it can be one of:  
045  
# debug (a lot of information, useful for development/testing)  
046  
# verbose (many rarely useful info, but not a mess like the debug level)  
047  
# notice (moderately verbose, what you want in production probably)  
048  
# warning (only very important / critical messages are logged)  
049  
loglevel verbose  
050  
指定日志記錄級別绩鸣,Redis總共支持四個級別:debug、verbose凡简、notice逼友、warning精肃,默認(rèn)為verbose  
051  
# Specify the log file name. Also 'stdout' can be used to force  
052  
# Redis to log on the standard output. Note that if you use standard  
053  
# output for logging but daemonize, logs will be sent to /dev/null  
054  
logfile stdout  
055  
日志記錄方式,默認(rèn)為標(biāo)準(zhǔn)輸出帜乞,如果配置Redis為守護(hù)進(jìn)程方式運(yùn)行司抱,而這里又配置為日志記錄方式為標(biāo)準(zhǔn)輸出,則日志將會發(fā)送給/dev/null  
056  
# To enable logging to the system logger, just set 'syslog-enabled' to yes,  
057  
# and optionally update the other syslog parameters to suit your needs.  
058  
# syslog-enabled no  
059  
   
060  
# Specify the syslog identity.  
061  
# syslog-ident redis  
062  
   
063  
# Specify the syslog facility.  Must be USER or between LOCAL0-LOCAL7.  
064  
# syslog-facility local0  
065  
   
066  
# Set the number of databases. The default database is DB 0, you can select  
067  
# a different one on a per-connection basis using SELECT <dbid> where  
068  
# dbid is a number between 0 and 'databases'-1  
069  
databases 16  www.2cto.com    
070  
設(shè)置數(shù)據(jù)庫的數(shù)量黎烈,默認(rèn)數(shù)據(jù)庫為0习柠,可以使用SELECT <dbid>命令在連接上指定數(shù)據(jù)庫id  
071  
################################ SNAPSHOTTING  #################################  
072  
#  
073  
# Save the DB on disk:  
074  
#  
075  
#   save <seconds> <changes>  
076  
#  
077  
#   Will save the DB if both the given number of seconds and the given  
078  
#   number of write operations against the DB occurred.  
079  
#  
080  
#   In the example below the behaviour will be to save:  
081  
#   after 900 sec (15 min) if at least 1 key changed  
082  
#   after 300 sec (5 min) if at least 10 keys changed  
083  
#   after 60 sec if at least 10000 keys changed  
084  
#  
085  
#   Note: you can disable saving at all commenting all the "save" lines.  
086  
   
087  
save 900 1  
088  
save 300 10  
089  
save 60 10000  
090  
分別表示900秒(15分鐘)內(nèi)有1個更改,300秒(5分鐘)內(nèi)有10個更改以及60秒內(nèi)有10000個更改照棋。  
091  
指定在多長時間內(nèi)资溃,有多少次更新操作,就將數(shù)據(jù)同步到數(shù)據(jù)文件烈炭,可以多個條件配合  
092  
# Compress string objects using LZF when dump .rdb databases?  
093  
# For default that's set to 'yes' as it's almost always a win.  
094  
# If you want to save some CPU in the saving child set it to 'no' but  
095  
# the dataset will likely be bigger if you have compressible values or keys.  
096  
rdbcompression yes  
097  
指定存儲至本地數(shù)據(jù)庫時是否壓縮數(shù)據(jù)溶锭,默認(rèn)為yes,Redis采用LZF壓縮符隙,如果為了節(jié)省CPU時間趴捅,可以關(guān)閉該選項,但會導(dǎo)致數(shù)據(jù)庫文件變的巨大  
098  
# The filename where to dump the DB  
099  
dbfilename dump.rdb  
100  
指定本地數(shù)據(jù)庫文件名霹疫,默認(rèn)值為dump.rdb  
101  
# The working directory.  
102  
#  
103  
# The DB will be written inside this directory, with the filename specified  
104  
# above using the 'dbfilename' configuration directive.  
105  
#  
106  
# Also the Append Only File will be created inside this directory.  
107  
#  
108  
# Note that you must specify a directory here, not a file name.  
109  
dir ./  
110  
指定本地數(shù)據(jù)庫存放目錄  
111  
################################# REPLICATION #################################  
112  
   
113  
# Master-Slave replication. Use slaveof to make a Redis instance a copy of  
114  
# another Redis server. Note that the configuration is local to the slave  
115  
# so for example it is possible to configure the slave to save the DB with a  
116  
# different interval, or to listen to another port, and so on.  www.2cto.com    
117  
#  
118  
# slaveof <masterip> <masterport>  
119  
slaveof <masterip> <masterport> 設(shè)置當(dāng)本機(jī)為slav服務(wù)時拱绑,設(shè)置master服務(wù)的IP地址及端口,在Redis啟動時更米,它會自動從master進(jìn)行數(shù)據(jù)同步  
120  
# If the master is password protected (using the "requirepass" configuration  
121  
# directive below) it is possible to tell the slave to authenticate before  
122  
# starting the replication synchronization process, otherwise the master will  
123  
# refuse the slave request.  
124  
#  
125  
# masterauth <master-password>  
126  
masterauth <master-password> 當(dāng)master服務(wù)設(shè)置了密碼保護(hù)時欺栗,slav服務(wù)連接master的密碼  
127  
# When a slave lost the connection with the master, or when the replication  
128  
# is still in progress, the slave can act in two different ways:  
129  
#  
130  
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will  
131  
#    still reply to client requests, possibly with out of data data, or the  
132  
#    data set may just be empty if this is the first synchronization.  
133  
#  
134  
# 2) if slave-serve-stale data is set to 'no' the slave will reply with  
135  
#    an error "SYNC with master in progress" to all the kind of commands  
136  
#    but to INFO and SLAVEOF.  
137  
#  
138  
slave-serve-stale-data yes  
139  
   
140  
# Slaves send PINGs to server in a predefined interval. It's possible to change  
141  
# this interval with the repl_ping_slave_period option. The default value is 10  
142  
# seconds.  www.2cto.com    
143  
#  
144  
# repl-ping-slave-period 10  
145  
   
146  
# The following option sets a timeout for both Bulk transfer I/O timeout and  
147  
# master data or ping response timeout. The default value is 60 seconds.  
148  
#  
149  
# It is important to make sure that this value is greater than the value  
150  
# specified for repl-ping-slave-period otherwise a timeout will be detected  
151  
# every time there is low traffic between the master and the slave.  
152  
#  
153  
# repl-timeout 60  
154  
   
155  
################################## SECURITY ###################################  
156  
   
157  
# Require clients to issue AUTH <PASSWORD> before processing any other  
158  
# commands.  This might be useful in environments in which you do not trust  
159  
# others with access to the host running redis-server.  
160  
#  
161  
# This should stay commented out for backward compatibility and because most  
162  
# people do not need auth (e.g. they run their own servers).  
163  
#  
164  
# Warning: since Redis is pretty fast an outside user can try up to  
165  
# 150k passwords per second against a good box. This means that you should  
166  
# use a very strong password otherwise it will be very easy to break.  
167  
#  
168  
# requirepass foobared  
169  
 requirepass foobared 設(shè)置Redis連接密碼,如果配置了連接密碼征峦,客戶端在連接Redis時需要通過AUTH <password>命令提供密碼迟几,默認(rèn)關(guān)閉  
170  
# Command renaming.  
171  
#  
172  
# It is possilbe to change the name of dangerous commands in a shared  
173  
# environment. For instance the CONFIG command may be renamed into something  
174  
# of hard to guess so that it will be still available for internal-use  
175  
# tools but not available for general clients.  
176  
#  
177  
# Example:  
178  
#  
179  
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52  
180  
#  
181  
# It is also possilbe to completely kill a command renaming it into  
182  
# an empty string:  
183  
#  
184  
# rename-command CONFIG ""  
185  
   
186  
################################### LIMITS ####################################  
187  
   
188  
# Set the max number of connected clients at the same time. By default there  
189  
# is no limit, and it's up to the number of file descriptors the Redis process  
190  
# is able to open. The special value '0' means no limits.  
191  
# Once the limit is reached Redis will close all the new connections sending  
192  
# an error 'max number of clients reached'.  www.2cto.com    
193  
#  
194  
# maxclients 128  
195  
maxclients 128 設(shè)置同一時間最大客戶端連接數(shù),默認(rèn)無限制栏笆,Redis可以同時打開的客戶端連接數(shù)為Redis進(jìn)程可以打開的最大文件描述符數(shù)类腮,如果設(shè)置 maxclients 0,表示不作限制蛉加。當(dāng)客戶端連接數(shù)到達(dá)限制時蚜枢,Redis會關(guān)閉新的連接并向客戶端返回max number of clients reached錯誤信息  
196  
# Don't use more memory than the specified amount of bytes.  
197  
# When the memory limit is reached Redis will try to remove keys with an  
198  
# EXPIRE set. It will try to start freeing keys that are going to expire  
199  
# in little time and preserve keys with a longer time to live.  
200  
# Redis will also try to remove objects from free lists if possible.  
201  
#  
202  
# If all this fails, Redis will start to reply with errors to commands  
203  
# that will use more memory, like SET, LPUSH, and so on, and will continue  
204  
# to reply to most read-only commands like GET.  
205  
#  
206  
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a  
207  
# 'state' server or cache, not as a real DB. When Redis is used as a real  
208  
# database the memory usage will grow over the weeks, it will be obvious if  
209  
# it is going to use too much memory in the long run, and you'll have the time  
210  
# to upgrade. With maxmemory after the limit is reached you'll start to get  
211  
# errors for write operations, and this may even lead to DB inconsistency.  
212  
#  
213  
# maxmemory <bytes>  
214  
 maxmemory <bytes>指定Redis最大內(nèi)存限制,Redis在啟動時會把數(shù)據(jù)加載到內(nèi)存中针饥,達(dá)到最大內(nèi)存后厂抽,Redis會先嘗試清除已到期或即將到期的Key,當(dāng)此方法處理 后丁眼,仍然到達(dá)最大內(nèi)存設(shè)置筷凤,將無法再進(jìn)行寫入操作,但仍然可以進(jìn)行讀取操作。Redis新的vm機(jī)制藐守,會把Key存放內(nèi)存挪丢,Value會存放在swap區(qū)  
215  
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory  
216  
# is reached? You can select among five behavior:  
217  
#  
218  
# volatile-lru -> remove the key with an expire set using an LRU algorithm  
219  
# allkeys-lru -> remove any key accordingly to the LRU algorithm  
220  
# volatile-random -> remove a random key with an expire set  
221  
# allkeys->random -> remove a random key, any key  
222  
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)  
223  
# noeviction -> don't expire at all, just return an error on write operations  
224  
#  
225  
# Note: with all the kind of policies, Redis will return an error on write  
226  
#       operations, when there are not suitable keys for eviction.  
227  
#  
228  
#       At the date of writing this commands are: set setnx setex append  
229  
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd  
230  
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby  
231  
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby  
232  
#       getset mset msetnx exec sort  www.2cto.com    
233  
#  
234  
# The default is:  
235  
#  
236  
# maxmemory-policy volatile-lru  
237  
   
238  
# LRU and minimal TTL algorithms are not precise algorithms but approximated  
239  
# algorithms (in order to save memory), so you can select as well the sample  
240  
# size to check. For instance for default Redis will check three keys and  
241  
# pick the one that was used less recently, you can change the sample size  
242  
# using the following configuration directive.  
243  
#  
244  
# maxmemory-samples 3  
245  
   
246  
############################## APPEND ONLY MODE ###############################  
247  
   
248  
# By default Redis asynchronously dumps the dataset on disk. If you can live  
249  
# with the idea that the latest records will be lost if something like a crash  
250  
# happens this is the preferred way to run Redis. If instead you care a lot  
251  
# about your data and don't want to that a single record can get lost you should  
252  
# enable the append only mode: when this mode is enabled Redis will append  
253  
# every write operation received in the file appendonly.aof. This file will  
254  
# be read on startup in order to rebuild the full dataset in memory.  
255  
#  
256  
# Note that you can have both the async dumps and the append only file if you  
257  
# like (you have to comment the "save" statements above to disable the dumps).  
258  
# Still if append only mode is enabled Redis will load the data from the  
259  
# log file at startup ignoring the dump.rdb file.  
260  
#  
261  
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append  
262  
# log file in background when it gets too big.  
263  
   
264  
appendonly no  
265  
appendonly no指定是否在每次更新操作后進(jìn)行日志記錄,Redis在默認(rèn)情況下是異步的把數(shù)據(jù)寫入磁盤卢厂,如果不開啟乾蓬,可能會在斷電時導(dǎo)致一段時間內(nèi)的數(shù)據(jù)丟失。因為 redis本身同步數(shù)據(jù)文件是按上面save條件來同步的慎恒,所以有的數(shù)據(jù)會在一段時間內(nèi)只存在于內(nèi)存中任内。默認(rèn)為no  
266  
# The name of the append only file (default: "appendonly.aof")  
267  
# appendfilename appendonly.aof  
268  
 appendfilename appendonly.aof指定更新日志文件名,默認(rèn)為appendonly.aof  
269  
# The fsync() call tells the Operating System to actually write data on disk  
270  
# instead to wait for more data in the output buffer. Some OS will really flush  
271  
# data on disk, some other OS will just try to do it ASAP.  
272  
#  
273  
# Redis supports three different modes:  
274  
#  
275  
# no: don't fsync, just let the OS flush the data when it wants. Faster.  
276  
# always: fsync after every write to the append only log . Slow, Safest.  
277  
# everysec: fsync only if one second passed since the last fsync. Compromise.  
278  
#  
279  
# The default is "everysec" that's usually the right compromise between  
280  
# speed and data safety. It's up to you to understand if you can relax this to  
281  
# "no" that will will let the operating system flush the output buffer when  
282  
# it wants, for better performances (but if you can live with the idea of  
283  
# some data loss consider the default persistence mode that's snapshotting),  
284  
# or on the contrary, use "always" that's very slow but a bit safer than  
285  
# everysec.  www.2cto.com    
286  
#  
287  
# If unsure, use "everysec".  
288  
   
289  
# appendfsync always  
290  
appendfsync everysec  
291  
# appendfsync no  
292  
指定更新日志條件巧号,共有3個可選值:  
293  
no:表示等操作系統(tǒng)進(jìn)行數(shù)據(jù)緩存同步到磁盤(快)  
294  
always:表示每次更新操作后手動調(diào)用fsync()將數(shù)據(jù)寫到磁盤(慢族奢,安全)  
295  
everysec:表示每秒同步一次(折衷,默認(rèn)值)  
296  
# When the AOF fsync policy is set to always or everysec, and a background  
297  
# saving process (a background save or AOF log background rewriting) is  
298  
# performing a lot of I/O against the disk, in some Linux configurations  
299  
# Redis may block too long on the fsync() call. Note that there is no fix for  
300  
# this currently, as even performing fsync in a different thread will block  
301  
# our synchronous write(2) call.  
302  
#  
303  
# In order to mitigate this problem it's possible to use the following option  
304  
# that will prevent fsync() from being called in the main process while a  
305  
# BGSAVE or BGREWRITEAOF is in progress.  
306  
#  
307  
# This means that while another child is saving the durability of Redis is  
308  
# the same as "appendfsync none", that in pratical terms means that it is  
309  
# possible to lost up to 30 seconds of log in the worst scenario (with the  
310  
# default Linux settings).  
311  
#  
312  
# If you have latency problems turn this to "yes". Otherwise leave it as  
313  
# "no" that is the safest pick from the point of view of durability.  
314  
no-appendfsync-on-rewrite no  
315  
   
316  
# Automatic rewrite of the append only file.  
317  
# Redis is able to automatically rewrite the log file implicitly calling  
318  
# BGREWRITEAOF when the AOF log size will growth by the specified percentage.  
319  
#  
320  
# This is how it works: Redis remembers the size of the AOF file after the  
321  
# latest rewrite (or if no rewrite happened since the restart, the size of  
322  
# the AOF at startup is used).  
323  
#  
324  
# This base size is compared to the current size. If the current size is  
325  
# bigger than the specified percentage, the rewrite is triggered. Also  
326  
# you need to specify a minimal size for the AOF file to be rewritten, this  
327  
# is useful to avoid rewriting the AOF file even if the percentage increase  
328  
# is reached but it is still pretty small.  
329  
#  
330  
# Specify a precentage of zero in order to disable the automatic AOF  
331  
# rewrite feature.  www.2cto.com    
332  
   
333  
auto-aof-rewrite-percentage 100  
334  
auto-aof-rewrite-min-size 64mb  
335  
   
336  
################################## SLOW LOG ###################################  
337  
   
338  
# The Redis Slow Log is a system to log queries that exceeded a specified  
339  
# execution time. The execution time does not include the I/O operations  
340  
# like talking with the client, sending the reply and so forth,  
341  
# but just the time needed to actually execute the command (this is the only  
342  
# stage of command execution where the thread is blocked and can not serve  
343  
# other requests in the meantime).  
344  
#  
345  
# You can configure the slow log with two parameters: one tells Redis  
346  
# what is the execution time, in microseconds, to exceed in order for the  
347  
# command to get logged, and the other parameter is the length of the  
348  
# slow log. When a new command is logged the oldest one is removed from the  
349  
# queue of logged commands.  
350  
   
351  
# The following time is expressed in microseconds, so 1000000 is equivalent  
352  
# to one second. Note that a negative number disables the slow log, while  
353  
# a value of zero forces the logging of every command.  
354  
slowlog-log-slower-than 10000  
355  
   
356  
# There is no limit to this length. Just be aware that it will consume memory.  
357  
# You can reclaim memory used by the slow log with SLOWLOG RESET.  
358  
slowlog-max-len 1024  
359  
   
360  
################################ VIRTUAL MEMORY ###############################  
361  
   
362  
### WARNING! Virtual Memory is deprecated in Redis 2.4  
363  
### The use of Virtual Memory is strongly discouraged.  
364  
   
365  
### WARNING! Virtual Memory is deprecated in Redis 2.4  
366  
### The use of Virtual Memory is strongly discouraged.  
367  
   
368  
# Virtual Memory allows Redis to work with datasets bigger than the actual  
369  
# amount of RAM needed to hold the whole dataset in memory.  
370  
# In order to do so very used keys are taken in memory while the other keys  
371  
# are swapped into a swap file, similarly to what operating systems do  
372  
# with memory pages.  www.2cto.com    
373  
#  
374  
# To enable VM just set 'vm-enabled' to yes, and set the following three  
375  
# VM parameters accordingly to your needs.  
376  
   
377  
vm-enabled no  
378  
指定是否啟用虛擬內(nèi)存機(jī)制丹鸿,默認(rèn)值為no越走,簡單的介紹一下,VM機(jī)制將數(shù)據(jù)分頁存放靠欢,由Redis將訪問量較少的頁即冷數(shù)據(jù)swap到磁盤上廊敌,訪問多的頁面由磁盤自動換出到內(nèi)存中(在后面的文章我會仔細(xì)分析Redis的VM機(jī)制)  
379  
# vm-enabled yes  
380  
   
381  
# This is the path of the Redis swap file. As you can guess, swap files  
382  
# can't be shared by different Redis instances, so make sure to use a swap  
383  
# file for every redis process you are running. Redis will complain if the  
384  
# swap file is already in use.  
385  
#  
386  
# The best kind of storage for the Redis swap file (that's accessed at random)  
387  
# is a Solid State Disk (SSD).  
388  
#  
389  
# *** WARNING *** if you are using a shared hosting the default of putting  
390  
# the swap file under /tmp is not secure. Create a dir with access granted  
391  
# only to Redis user and configure Redis to create the swap file there.  
392  
vm-swap-file /tmp/redis.swap  
393  
虛擬內(nèi)存文件路徑,默認(rèn)值為/tmp/redis.swap门怪,不可多個Redis實例共享  
394  
# vm-max-memory configures the VM to use at max the specified amount of  
395  
# RAM. Everything that deos not fit will be swapped on disk *if* possible, that  
396  
# is, if there is still enough contiguous space in the swap file.  
397  
#  
398  
# With vm-max-memory 0 the system will swap everything it can. Not a good  
399  
# default, just specify the max amount of RAM you can in bytes, but it's  
400  
# better to leave some margin. For instance specify an amount of RAM  
401  
# that's more or less between 60 and 80% of your free RAM.  
402  
vm-max-memory 0  www.2cto.com    
403  
將所有大于vm-max-memory的數(shù)據(jù)存入虛擬內(nèi)存,無論vm-max-memory設(shè)置多小,所有索引數(shù)據(jù)都是內(nèi)存存儲的(Redis的索引數(shù)據(jù) 就是keys),也就是說,當(dāng)vm-max-memory設(shè)置為0的時候,其實是所有value都存在于磁盤骡澈。默認(rèn)值為0  
404  
# Redis swap files is split into pages. An object can be saved using multiple  
405  
# contiguous pages, but pages can't be shared between different objects.  
406  
# So if your page is too big, small objects swapped out on disk will waste  
407  
# a lot of space. If you page is too small, there is less space in the swap  
408  
# file (assuming you configured the same number of total swap file pages).  
409  
#  
410  
# If you use a lot of small objects, use a page size of 64 or 32 bytes.  
411  
# If you use a lot of big objects, use a bigger page size.  
412  
# If unsure, use the default :)  
413  
vm-page-size 32  
414  
Redis swap文件分成了很多的page,一個對象可以保存在多個page上面掷空,但一個page上不能被多個對象共享肋殴,vm-page-size是要根據(jù)存儲的 數(shù)據(jù)大小來設(shè)定的,作者建議如果存儲很多小對象坦弟,page大小最好設(shè)置為32或者64bytes护锤;如果存儲很大大對象,則可以使用更大的page酿傍,如果不 確定烙懦,就使用默認(rèn)值  
415  
# Number of total memory pages in the swap file.  
416  
# Given that the page table (a bitmap of free/used pages) is taken in memory,  
417  
# every 8 pages on disk will consume 1 byte of RAM.  
418  
#  
419  
# The total swap size is vm-page-size * vm-pages  
420  
#  
421  
# With the default of 32-bytes memory pages and 134217728 pages Redis will  
422  
# use a 4 GB swap file, that will use 16 MB of RAM for the page table.  
423  
#  
424  
# It's better to use the smallest acceptable value for your application,  
425  
# but the default is large in order to work in most conditions.  
426  
vm-pages 134217728  
427  
設(shè)置swap文件中的page數(shù)量,由于頁表(一種表示頁面空閑或使用的bitmap)是在放在內(nèi)存中的赤炒,氯析,在磁盤上每8個pages將消耗1byte的內(nèi)存。  
428  
# Max number of VM I/O threads running at the same time.  
429  
# This threads are used to read/write data from/to swap file, since they  
430  
# also encode and decode objects from disk to memory or the reverse, a bigger  
431  
# number of threads can help with big objects even if they can't help with  
432  
# I/O itself as the physical device may not be able to couple with many  
433  
# reads/writes operations at the same time.  www.2cto.com    
434  
#  
435  
# The special value of 0 turn off threaded I/O and enables the blocking  
436  
# Virtual Memory implementation.  
437  
vm-max-threads 4  
438  
設(shè)置訪問swap文件的線程數(shù),最好不要超過機(jī)器的核數(shù),如果設(shè)置為0,那么所有對swap文件的操作都是串行的莺褒,可能會造成比較長時間的延遲掩缓。默認(rèn)值為4  
439  
############################### ADVANCED CONFIG ###############################  
440  
   
441  
# Hashes are encoded in a special way (much more memory efficient) when they  
442  
# have at max a given numer of elements, and the biggest element does not  
443  
# exceed a given threshold. You can configure this limits with the following  
444  
# configuration directives.  
445  
hash-max-zipmap-entries 512  
446  
hash-max-zipmap-value 64  
447  
指定在超過一定的數(shù)量或者最大的元素超過某一臨界值時,采用一種特殊的哈希算法  
448  
# Similarly to hashes, small lists are also encoded in a special way in order  
449  
# to save a lot of space. The special representation is only used when  
450  
# you are under the following limits:  
451  
list-max-ziplist-entries 512  
452  
list-max-ziplist-value 64  
453  
   
454  
# Sets have a special encoding in just one case: when a set is composed  
455  
# of just strings that happens to be integers in radix 10 in the range  
456  
# of 64 bit signed integers.  
457  
# The following configuration setting sets the limit in the size of the  
458  
# set in order to use this special memory saving encoding.  
459  
set-max-intset-entries 512  www.2cto.com    
460  
   
461  
# Similarly to hashes and lists, sorted sets are also specially encoded in  
462  
# order to save a lot of space. This encoding is only used when the length and  
463  
# elements of a sorted set are below the following limits:  
464  
zset-max-ziplist-entries 128  
465  
zset-max-ziplist-value 64  
466  
   
467  
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in  
468  
# order to help rehashing the main Redis hash table (the one mapping top-level  
469  
# keys to values). The hash table implementation redis uses (see dict.c)  
470  
# performs a lazy rehashing: the more operation you run into an hash table  
471  
# that is rhashing, the more rehashing "steps" are performed, so if the  
472  
# server is idle the rehashing is never complete and some more memory is used  
473  
# by the hash table.  
474  
#  
475  
# The default is to use this millisecond 10 times every second in order to  
476  
# active rehashing the main dictionaries, freeing memory when possible.  
477  
#  
478  
# If unsure:  
479  
# use "activerehashing no" if you have hard latency requirements and it is  
480  
# not a good thing in your environment that Redis can reply form time to time  
481  
# to queries with 2 milliseconds delay.  
482  
#  
483  
# use "activerehashing yes" if you don't have such hard requirements but  
484  
# want to free memory asap when possible.  
485  
activerehashing yes  www.2cto.com    
486  
   
487  
################################## INCLUDES ###################################  
488  
   
489  
# Include one or more other config files here.  This is useful if you  
490  
# have a standard template that goes to all redis server but also need  
491  
# to customize a few per-server settings.  Include files can include  
492  
# other files, so use this wisely.  
493  
#  
494  
# include /path/to/local.conf  
495  
# include /path/to/other.conf  
496  
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末遵岩,一起剝皮案震驚了整個濱河市你辣,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖绢记,帶你破解...
    沈念sama閱讀 218,122評論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異正卧,居然都是意外死亡蠢熄,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,070評論 3 395
  • 文/潘曉璐 我一進(jìn)店門炉旷,熙熙樓的掌柜王于貴愁眉苦臉地迎上來签孔,“玉大人,你說我怎么就攤上這事窘行〖⒆罚” “怎么了?”我有些...
    開封第一講書人閱讀 164,491評論 0 354
  • 文/不壞的土叔 我叫張陵罐盔,是天一觀的道長但绕。 經(jīng)常有香客問我,道長惶看,這世上最難降的妖魔是什么捏顺? 我笑而不...
    開封第一講書人閱讀 58,636評論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮纬黎,結(jié)果婚禮上幅骄,老公的妹妹穿的比我還像新娘。我一直安慰自己本今,他們只是感情好拆座,可當(dāng)我...
    茶點故事閱讀 67,676評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著冠息,像睡著了一般挪凑。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上铐达,一...
    開封第一講書人閱讀 51,541評論 1 305
  • 那天岖赋,我揣著相機(jī)與錄音,去河邊找鬼瓮孙。 笑死唐断,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的杭抠。 我是一名探鬼主播脸甘,決...
    沈念sama閱讀 40,292評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼偏灿!你這毒婦竟也來了丹诀?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,211評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎铆遭,沒想到半個月后硝桩,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,655評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡枚荣,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,846評論 3 336
  • 正文 我和宋清朗相戀三年碗脊,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片橄妆。...
    茶點故事閱讀 39,965評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡衙伶,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出害碾,到底是詐尸還是另有隱情矢劲,我是刑警寧澤,帶...
    沈念sama閱讀 35,684評論 5 347
  • 正文 年R本政府宣布慌随,位于F島的核電站芬沉,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏阁猜。R本人自食惡果不足惜花嘶,卻給世界環(huán)境...
    茶點故事閱讀 41,295評論 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望蹦漠。 院中可真熱鬧椭员,春花似錦、人聲如沸笛园。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,894評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽研铆。三九已至埋同,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間棵红,已是汗流浹背凶赁。 一陣腳步聲響...
    開封第一講書人閱讀 33,012評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留逆甜,地道東北人虱肄。 一個月前我還...
    沈念sama閱讀 48,126評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像交煞,于是被迫代替她去往敵國和親咏窿。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,914評論 2 355

推薦閱讀更多精彩內(nèi)容