[关闭]
@coldxiangyu 2017-04-05T09:14:13.000000Z 字数 20335 阅读 2465

redis安装及相关配置

redis


redis官方运行环境为Linux,由于本地资源所限,采用windows系统。
windows安装配置redis十分简单,windows版本redis下载地址如下:
官方网站:http://redis.io/
官方下载:http://redis.io/download
windows版:https://github.com/mythz/redis-windows
解压下载zip文件,发现目录下有几个exe可执行文件,其中redis-cli.exe、
redis-server.exe分别为客户端与服务端启动程序。
启动redis服务端,如下:

  1. D:\redis\redis-64.3.0.503>redis-server.exe
  2. [6420] 29 Mar 09:27:14.755 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server.exe /path/to/redis.conf
  3. _._
  4. _.-``__ ''-._
  5. _.-`` `. `_. ''-._ Redis 3.0.503 (00000000/0) 64 bit
  6. .-`` .-```. ```\/ _.,_ ''-._
  7. ( ' , .-` | `, ) Running in standalone mode
  8. |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
  9. | `-._ `._ / _.-' | PID: 6420
  10. `-._ `-._ `-./ _.-' _.-'
  11. |`-._`-._ `-.__.-' _.-'_.-'|
  12. | `-._`-._ _.-'_.-' | http://redis.io
  13. `-._ `-._`-.__.-'_.-' _.-'
  14. |`-._`-._ `-.__.-' _.-'_.-'|
  15. | `-._`-._ _.-'_.-' |
  16. `-._ `-._`-.__.-'_.-' _.-'
  17. `-._ `-.__.-' _.-'
  18. `-._ _.-'
  19. `-.__.-'
  20. [6420] 29 Mar 09:27:14.772 # Server started, Redis version 3.0.503
  21. [6420] 29 Mar 09:27:14.773 * The server is now ready to accept connections on port 6379

cmd命令窗口cd至redis安装目录,执行redis-server.exe (redis.conf) 其中redis.conf为redis核心配置,加上的话按该配置运行,不加则以redis默认配置运行,我用的版本redis-64.3.0.503,该配置文件名为redis.windows.conf
启动redis服务器后,另起一个cmd窗口启动客户端,
执行redis-cli.exe -h 127.0.0.1 -p 6379 连接redis服务器
测试如下:

  1. 127.0.0.1:6379> set code test
  2. OK
  3. 127.0.0.1:6379> get code
  4. "test"
  5. 127.0.0.1:6379>

测试成功!

以下为redis.conf相关配置说明:

  1. # Redis configuration file example
  2. # Note on units: when memory size is needed, it is possible to specifiy
  3. # it in the usual form of 1k 5GB 4M and so forth:
  4. #
  5. # 1k => 1000 bytes
  6. # 1kb => 1024 bytes
  7. # 1m => 1000000 bytes
  8. # 1mb => 1024*1024 bytes
  9. # 1g => 1000000000 bytes
  10. # 1gb => 1024*1024*1024 bytes
  11. #
  12. # units are case insensitive so 1GB 1Gb 1gB are all the same.
  13. # By default Redis does not run as a daemon. Use 'yes' if you need it.
  14. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
  15. daemonize no
  16. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程
  17. # When running daemonized, Redis writes a pid file in /var/run/redis.pid by
  18. # default. You can specify a custom pid file location here.
  19. pidfile /var/run/redis.pid
  20. 当Redis以守护进程方式运行时,Redis默认会把pid写入/var/run/redis.pid文件,可以通过pidfile指定
  21. # Accept connections on the specified port, default is 6379.
  22. # If port 0 is specified Redis will not listen on a TCP socket.
  23. port 6379
  24. 指定Redis监听端口,默认端口为6379
  25. # If you want you can bind a single interface, if the bind option is not
  26. # specified all the interfaces will listen for incoming connections.
  27. #
  28. # bind 127.0.0.1
  29. 绑定的主机地址
  30. # Specify the path for the unix socket that will be used to listen for
  31. # incoming connections. There is no default, so Redis will not listen
  32. # on a unix socket when not specified.
  33. #
  34. # unixsocket /tmp/redis.sock
  35. # unixsocketperm 755
  36. # Close the connection after a client is idle for N seconds (0 to disable)
  37. timeout 0
  38. 当 客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能
  39. # Set server verbosity to 'debug'
  40. # it can be one of:
  41. # debug (a lot of information, useful for development/testing)
  42. # verbose (many rarely useful info, but not a mess like the debug level)
  43. # notice (moderately verbose, what you want in production probably)
  44. # warning (only very important / critical messages are logged)
  45. loglevel verbose
  46. 指定日志记录级别,Redis总共支持四个级别:debug、verbose、notice、warning,默认为verbose
  47. # Specify the log file name. Also 'stdout' can be used to force
  48. # Redis to log on the standard output. Note that if you use standard
  49. # output for logging but daemonize, logs will be sent to /dev/null
  50. logfile stdout
  51. 日志记录方式,默认为标准输出,如果配置Redis为守护进程方式运行,而这里又配置为日志记录方式为标准输出,则日志将会发送给/dev/null
  52. # To enable logging to the system logger, just set 'syslog-enabled' to yes,
  53. # and optionally update the other syslog parameters to suit your needs.
  54. # syslog-enabled no
  55. # Specify the syslog identity.
  56. # syslog-ident redis
  57. # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
  58. # syslog-facility local0
  59. # Set the number of databases. The default database is DB 0, you can select
  60. # a different one on a per-connection basis using SELECT <dbid> where
  61. # dbid is a number between 0 and 'databases'-1
  62. databases 16
  63. 设置数据库的数量,默认数据库为0,可以使用SELECT <dbid>命令在连接上指定数据库id
  64. ################################ SNAPSHOTTING #################################
  65. #
  66. # Save the DB on disk:
  67. #
  68. # save <seconds> <changes>
  69. #
  70. # Will save the DB if both the given number of seconds and the given
  71. # number of write operations against the DB occurred.
  72. #
  73. # In the example below the behaviour will be to save:
  74. # after 900 sec (15 min) if at least 1 key changed
  75. # after 300 sec (5 min) if at least 10 keys changed
  76. # after 60 sec if at least 10000 keys changed
  77. #
  78. # Note: you can disable saving at all commenting all the "save" lines.
  79. save 900 1
  80. save 300 10
  81. save 60 10000
  82. 分别表示900秒(15分钟)内有1个更改,300秒(5分钟)内有10个更改以及60秒内有10000个更改。
  83. 指定在多长时间内,有多少次更新操作,就将数据同步到数据文件,可以多个条件配合
  84. # Compress string objects using LZF when dump .rdb databases?
  85. # For default that's set to 'yes' as it's almost always a win.
  86. # If you want to save some CPU in the saving child set it to 'no' but
  87. # the dataset will likely be bigger if you have compressible values or keys.
  88. rdbcompression yes
  89. 指定存储至本地数据库时是否压缩数据,默认为yes,Redis采用LZF压缩,如果为了节省CPU时间,可以关闭该选项,但会导致数据库文件变的巨大
  90. # The filename where to dump the DB
  91. dbfilename dump.rdb
  92. 指定本地数据库文件名,默认值为dump.rdb
  93. # The working directory.
  94. #
  95. # The DB will be written inside this directory, with the filename specified
  96. # above using the 'dbfilename' configuration directive.
  97. #
  98. # Also the Append Only File will be created inside this directory.
  99. #
  100. # Note that you must specify a directory here, not a file name.
  101. dir ./
  102. 指定本地数据库存放目录
  103. ################################# REPLICATION #################################
  104. # Master-Slave replication. Use slaveof to make a Redis instance a copy of
  105. # another Redis server. Note that the configuration is local to the slave
  106. # so for example it is possible to configure the slave to save the DB with a
  107. # different interval, or to listen to another port, and so on.
  108. #
  109. # slaveof <masterip> <masterport>
  110. slaveof <masterip> <masterport> 设置当本机为slav服务时,设置master服务的IP地址及端口,在Redis启动时,它会自动从master进行数据同步
  111. # If the master is password protected (using the "requirepass" configuration
  112. # directive below) it is possible to tell the slave to authenticate before
  113. # starting the replication synchronization process, otherwise the master will
  114. # refuse the slave request.
  115. #
  116. # masterauth <master-password>
  117. masterauth <master-password> 当master服务设置了密码保护时,slav服务连接master的密码
  118. # When a slave lost the connection with the master, or when the replication
  119. # is still in progress, the slave can act in two different ways:
  120. #
  121. # 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
  122. # still reply to client requests, possibly with out of data data, or the
  123. # data set may just be empty if this is the first synchronization.
  124. #
  125. # 2) if slave-serve-stale data is set to 'no' the slave will reply with
  126. # an error "SYNC with master in progress" to all the kind of commands
  127. # but to INFO and SLAVEOF.
  128. #
  129. slave-serve-stale-data yes
  130. # Slaves send PINGs to server in a predefined interval. It's possible to change
  131. # this interval with the repl_ping_slave_period option. The default value is 10
  132. # seconds.
  133. #
  134. # repl-ping-slave-period 10
  135. # The following option sets a timeout for both Bulk transfer I/O timeout and
  136. # master data or ping response timeout. The default value is 60 seconds.
  137. #
  138. # It is important to make sure that this value is greater than the value
  139. # specified for repl-ping-slave-period otherwise a timeout will be detected
  140. # every time there is low traffic between the master and the slave.
  141. #
  142. # repl-timeout 60
  143. ################################## SECURITY ###################################
  144. # Require clients to issue AUTH <PASSWORD> before processing any other
  145. # commands. This might be useful in environments in which you do not trust
  146. # others with access to the host running redis-server.
  147. #
  148. # This should stay commented out for backward compatibility and because most
  149. # people do not need auth (e.g. they run their own servers).
  150. #
  151. # Warning: since Redis is pretty fast an outside user can try up to
  152. # 150k passwords per second against a good box. This means that you should
  153. # use a very strong password otherwise it will be very easy to break.
  154. #
  155. # requirepass foobared
  156. requirepass foobared 设置Redis连接密码,如果配置了连接密码,客户端在连接Redis时需要通过AUTH <password>命令提供密码,默认关闭
  157. # Command renaming.
  158. #
  159. # It is possilbe to change the name of dangerous commands in a shared
  160. # environment. For instance the CONFIG command may be renamed into something
  161. # of hard to guess so that it will be still available for internal-use
  162. # tools but not available for general clients.
  163. #
  164. # Example:
  165. #
  166. # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
  167. #
  168. # It is also possilbe to completely kill a command renaming it into
  169. # an empty string:
  170. #
  171. # rename-command CONFIG ""
  172. ################################### LIMITS ####################################
  173. # Set the max number of connected clients at the same time. By default there
  174. # is no limit, and it's up to the number of file descriptors the Redis process
  175. # is able to open. The special value '0' means no limits.
  176. # Once the limit is reached Redis will close all the new connections sending
  177. # an error 'max number of clients reached'.
  178. #
  179. # maxclients 128
  180. maxclients 128 设置同一时间最大客户端连接数,默认无限制,Redis可以同时打开的客户端连接数为Redis进程可以打开的最大文件描述符数,如果设置 maxclients 0,表示不作限制。当客户端连接数到达限制时,Redis会关闭新的连接并向客户端返回max number of clients reached错误信息
  181. # Don't use more memory than the specified amount of bytes.
  182. # When the memory limit is reached Redis will try to remove keys with an
  183. # EXPIRE set. It will try to start freeing keys that are going to expire
  184. # in little time and preserve keys with a longer time to live.
  185. # Redis will also try to remove objects from free lists if possible.
  186. #
  187. # If all this fails, Redis will start to reply with errors to commands
  188. # that will use more memory, like SET, LPUSH, and so on, and will continue
  189. # to reply to most read-only commands like GET.
  190. #
  191. # WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
  192. # 'state' server or cache, not as a real DB. When Redis is used as a real
  193. # database the memory usage will grow over the weeks, it will be obvious if
  194. # it is going to use too much memory in the long run, and you'll have the time
  195. # to upgrade. With maxmemory after the limit is reached you'll start to get
  196. # errors for write operations, and this may even lead to DB inconsistency.
  197. #
  198. # maxmemory <bytes>
  199. maxmemory <bytes>指定Redis最大内存限制,Redis在启动时会把数据加载到内存中,达到最大内存后,Redis会先尝试清除已到期或即将到期的Key,当此方法处理 后,仍然到达最大内存设置,将无法再进行写入操作,但仍然可以进行读取操作。Redis新的vm机制,会把Key存放内存,Value会存放在swap区
  200. # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
  201. # is reached? You can select among five behavior:
  202. #
  203. # volatile-lru -> remove the key with an expire set using an LRU algorithm
  204. # allkeys-lru -> remove any key accordingly to the LRU algorithm
  205. # volatile-random -> remove a random key with an expire set
  206. # allkeys->random -> remove a random key, any key
  207. # volatile-ttl -> remove the key with the nearest expire time (minor TTL)
  208. # noeviction -> don't expire at all, just return an error on write operations
  209. #
  210. # Note: with all the kind of policies, Redis will return an error on write
  211. # operations, when there are not suitable keys for eviction.
  212. #
  213. # At the date of writing this commands are: set setnx setex append
  214. # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
  215. # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
  216. # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
  217. # getset mset msetnx exec sort
  218. #
  219. # The default is:
  220. #
  221. # maxmemory-policy volatile-lru
  222. # LRU and minimal TTL algorithms are not precise algorithms but approximated
  223. # algorithms (in order to save memory), so you can select as well the sample
  224. # size to check. For instance for default Redis will check three keys and
  225. # pick the one that was used less recently, you can change the sample size
  226. # using the following configuration directive.
  227. #
  228. # maxmemory-samples 3
  229. ############################## APPEND ONLY MODE ###############################
  230. # By default Redis asynchronously dumps the dataset on disk. If you can live
  231. # with the idea that the latest records will be lost if something like a crash
  232. # happens this is the preferred way to run Redis. If instead you care a lot
  233. # about your data and don't want to that a single record can get lost you should
  234. # enable the append only mode: when this mode is enabled Redis will append
  235. # every write operation received in the file appendonly.aof. This file will
  236. # be read on startup in order to rebuild the full dataset in memory.
  237. #
  238. # Note that you can have both the async dumps and the append only file if you
  239. # like (you have to comment the "save" statements above to disable the dumps).
  240. # Still if append only mode is enabled Redis will load the data from the
  241. # log file at startup ignoring the dump.rdb file.
  242. #
  243. # IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
  244. # log file in background when it gets too big.
  245. appendonly no
  246. appendonly no指定是否在每次更新操作后进行日志记录,Redis在默认情况下是异步的把数据写入磁盘,如果不开启,可能会在断电时导致一段时间内的数据丢失。因为 redis本身同步数据文件是按上面save条件来同步的,所以有的数据会在一段时间内只存在于内存中。默认为no
  247. # The name of the append only file (default: "appendonly.aof")
  248. # appendfilename appendonly.aof
  249. appendfilename appendonly.aof指定更新日志文件名,默认为appendonly.aof
  250. # The fsync() call tells the Operating System to actually write data on disk
  251. # instead to wait for more data in the output buffer. Some OS will really flush
  252. # data on disk, some other OS will just try to do it ASAP.
  253. #
  254. # Redis supports three different modes:
  255. #
  256. # no: don't fsync, just let the OS flush the data when it wants. Faster.
  257. # always: fsync after every write to the append only log . Slow, Safest.
  258. # everysec: fsync only if one second passed since the last fsync. Compromise.
  259. #
  260. # The default is "everysec" that's usually the right compromise between
  261. # speed and data safety. It's up to you to understand if you can relax this to
  262. # "no" that will will let the operating system flush the output buffer when
  263. # it wants, for better performances (but if you can live with the idea of
  264. # some data loss consider the default persistence mode that's snapshotting),
  265. # or on the contrary, use "always" that's very slow but a bit safer than
  266. # everysec.
  267. #
  268. # If unsure, use "everysec".
  269. # appendfsync always
  270. appendfsync everysec
  271. # appendfsync no
  272. 指定更新日志条件,共有3个可选值:
  273. no:表示等操作系统进行数据缓存同步到磁盘(快)
  274. always:表示每次更新操作后手动调用fsync()将数据写到磁盘(慢,安全)
  275. everysec:表示每秒同步一次(折衷,默认值)
  276. # When the AOF fsync policy is set to always or everysec, and a background
  277. # saving process (a background save or AOF log background rewriting) is
  278. # performing a lot of I/O against the disk, in some Linux configurations
  279. # Redis may block too long on the fsync() call. Note that there is no fix for
  280. # this currently, as even performing fsync in a different thread will block
  281. # our synchronous write(2) call.
  282. #
  283. # In order to mitigate this problem it's possible to use the following option
  284. # that will prevent fsync() from being called in the main process while a
  285. # BGSAVE or BGREWRITEAOF is in progress.
  286. #
  287. # This means that while another child is saving the durability of Redis is
  288. # the same as "appendfsync none", that in pratical terms means that it is
  289. # possible to lost up to 30 seconds of log in the worst scenario (with the
  290. # default Linux settings).
  291. #
  292. # If you have latency problems turn this to "yes". Otherwise leave it as
  293. # "no" that is the safest pick from the point of view of durability.
  294. no-appendfsync-on-rewrite no
  295. # Automatic rewrite of the append only file.
  296. # Redis is able to automatically rewrite the log file implicitly calling
  297. # BGREWRITEAOF when the AOF log size will growth by the specified percentage.
  298. #
  299. # This is how it works: Redis remembers the size of the AOF file after the
  300. # latest rewrite (or if no rewrite happened since the restart, the size of
  301. # the AOF at startup is used).
  302. #
  303. # This base size is compared to the current size. If the current size is
  304. # bigger than the specified percentage, the rewrite is triggered. Also
  305. # you need to specify a minimal size for the AOF file to be rewritten, this
  306. # is useful to avoid rewriting the AOF file even if the percentage increase
  307. # is reached but it is still pretty small.
  308. #
  309. # Specify a precentage of zero in order to disable the automatic AOF
  310. # rewrite feature.
  311. auto-aof-rewrite-percentage 100
  312. auto-aof-rewrite-min-size 64mb
  313. ################################## SLOW LOG ###################################
  314. # The Redis Slow Log is a system to log queries that exceeded a specified
  315. # execution time. The execution time does not include the I/O operations
  316. # like talking with the client, sending the reply and so forth,
  317. # but just the time needed to actually execute the command (this is the only
  318. # stage of command execution where the thread is blocked and can not serve
  319. # other requests in the meantime).
  320. #
  321. # You can configure the slow log with two parameters: one tells Redis
  322. # what is the execution time, in microseconds, to exceed in order for the
  323. # command to get logged, and the other parameter is the length of the
  324. # slow log. When a new command is logged the oldest one is removed from the
  325. # queue of logged commands.
  326. # The following time is expressed in microseconds, so 1000000 is equivalent
  327. # to one second. Note that a negative number disables the slow log, while
  328. # a value of zero forces the logging of every command.
  329. slowlog-log-slower-than 10000
  330. # There is no limit to this length. Just be aware that it will consume memory.
  331. # You can reclaim memory used by the slow log with SLOWLOG RESET.
  332. slowlog-max-len 1024
  333. ################################ VIRTUAL MEMORY ###############################
  334. ### WARNING! Virtual Memory is deprecated in Redis 2.4
  335. ### The use of Virtual Memory is strongly discouraged.
  336. ### WARNING! Virtual Memory is deprecated in Redis 2.4
  337. ### The use of Virtual Memory is strongly discouraged.
  338. # Virtual Memory allows Redis to work with datasets bigger than the actual
  339. # amount of RAM needed to hold the whole dataset in memory.
  340. # In order to do so very used keys are taken in memory while the other keys
  341. # are swapped into a swap file, similarly to what operating systems do
  342. # with memory pages.
  343. #
  344. # To enable VM just set 'vm-enabled' to yes, and set the following three
  345. # VM parameters accordingly to your needs.
  346. vm-enabled no
  347. 指定是否启用虚拟内存机制,默认值为no,简单的介绍一下,VM机制将数据分页存放,由Redis将访问量较少的页即冷数据swap到磁盘上,访问多的页面由磁盘自动换出到内存中(在后面的文章我会仔细分析Redis的VM机制)
  348. # vm-enabled yes
  349. # This is the path of the Redis swap file. As you can guess, swap files
  350. # can't be shared by different Redis instances, so make sure to use a swap
  351. # file for every redis process you are running. Redis will complain if the
  352. # swap file is already in use.
  353. #
  354. # The best kind of storage for the Redis swap file (that's accessed at random)
  355. # is a Solid State Disk (SSD).
  356. #
  357. # *** WARNING *** if you are using a shared hosting the default of putting
  358. # the swap file under /tmp is not secure. Create a dir with access granted
  359. # only to Redis user and configure Redis to create the swap file there.
  360. vm-swap-file /tmp/redis.swap
  361. 虚拟内存文件路径,默认值为/tmp/redis.swap,不可多个Redis实例共享
  362. # vm-max-memory configures the VM to use at max the specified amount of
  363. # RAM. Everything that deos not fit will be swapped on disk *if* possible, that
  364. # is, if there is still enough contiguous space in the swap file.
  365. #
  366. # With vm-max-memory 0 the system will swap everything it can. Not a good
  367. # default, just specify the max amount of RAM you can in bytes, but it's
  368. # better to leave some margin. For instance specify an amount of RAM
  369. # that's more or less between 60 and 80% of your free RAM.
  370. vm-max-memory 0
  371. 将所有大于vm-max-memory的数据存入虚拟内存,无论vm-max-memory设置多小,所有索引数据都是内存存储的(Redis的索引数据 就是keys),也就是说,当vm-max-memory设置为0的时候,其实是所有value都存在于磁盘。默认值为0
  372. # Redis swap files is split into pages. An object can be saved using multiple
  373. # contiguous pages, but pages can't be shared between different objects.
  374. # So if your page is too big, small objects swapped out on disk will waste
  375. # a lot of space. If you page is too small, there is less space in the swap
  376. # file (assuming you configured the same number of total swap file pages).
  377. #
  378. # If you use a lot of small objects, use a page size of 64 or 32 bytes.
  379. # If you use a lot of big objects, use a bigger page size.
  380. # If unsure, use the default :)
  381. vm-page-size 32
  382. Redis swap文件分成了很多的page,一个对象可以保存在多个page上面,但一个page上不能被多个对象共享,vm-page-size是要根据存储的 数据大小来设定的,作者建议如果存储很多小对象,page大小最好设置为32或者64bytes;如果存储很大大对象,则可以使用更大的page,如果不 确定,就使用默认值
  383. # Number of total memory pages in the swap file.
  384. # Given that the page table (a bitmap of free/used pages) is taken in memory,
  385. # every 8 pages on disk will consume 1 byte of RAM.
  386. #
  387. # The total swap size is vm-page-size * vm-pages
  388. #
  389. # With the default of 32-bytes memory pages and 134217728 pages Redis will
  390. # use a 4 GB swap file, that will use 16 MB of RAM for the page table.
  391. #
  392. # It's better to use the smallest acceptable value for your application,
  393. # but the default is large in order to work in most conditions.
  394. vm-pages 134217728
  395. 设置swap文件中的page数量,由于页表(一种表示页面空闲或使用的bitmap)是在放在内存中的,,在磁盘上每8个pages将消耗1byte的内存。
  396. # Max number of VM I/O threads running at the same time.
  397. # This threads are used to read/write data from/to swap file, since they
  398. # also encode and decode objects from disk to memory or the reverse, a bigger
  399. # number of threads can help with big objects even if they can't help with
  400. # I/O itself as the physical device may not be able to couple with many
  401. # reads/writes operations at the same time.
  402. #
  403. # The special value of 0 turn off threaded I/O and enables the blocking
  404. # Virtual Memory implementation.
  405. vm-max-threads 4
  406. 设置访问swap文件的线程数,最好不要超过机器的核数,如果设置为0,那么所有对swap文件的操作都是串行的,可能会造成比较长时间的延迟。默认值为4
  407. ############################### ADVANCED CONFIG ###############################
  408. # Hashes are encoded in a special way (much more memory efficient) when they
  409. # have at max a given numer of elements, and the biggest element does not
  410. # exceed a given threshold. You can configure this limits with the following
  411. # configuration directives.
  412. hash-max-zipmap-entries 512
  413. hash-max-zipmap-value 64
  414. 指定在超过一定的数量或者最大的元素超过某一临界值时,采用一种特殊的哈希算法
  415. # Similarly to hashes, small lists are also encoded in a special way in order
  416. # to save a lot of space. The special representation is only used when
  417. # you are under the following limits:
  418. list-max-ziplist-entries 512
  419. list-max-ziplist-value 64
  420. # Sets have a special encoding in just one case: when a set is composed
  421. # of just strings that happens to be integers in radix 10 in the range
  422. # of 64 bit signed integers.
  423. # The following configuration setting sets the limit in the size of the
  424. # set in order to use this special memory saving encoding.
  425. set-max-intset-entries 512
  426. # Similarly to hashes and lists, sorted sets are also specially encoded in
  427. # order to save a lot of space. This encoding is only used when the length and
  428. # elements of a sorted set are below the following limits:
  429. zset-max-ziplist-entries 128
  430. zset-max-ziplist-value 64
  431. # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
  432. # order to help rehashing the main Redis hash table (the one mapping top-level
  433. # keys to values). The hash table implementation redis uses (see dict.c)
  434. # performs a lazy rehashing: the more operation you run into an hash table
  435. # that is rhashing, the more rehashing "steps" are performed, so if the
  436. # server is idle the rehashing is never complete and some more memory is used
  437. # by the hash table.
  438. #
  439. # The default is to use this millisecond 10 times every second in order to
  440. # active rehashing the main dictionaries, freeing memory when possible.
  441. #
  442. # If unsure:
  443. # use "activerehashing no" if you have hard latency requirements and it is
  444. # not a good thing in your environment that Redis can reply form time to time
  445. # to queries with 2 milliseconds delay.
  446. #
  447. # use "activerehashing yes" if you don't have such hard requirements but
  448. # want to free memory asap when possible.
  449. activerehashing yes
  450. ################################## INCLUDES ###################################
  451. # Include one or more other config files here. This is useful if you
  452. # have a standard template that goes to all redis server but also need
  453. # to customize a few per-server settings. Include files can include
  454. # other files, so use this wisely.
  455. #
  456. # include /path/to/local.conf
  457. # include /path/to/other.conf
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注