dump.rdb file. # # IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append # log file in background when it gets too big. # 默认情况下,redis会在后台异步的把数据库镜像备份到磁盘,但是该备份是非常耗时的, # 而且备份也不能很频繁,如果发生诸如拉闸限电、拔插头等状况,那么将造成比较大范围的数据丢失。 # 所以redis提供了另外一种更加高效的数据库备份及灾难恢复方式。 # 开启append only模式之后,redis会把所接收到的每一次写操作请求都追加到appendonly.aof 文件中, # 当redis重新启动时,会从该文件恢复出之前的状态。但是这样会造成 appendonly.aof 文件过大, # 所以redis还支持了BGREWRITEAOF 指令,对appendonly.aof进行重新整理 appendonly no
18、appendfsync
# 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 will really flush # data on disk, some other OS will 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 you to understand if you can relax this to # "no" that will will let the operating system flush the output buffer when # it wants, for better performances (but 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". # 设置对 appendonly.aof 文件进行同步的频率。 # always 表示每次有写操作都进行同步,everysec表示对写操作进行累积,每秒同步一次。 # appendfsync always appendfsync everysec # appendfsync no
19、vm-enabled
# Virtual Memory allows Redis 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 are taken in memory while the other keys # are 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. # 是否开启虚拟内存支持。因为redis 是一个内存数据库,而且当内存满的时候,无法接收新的写请求, # 所以在redis2.0中,提供了虚拟内存的支持。 # 但是需要注意的是,redis中,所有的key都会放在内存中,在内存不够时,只会把value值放入交换区。 # 这样保证了虽然使用虚拟内存,但性能基本不受影响, # 同时,你需要注意的是你要把vm-max-memory设置到足够来放下你的所有的key vm-enabled no # vm-enabled yes
20、vm-swap-file
# 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 you are running. Redis will complain if the # swap file is already in use. # # The best kind of storage for the Redis swap file (that'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 # only to Redis user and configure Redis to create the swap file there. # 设置虚拟内存的交换文件路径 vm-swap-file /tmp/redis.swap
21、vm-max-memory
# vm-max-memory configures the VM to use at max the specified amount of # RAM. Everything that deos not fit will be swapped on disk *if* possible, that # is, if there is still enough contiguous space in the swap file. # # With vm-max-memory 0 the system will swap everything it can. Not a good # default, just specify the max amount of RAM you can in bytes, but it's # better to leave some margin. For instance specify an amount of RAM # that's more or less between 60 and 80% of your free RAM. # 这里设置开启虚拟内存之后,redis将使用的最大物理内存的大小。 # 默认为0,redis将把他所有的能放到交换文件的都放到交换文件中,以尽量少的使用物理内存。 # 在生产环境下,需要根据实际情况设置该值,最好不要使用默认的 0 vm-max-memory 0
22、vm-pa