{"id":187,"date":"2011-07-29T13:25:17","date_gmt":"2011-07-29T13:25:17","guid":{"rendered":"31fefc0e570cb3860f2a6d4b38c6490d"},"modified":"2011-07-29T13:25:17","modified_gmt":"2011-07-29T13:25:17","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/187","title":{"rendered":"REDIS WINDOWS \u4e0b\u914d\u7f6e"},"content":{"rendered":"<p>Windows\u7248\u7684Redis\u53ef\u5230\u6b64\u5904\u4e0b\u8f7d\uff0c\u975e\u5b98\u65b9\u7248<br \/>\n<a href=\"http:\/\/code.google.com\/p\/servicestack\/wiki\/RedisWindowsDownload\"><span style=\"color:#1463c4;\">http:\/\/code.google.com\/p\/servicestack\/wiki\/RedisWindowsDownload<\/span><\/a><\/p>\n<p>redis.conf<br \/>\n\u590d\u5236\u4ee5\u4e0b===\u4e0e====\u4e4b\u5185\u7684\u5185\u5bb9<br \/>\n=================================<br \/>\n# Redis configuration file example<\/p>\n<p># By default Redis does not run as a daemon. Use 'yes' if you need it.<br \/>\n# Note that Redis will write a pid file in \/var\/run\/redis.pid when daemonized.<br \/>\ndaemonize no<\/p>\n<p># When run as a daemon, Redis write a pid file in \/var\/run\/redis.pid by default.<br \/>\n# You can specify a custom pid file location here.<br \/>\npidfile \/var\/run\/redis.pid<\/p>\n<p># Accept connections on the specified port, default is 6379<br \/>\nport 6379<\/p>\n<p># If you want you can bind a single interface, if the bind option is not<br \/>\n# specified all the interfaces will listen for connections.<br \/>\n#<br \/>\n# bind 127.0.0.1<\/p>\n<p># Close the connection after a client is idle for N seconds (0 to disable)<br \/>\ntimeout 300<\/p>\n<p># Set server verbosity to 'debug'<br \/>\n# it can be one of:<br \/>\n# debug (a lot of information, useful for development\/testing)<br \/>\n# notice (moderately verbose, what you want in production probably)<br \/>\n# warning (only very important \/ critical messages are logged)<br \/>\nloglevel debug<\/p>\n<p># Specify the log file name. Also 'stdout' can be used to force<br \/>\n# the demon to log on the standard output. Note that if you use standard<br \/>\n# output for logging but daemonize, logs will be sent to \/dev\/null<br \/>\nlogfile stdout<\/p>\n<p># Set the number of databases. The default database is DB 0, you can select<br \/>\n# a different one on a per-connection basis using SELECT &lt;dbid&gt; where<br \/>\n# dbid is a number between 0 and 'databases'-1<br \/>\ndatabases 16<\/p>\n<p>################################ SNAPSHOTTING&nbsp; #################################<br \/>\n#<br \/>\n# Save the DB on disk:<br \/>\n#<br \/>\n#&nbsp;&nbsp; save &lt;seconds&gt; &lt;changes&gt;<br \/>\n#<br \/>\n#&nbsp;&nbsp; Will save the DB if both the given number of seconds and the given<br \/>\n#&nbsp;&nbsp; number of write operations against the DB occurred.<br \/>\n#<br \/>\n#&nbsp;&nbsp; In the example below the behaviour will be to save:<br \/>\n#&nbsp;&nbsp; after 900 sec (15 min) if at least 1 key changed<br \/>\n#&nbsp;&nbsp; after 300 sec (5 min) if at least 10 keys changed<br \/>\n#&nbsp;&nbsp; after 60 sec if at least 10000 keys changed<br \/>\nsave 900 1<br \/>\nsave 300 10<br \/>\nsave 60 10000<\/p>\n<p># Compress string objects using LZF when dump .rdb databases?<br \/>\n# For default that's set to 'yes' as it's almost always a win.<br \/>\n# If you want to save some CPU in the saving child set it to 'no' but<br \/>\n# the dataset will likely be bigger if you have compressible values or keys.<br \/>\nrdbcompression yes<\/p>\n<p># The filename where to dump the DB<br \/>\ndbfilename dump.rdb<\/p>\n<p># For default save\/load DB in\/from the working directory<br \/>\n# Note that you must specify a directory not a file name.<br \/>\ndir .\/<\/p>\n<p>################################# REPLICATION #################################<\/p>\n<p># Master-Slave replication. Use slaveof to make a Redis instance a copy of<br \/>\n# another Redis server. Note that the configuration is local to the slave<br \/>\n# so for example it is possible to configure the slave to save the DB with a<br \/>\n# different interval, or to listen to another port, and so on.<br \/>\n#<br \/>\n# slaveof &lt;masterip&gt; &lt;masterport&gt;<\/p>\n<p># If the master is password protected (using the \"requirepass\" configuration<br \/>\n# directive below) it is possible to tell the slave to authenticate before<br \/>\n# starting the replication synchronization process, otherwise the master will<br \/>\n# refuse the slave request.<br \/>\n#<br \/>\n# masterauth &lt;master-password&gt;<\/p>\n<p>################################## SECURITY ###################################<\/p>\n<p># Require clients to issue AUTH &lt;PASSWORD&gt; before processing any other<br \/>\n# commands.&nbsp; This might be useful in environments in which you do not trust<br \/>\n# others with access to the host running redis-server.<br \/>\n#<br \/>\n# This should stay commented out for backward compatibility and because most<br \/>\n# people do not need auth (e.g. they run their own servers).<br \/>\n#<br \/>\n# requirepass foobared<\/p>\n<p>################################### LIMITS ####################################<\/p>\n<p># Set the max number of connected clients at the same time. By default there<br \/>\n# is no limit, and it's up to the number of file descriptors the Redis process<br \/>\n# is able to open. The special value '0' means no limts.<br \/>\n# Once the limit is reached Redis will close all the new connections sending<br \/>\n# an error 'max number of clients reached'.<br \/>\n#<br \/>\n# maxclients 128<\/p>\n<p># Don't use more memory than the specified amount of bytes.<br \/>\n# When the memory limit is reached Redis will try to remove keys with an<br \/>\n# EXPIRE set. It will try to start freeing keys that are going to expire<br \/>\n# in little time and preserve keys with a longer time to live.<br \/>\n# Redis will also try to remove objects from free lists if possible.<br \/>\n#<br \/>\n# If all this fails, Redis will start to reply with errors to commands<br \/>\n# that will use more memory, like SET, LPUSH, and so on, and will continue<br \/>\n# to reply to most read-only commands like GET.<br \/>\n#<br \/>\n# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a<br \/>\n# 'state' server or cache, not as a real DB. When Redis is used as a real<br \/>\n# database the memory usage will grow over the weeks, it will be obvious if<br \/>\n# it is going to use too much memory in the long run, and you'll have the time<br \/>\n# to upgrade. With maxmemory after the limit is reached you'll start to get<br \/>\n# errors for write operations, and this may even lead to DB inconsistency.<br \/>\n#<br \/>\n# maxmemory &lt;bytes&gt;<\/p>\n<p>############################## APPEND ONLY MODE ###############################<\/p>\n<p># By default Redis asynchronously dumps the dataset on disk. If you can live<br \/>\n# with the idea that the latest records will be lost if something like a crash<br \/>\n# happens this is the preferred way to run Redis. If instead you care a lot<br \/>\n# about your data and don't want to that a single record can get lost you should<br \/>\n# enable the append only mode: when this mode is enabled Redis will append<br \/>\n# every write operation received in the file appendonly.log. This file will<br \/>\n# be read on startup in order to rebuild the full dataset in memory.<br \/>\n#<br \/>\n# Note that you can have both the async dumps and the append only file if you<br \/>\n# like (you have to comment the \"save\" statements above to disable the dumps).<br \/>\n# Still if append only mode is enabled Redis will load the data from the<br \/>\n# log file at startup ignoring the dump.rdb file.<br \/>\n#<br \/>\n# The name of the append only file is \"appendonly.log\"<br \/>\n#<br \/>\n# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append<br \/>\n# log file in background when it gets too big.<\/p>\n<p>appendonly no<\/p>\n<p># The fsync() call tells the Operating System to actually write data on disk<br \/>\n# instead to wait for more data in the output buffer. Some OS will really flush <br \/>\n# data on disk, some other OS will just try to do it ASAP.<br \/>\n#<br \/>\n# Redis supports three different modes:<br \/>\n#<br \/>\n# no: don't fsync, just let the OS flush the data when it wants. Faster.<br \/>\n# always: fsync after every write to the append only log . Slow, Safest.<br \/>\n# everysec: fsync only if one second passed since the last fsync. Compromise.<br \/>\n#<br \/>\n# The default is \"always\" that's the safer of the options. It's up to you to<br \/>\n# understand if you can relax this to \"everysec\" that will fsync every second<br \/>\n# or to \"no\" that will let the operating system flush the output buffer when<br \/>\n# it want, for better performances (but if you can live with the idea of<br \/>\n# some data loss consider the default persistence mode that's snapshotting).<\/p>\n<p>appendfsync always<br \/>\n# appendfsync everysec<br \/>\n# appendfsync no<\/p>\n<p>############################### ADVANCED CONFIG ###############################<\/p>\n<p># Glue small output buffers together in order to send small replies in a<br \/>\n# single TCP packet. Uses a bit more CPU but most of the times it is a win<br \/>\n# in terms of number of queries per second. Use 'yes' if unsure.<br \/>\nglueoutputbuf yes<\/p>\n<p># Use object sharing. Can save a lot of memory if you have many common<br \/>\n# string in your dataset, but performs lookups against the shared objects<br \/>\n# pool so it uses more CPU and can be a bit slower. Usually it's a good<br \/>\n# idea.<br \/>\n#<br \/>\n# When object sharing is enabled (shareobjects yes) you can use<br \/>\n# shareobjectspoolsize to control the size of the pool used in order to try<br \/>\n# object sharing. A bigger pool size will lead to better sharing capabilities.<br \/>\n# In general you want this value to be at least the double of the number of<br \/>\n# very common strings you have in your dataset.<br \/>\n#<br \/>\n# WARNING: object sharing is experimental, don't enable this feature<br \/>\n# in production before of Redis 1.0-stable. Still please try this feature in<br \/>\n# your development environment so that we can test it better.<br \/>\n# shareobjects no<br \/>\n# shareobjectspoolsize 1024<\/p>\n<p>================================================<br \/>\n\u5c06\u4ee5\u4e0a\u5185\u5bb9\u5b58\u50a8\u4e3aredis.conf<\/p>\n<p>\u89e3\u538b\u4e0b\u8f7d\u7684redis\u5305\u3002\u6211\u7684windows\u4e0b\u7684\u89e3\u538b\u5730\u5740\u662fD:\\redis-2.0.2<br \/>\n\u5c06redis.conf \u62f7\u8d1d\u5230D:\\redis-2.0.2\\\u4e0b<\/p>\n<p>\u6307\u5b9aredis\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u6ca1\u6709\u6307\u5b9a\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e<br \/>\n<span style=\"color:#008000;\">D:\\redis-2.0.2&gt;redis-server.exe redis.conf<\/span><\/p>\n<p>\u5982\u4e0b\u56fe\u5219\u5f00\u542f\u6b63\u5e38<br \/>\n<a id=\"ematt:363\" href=\"\/notes\/content\/uploadfile\/201510\/f3cc1444383895.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201510\/f3cc1444383895.jpg\" \/><\/a><\/p>\n<p>\u65b0\u5f00\u4e00\u4e2acmd\u547d\u4ee4\u7a97\u53e3<br \/>\nredis-cli.exe\uff1a\u547d\u4ee4\u884c\u5ba2\u6237\u7aef\uff0c\u6d4b\u8bd5\u7528<br \/>\n<span style=\"color:#008000;\">D:\\redis-2.0.2&gt;redis-cli.exe -h 192.168.10.59 -p 6379<br \/>\n192.168.10.59 \u662f\u6211\u672c\u5730\u7684\u5730\u5740<\/p>\n<p><\/span>\u5982\u4e0b\u56fe\u5219<br \/>\n<span style=\"color:#008000;\"><br \/>\n<\/span><a id=\"ematt:364\" href=\"\/notes\/content\/uploadfile\/201510\/15601444383895.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201510\/15601444383895.jpg\" \/><\/a><\/p>\n<p>\n\u73a9redis\u5427~~<br \/>\n<a id=\"ematt:365\" href=\"\/notes\/content\/uploadfile\/201510\/799b1444383895.jpg\" target=\"_blank\"><img decoding=\"async\" border=\"0\" alt=\"\u70b9\u51fb\u67e5\u770b\u539f\u56fe\" src=\"\/notes\/content\/uploadfile\/201510\/799b1444383895.jpg\" \/><\/a><\/p>\n<p>------------------------------------------------------------------------------------------------<\/p>\n<p>\u53e6\u4e00\u6458\u8981<\/p>\n<p>------------------------------------------------------------------------------------------------<\/p>\n<p><strong>window\u5e73\u53f0Redis\u5b89\u88c5<\/strong><\/p>\n<p>\u4e0b\u8f7d\u5730\u5740: <a href=\"http:\/\/code.google.com\/p\/servicestack\/wiki\/RedisWindowsDownload\" target=\"_blank\">http:\/\/code.google.com\/p\/servicestack\/wiki\/RedisWindowsDownload <\/a><\/p>\n<blockquote>\n<p>Redis\u6587\u4ef6\u5939\u6709\u4ee5\u4e0b\u51e0\u4e2a\u6587\u4ef6<\/p>\n<\/blockquote>\n<div>\n<blockquote>\n<p>redis-server.exe\uff1a\u670d\u52a1\u7a0b\u5e8f<\/p>\n<p>redis-check-dump.exe\uff1a\u672c\u5730\u6570\u636e\u5e93\u68c0\u67e5<\/p>\n<p>redis-check-aof.exe\uff1a\u66f4\u65b0\u65e5\u5fd7\u68c0\u67e5<\/p>\n<p>redis-benchmark.exe\uff1a\u6027\u80fd\u6d4b\u8bd5\uff0c\u7528\u4ee5\u6a21\u62df\u540c\u65f6\u7531N\u4e2a\u5ba2\u6237\u7aef\u53d1\u9001M\u4e2a SETs\/GETs \u67e5\u8be2 (\u7c7b\u4f3c\u4e8e Apache \u7684ab \u5de5\u5177).<\/p>\n<\/blockquote>\n<\/div>\n<p>\u6307\u5b9aredis\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u6ca1\u6709\u6307\u5b9a\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e<\/p>\n<p>\u89e3\u538b\u76ee\u5f55:<\/p>\n<blockquote>\n<p>d:\\&gt;redis-server.exe<\/p>\n<\/blockquote>\n<p>redis-cli.exe\uff1a\u547d\u4ee4\u884c\u5ba2\u6237\u7aef\uff0c\u6d4b\u8bd5\u7528.windows\u4e0b\u6ca1\u6709redis.conf\u914d\u7f6e\u6587\u4ef6. &nbsp;<\/p>\n<div>\n<div>\u89e3\u538b\u76ee\u5f55:<\/div>\n<blockquote>\n<div>d:\\&gt;redis-cli.exe&nbsp;-h&nbsp;127.0.0.1&nbsp;-p&nbsp;6379<\/div>\n<\/blockquote>\n<\/div>\n<p>\u4f7f\u7528\u65b9\u6cd5\u6709\u4e24\u79cd:\u4e00\u79cd\u662f\u76f4\u63a5\u4f7f\u7528redis-cli.exe \u540e\u9762\u52a0\u64cd\u4f5c,\u53e6\u4e00\u79cd\u662f\u76f4\u63a5\u8f93\u5165redis-cli.exe\u8fdb\u5165\u7ba1\u7406\u754c\u9762,\u7136\u540e\u76f4\u63a5\u5728redis\u63d0\u793a\u7b26\u4e0b\u8f93\u5165\u547d\u4ee4\u5373\u53ef.<\/p>\n<p>\u8bbe\u7f6e\u4e00\u4e2aKey\u5e76\u83b7\u53d6\u8fd4\u56de\u7684\u503c:<\/p>\n<div>\n<div>\n<blockquote>\n<p>$&nbsp;.\/redis-cli&nbsp;set&nbsp;mykey&nbsp;somevalue<\/p>\n<p>OK<\/p>\n<p>$&nbsp;.\/redis-cli&nbsp;get&nbsp;mykey<\/p>\n<p>Somevalue<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>\u5982\u4f55\u6dfb\u52a0\u503c\u5230list:<\/p>\n<div>\n<div id=\"cnblogs_code_open_8e6fb389-7f46-4f5c-9c72-eb11ed630fe4\">\n<div>\n<blockquote>\n<p>$&nbsp;.\/redis-cli&nbsp;lpush&nbsp;mylist&nbsp;firstvalue<\/p>\n<p>OK<\/p>\n<p>$&nbsp;.\/redis-cli&nbsp;lpush&nbsp;mylist&nbsp;secondvalue<\/p>\n<p>OK<\/p>\n<p>$&nbsp;.\/redis-cli&nbsp;lpush&nbsp;mylist&nbsp;thirdvalue<\/p>\n<p>OK<\/p>\n<p>$&nbsp;.\/redis-cli&nbsp;lrange&nbsp;mylist&nbsp;0&nbsp;-1<\/p>\n<p>1.&nbsp;thirdvalue<\/p>\n<p>2.&nbsp;secondvalue<\/p>\n<p>3.&nbsp;firstvalue<\/p>\n<p>$&nbsp;.\/redis-cli&nbsp;rpop&nbsp;mylist<\/p>\n<p>firstvalue<\/p>\n<p>$&nbsp;.\/redis-cli&nbsp;lrange&nbsp;mylist&nbsp;0&nbsp;-1<\/p>\n<p>1.&nbsp;thirdvalue<\/p>\n<p>2.&nbsp;secondvalue<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><strong>redis-benchmark.exe\uff1a<\/strong>\u6027\u80fd\u6d4b\u8bd5\uff0c\u7528\u4ee5\u6a21\u62df\u540c\u65f6\u7531N\u4e2a\u5ba2\u6237\u7aef\u53d1\u9001M\u4e2a SETs\/GETs \u67e5\u8be2 (\u7c7b\u4f3c\u4e8e Apache \u7684 ab \u5de5\u5177).<\/p>\n<div>\n<div id=\"cnblogs_code_open_226ef026-f5fe-4eee-ace7-08b81c8b4ee7\">\n<div>\n<blockquote>\n<p>.\/redis-benchmark&nbsp;-n&nbsp;100000&nbsp;\u2013c&nbsp;50<\/p>\n<p>======&nbsp;SET&nbsp;======<\/p>\n<p>100007&nbsp;requests&nbsp;completed&nbsp;in&nbsp;0.88&nbsp;seconds&nbsp;\uff08\u8bd1\u8005\u6ce8\uff1a100004&nbsp;\u67e5\u8be2\u5b8c\u6210\u4e8e&nbsp;1.14&nbsp;\u79d2&nbsp;\uff09<\/p>\n<p>50&nbsp;parallel&nbsp;clients&nbsp;\uff08\u8bd1\u8005\u6ce8\uff1a50\u4e2a\u5e76\u53d1\u5ba2\u6237\u7aef\uff09<\/p>\n<p>3&nbsp;bytes&nbsp;payload&nbsp;\uff08\u8bd1\u8005\u6ce8\uff1a3\u5b57\u8282\u6709\u6548\u8f7d\u8377)<\/p>\n<p>keep&nbsp;alive:&nbsp;1&nbsp;\uff08\u8bd1\u8005\u6ce8\uff1a\u4fdd\u63011\u4e2a\u8fde\u63a5)<\/p>\n<p>58.50%&nbsp;&lt;=&nbsp;0&nbsp;milliseconds\uff08\u8bd1\u8005\u6ce8\uff1a\u6beb\u79d2\uff09<\/p>\n<p>99.17%&nbsp;&lt;=&nbsp;1&nbsp;milliseconds<\/p>\n<p>99.58%&nbsp;&lt;=&nbsp;2&nbsp;milliseconds<\/p>\n<p>99.85%&nbsp;&lt;=&nbsp;3&nbsp;milliseconds<\/p>\n<p>99.90%&nbsp;&lt;=&nbsp;6&nbsp;milliseconds<\/p>\n<p>100.00%&nbsp;&lt;=&nbsp;9&nbsp;milliseconds<\/p>\n<p>114293.71&nbsp;requests&nbsp;per&nbsp;second\uff08\u8bd1\u8005\u6ce8\uff1a\u6bcf\u79d2&nbsp;114293.71&nbsp;\u6b21\u67e5\u8be2\uff09<\/p>\n<p>......<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p>Windows\u4e0b\u6d4b\u8bd5\u5e76\u53d1\u5ba2\u6237\u7aef\u6781\u9650\u4e3a60<\/p>\n<p>&nbsp;<\/p>\n<p><strong>linux\u5e73\u53f0Redis\u5b89\u88c5\uff1a <\/strong><\/p>\n<div>\n<div id=\"cnblogs_code_open_1a476a88-3c46-45c3-a161-719b47a14987\">\n<blockquote>\n<div>wget&nbsp;<a href=\"http:\/\/code.google.com\/p\/redis\/downloads\/detail?name=redis-2.0.4.tar.gz\" target=\"_blank\">http:\/\/code.google.com\/p\/redis\/downloads\/detail?name=redis-2.0.4.tar.gz<\/a><br \/>\ntar&nbsp;xvzf&nbsp;redis-2.0.4.tar.gz<br \/>\ncd&nbsp;&nbsp;redis-2.0.4<br \/>\nmake<br \/>\nmkdir&nbsp;\/home\/redis<br \/>\ncp&nbsp;redis-server&nbsp;&nbsp;\/home\/redis<br \/>\ncp&nbsp;redis-benchmark&nbsp;&nbsp;\/home\/redis<br \/>\ncp&nbsp;redis-cli&nbsp;&nbsp;\/home\/redis<br \/>\ncp&nbsp;redis.conf&nbsp;&nbsp;\/home\/redis<br \/>\ncd&nbsp;&nbsp;\/home\/redis<\/div>\n<\/blockquote>\n<\/div>\n<\/div>\n<div>\n<p>\u542f\u52a8<\/p>\n<blockquote>\n<p>.\/redis-server redis.conf<\/p>\n<\/blockquote>\n<p>\u8fdb\u5165\u547d\u4ee4\u4ea4\u4e92\u6a21\u5f0f\uff0c\u4e24\u79cd\uff1a<\/p>\n<p>1: &nbsp; .\/redis-cli<\/p>\n<p>2: &nbsp; telnet 127.0.0.1 6379 &nbsp; &nbsp; &nbsp; (ip\u63a5\u7aef\u53e3)<\/p>\n<p>\u5728\u5b89\u88c5\u7684\u65f6\u5019\u8981\u6ce8\u610f\u7cfb\u7edf\u65f6\u95f4\u8981\u6b63\u786e,\u4e0d\u7136\u53ef\u80fd\u4f1a\u63d0\u793a\"make[1]: warning: Clock skew detected. Your build may be incomplete\"\u9519\u8bef!<\/p>\n<\/div>\n<p>=============================================================<\/p>\n<p><strong>\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e<\/strong>:<\/p>\n<div>\n<p>&nbsp;<\/p>\n<p>1. Redis\u9ed8\u8ba4\u4e0d\u662f\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u7684\u65b9\u5f0f\u8fd0\u884c\uff0c\u53ef\u4ee5\u901a\u8fc7\u8be5\u914d\u7f6e\u9879\u4fee\u6539\uff0c\u4f7f\u7528yes\u542f\u7528\u5b88\u62a4\u8fdb\u7a0b<\/p>\n<p><strong>daemonize no<\/strong><\/p>\n<p>2. \u5f53Redis\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u65b9\u5f0f\u8fd0\u884c\u65f6\uff0cRedis\u9ed8\u8ba4\u4f1a\u628apid\u5199\u5165\/var\/run\/redis.pid\u6587\u4ef6\uff0c\u53ef\u4ee5\u901a\u8fc7pidfile\u6307\u5b9a<\/p>\n<p><strong>pidfile \/var\/run\/redis.pid<\/strong><\/p>\n<p>3. \u6307\u5b9aRedis\u76d1\u542c\u7aef\u53e3\uff0c\u9ed8\u8ba4\u7aef\u53e3\u4e3a6379\uff0c\u4f5c\u8005\u5728\u81ea\u5df1\u7684\u4e00\u7bc7\u535a\u6587\u4e2d\u89e3\u91ca\u4e86\u4e3a\u4ec0\u4e48\u9009\u75286379\u4f5c\u4e3a\u9ed8\u8ba4\u7aef\u53e3\uff0c\u56e0\u4e3a6379\u5728\u624b\u673a\u6309\u952e\u4e0aMERZ\u5bf9\u5e94\u7684\u53f7\u7801\uff0c\u800cMERZ\u53d6\u81ea\u610f\u5927\u5229\u6b4c\u5973Alessia Merz\u7684\u540d\u5b57<\/p>\n<p><strong>port 6379<\/strong><\/p>\n<p>4. \u7ed1\u5b9a\u7684\u4e3b\u673a\u5730\u5740<\/p>\n<p><strong>bind 127.0.0.1<\/strong><\/p>\n<p>5.\u5f53 \u5ba2\u6237\u7aef\u95f2\u7f6e\u591a\u957f\u65f6\u95f4\u540e\u5173\u95ed\u8fde\u63a5\uff0c\u5982\u679c\u6307\u5b9a\u4e3a0\uff0c\u8868\u793a\u5173\u95ed\u8be5\u529f\u80fd<\/p>\n<p><strong>timeout 300<\/strong><\/p>\n<p>6. \u6307\u5b9a\u65e5\u5fd7\u8bb0\u5f55\u7ea7\u522b\uff0cRedis\u603b\u5171\u652f\u6301\u56db\u4e2a\u7ea7\u522b\uff1adebug\u3001verbose\u3001notice\u3001warning\uff0c\u9ed8\u8ba4\u4e3averbose<\/p>\n<p><strong>loglevel verbose<\/strong><\/p>\n<p>7. \u65e5\u5fd7\u8bb0\u5f55\u65b9\u5f0f\uff0c\u9ed8\u8ba4\u4e3a\u6807\u51c6\u8f93\u51fa\uff0c\u5982\u679c\u914d\u7f6eRedis\u4e3a\u5b88\u62a4\u8fdb\u7a0b\u65b9\u5f0f\u8fd0\u884c\uff0c\u800c\u8fd9\u91cc\u53c8\u914d\u7f6e\u4e3a\u65e5\u5fd7\u8bb0\u5f55\u65b9\u5f0f\u4e3a\u6807\u51c6\u8f93\u51fa\uff0c\u5219\u65e5\u5fd7\u5c06\u4f1a\u53d1\u9001\u7ed9\/dev\/null<\/p>\n<p><strong>logfile stdout<\/strong><\/p>\n<p>8. \u8bbe\u7f6e\u6570\u636e\u5e93\u7684\u6570\u91cf\uff0c\u9ed8\u8ba4\u6570\u636e\u5e93\u4e3a0\uff0c\u53ef\u4ee5\u4f7f\u7528SELECT &lt;dbid&gt;\u547d\u4ee4\u5728\u8fde\u63a5\u4e0a\u6307\u5b9a\u6570\u636e\u5e93id<\/p>\n<p><strong>databases 16<\/strong><\/p>\n<p>9. \u6307\u5b9a\u5728\u591a\u957f\u65f6\u95f4\u5185\uff0c\u6709\u591a\u5c11\u6b21\u66f4\u65b0\u64cd\u4f5c\uff0c\u5c31\u5c06\u6570\u636e\u540c\u6b65\u5230\u6570\u636e\u6587\u4ef6\uff0c\u53ef\u4ee5\u591a\u4e2a\u6761\u4ef6\u914d\u5408<\/p>\n<p><strong>save &lt;seconds&gt; &lt;changes&gt;<\/strong><\/p>\n<p>Redis\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u4e2d\u63d0\u4f9b\u4e86\u4e09\u4e2a\u6761\u4ef6\uff1a<\/p>\n<p><strong>save 900 1<\/strong><\/p>\n<p><strong>save 300 10<\/strong><\/p>\n<p><strong>save 60 10000<\/strong><\/p>\n<p>\u5206\u522b\u8868\u793a900\u79d2\uff0815\u5206\u949f\uff09\u5185\u67091\u4e2a\u66f4\u6539\uff0c300\u79d2\uff085\u5206\u949f\uff09\u5185\u670910\u4e2a\u66f4\u6539\u4ee5\u53ca60\u79d2\u5185\u670910000\u4e2a\u66f4\u6539\u3002<\/p>\n<p>10. \u6307\u5b9a\u5b58\u50a8\u81f3\u672c\u5730\u6570\u636e\u5e93\u65f6\u662f\u5426\u538b\u7f29\u6570\u636e\uff0c\u9ed8\u8ba4\u4e3ayes\uff0cRedis\u91c7\u7528LZF\u538b\u7f29\uff0c\u5982\u679c\u4e3a\u4e86\u8282\u7701CPU\u65f6\u95f4\uff0c\u53ef\u4ee5\u5173\u95ed\u8be5\u9009\u9879\uff0c\u4f46\u4f1a\u5bfc\u81f4\u6570\u636e\u5e93\u6587\u4ef6\u53d8\u7684\u5de8\u5927<\/p>\n<p><strong>rdbcompression yes<\/strong><\/p>\n<p>11. \u6307\u5b9a\u672c\u5730\u6570\u636e\u5e93\u6587\u4ef6\u540d\uff0c\u9ed8\u8ba4\u503c\u4e3adump.rdb<\/p>\n<p><strong>dbfilename dump.rdb<\/strong><\/p>\n<p>12. \u6307\u5b9a\u672c\u5730\u6570\u636e\u5e93\u5b58\u653e\u76ee\u5f55<\/p>\n<p><strong>dir .\/<\/strong><\/p>\n<p>13. \u8bbe\u7f6e\u5f53\u672c\u673a\u4e3aslav\u670d\u52a1\u65f6\uff0c\u8bbe\u7f6emaster\u670d\u52a1\u7684IP\u5730\u5740\u53ca\u7aef\u53e3\uff0c\u5728Redis\u542f\u52a8\u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u4ecemaster\u8fdb\u884c\u6570\u636e\u540c\u6b65<\/p>\n<p><strong>slaveof &lt;masterip&gt; &lt;masterport&gt;<\/strong><\/p>\n<p>14. \u5f53master\u670d\u52a1\u8bbe\u7f6e\u4e86\u5bc6\u7801\u4fdd\u62a4\u65f6\uff0cslav\u670d\u52a1\u8fde\u63a5master\u7684\u5bc6\u7801<\/p>\n<p><strong>masterauth &lt;master-password&gt;<\/strong><\/p>\n<p>15. \u8bbe\u7f6eRedis\u8fde\u63a5\u5bc6\u7801\uff0c\u5982\u679c\u914d\u7f6e\u4e86\u8fde\u63a5\u5bc6\u7801\uff0c\u5ba2\u6237\u7aef\u5728\u8fde\u63a5Redis\u65f6\u9700\u8981\u901a\u8fc7AUTH &lt;password&gt;\u547d\u4ee4\u63d0\u4f9b\u5bc6\u7801\uff0c\u9ed8\u8ba4\u5173\u95ed<\/p>\n<p><strong>requirepass foobared<\/strong><\/p>\n<p>16. \u8bbe\u7f6e\u540c\u4e00\u65f6\u95f4\u6700\u5927\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\uff0c\u9ed8\u8ba4\u65e0\u9650\u5236\uff0cRedis\u53ef\u4ee5\u540c\u65f6\u6253\u5f00\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\u4e3aRedis\u8fdb\u7a0b\u53ef\u4ee5\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\uff0c\u5982\u679c\u8bbe\u7f6e maxclients 0\uff0c\u8868\u793a\u4e0d\u4f5c\u9650\u5236\u3002\u5f53\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\u5230\u8fbe\u9650\u5236\u65f6\uff0cRedis\u4f1a\u5173\u95ed\u65b0\u7684\u8fde\u63a5\u5e76\u5411\u5ba2\u6237\u7aef\u8fd4\u56demax number of clients reached\u9519\u8bef\u4fe1\u606f<\/p>\n<p><strong>maxclients 128<\/strong><\/p>\n<p>17. \u6307\u5b9aRedis\u6700\u5927\u5185\u5b58\u9650\u5236\uff0cRedis\u5728\u542f\u52a8\u65f6\u4f1a\u628a\u6570\u636e\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff0c\u8fbe\u5230\u6700\u5927\u5185\u5b58\u540e\uff0cRedis\u4f1a\u5148\u5c1d\u8bd5\u6e05\u9664\u5df2\u5230\u671f\u6216\u5373\u5c06\u5230\u671f\u7684Key\uff0c\u5f53\u6b64\u65b9\u6cd5\u5904\u7406 \u540e\uff0c\u4ecd\u7136\u5230\u8fbe\u6700\u5927\u5185\u5b58\u8bbe\u7f6e\uff0c\u5c06\u65e0\u6cd5\u518d\u8fdb\u884c\u5199\u5165\u64cd\u4f5c\uff0c\u4f46\u4ecd\u7136\u53ef\u4ee5\u8fdb\u884c\u8bfb\u53d6\u64cd\u4f5c\u3002Redis\u65b0\u7684vm\u673a\u5236\uff0c\u4f1a\u628aKey\u5b58\u653e\u5185\u5b58\uff0cValue\u4f1a\u5b58\u653e\u5728swap\u533a<\/p>\n<p><strong>maxmemory &lt;bytes&gt;<\/strong><\/p>\n<p>18. \u6307\u5b9a\u662f\u5426\u5728\u6bcf\u6b21\u66f4\u65b0\u64cd\u4f5c\u540e\u8fdb\u884c\u65e5\u5fd7\u8bb0\u5f55\uff0cRedis\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u662f\u5f02\u6b65\u7684\u628a\u6570\u636e\u5199\u5165\u78c1\u76d8\uff0c\u5982\u679c\u4e0d\u5f00\u542f\uff0c\u53ef\u80fd\u4f1a\u5728\u65ad\u7535\u65f6\u5bfc\u81f4\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u6570\u636e\u4e22\u5931\u3002\u56e0\u4e3a redis\u672c\u8eab\u540c\u6b65\u6570\u636e\u6587\u4ef6\u662f\u6309\u4e0a\u9762save\u6761\u4ef6\u6765\u540c\u6b65\u7684\uff0c\u6240\u4ee5\u6709\u7684\u6570\u636e\u4f1a\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u53ea\u5b58\u5728\u4e8e\u5185\u5b58\u4e2d\u3002\u9ed8\u8ba4\u4e3ano<\/p>\n<p><strong>appendonly no<\/strong><\/p>\n<p>19. \u6307\u5b9a\u66f4\u65b0\u65e5\u5fd7\u6587\u4ef6\u540d\uff0c\u9ed8\u8ba4\u4e3aappendonly.aof<\/p>\n<p><strong>appendfilename appendonly.aof<\/strong><\/p>\n<p>20. \u6307\u5b9a\u66f4\u65b0\u65e5\u5fd7\u6761\u4ef6\uff0c\u5171\u67093\u4e2a\u53ef\u9009\u503c\uff1a<\/p>\n<p><strong>no<\/strong>\uff1a\u8868\u793a\u7b49\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u6570\u636e\u7f13\u5b58\u540c\u6b65\u5230\u78c1\u76d8\uff08\u5feb\uff09<\/p>\n<p><strong>always<\/strong>\uff1a\u8868\u793a\u6bcf\u6b21\u66f4\u65b0\u64cd\u4f5c\u540e\u624b\u52a8\u8c03\u7528fsync()\u5c06\u6570\u636e\u5199\u5230\u78c1\u76d8\uff08\u6162\uff0c\u5b89\u5168\uff09<\/p>\n<p><strong>everysec<\/strong>\uff1a\u8868\u793a\u6bcf\u79d2\u540c\u6b65\u4e00\u6b21\uff08\u6298\u8877\uff0c\u9ed8\u8ba4\u503c\uff09<\/p>\n<p><strong>appendfsync everysec<\/strong><\/p>\n<p>21. \u6307\u5b9a\u662f\u5426\u542f\u7528\u865a\u62df\u5185\u5b58\u673a\u5236\uff0c\u9ed8\u8ba4\u503c\u4e3ano\uff0c\u7b80\u5355\u7684\u4ecb\u7ecd\u4e00\u4e0b\uff0cVM\u673a\u5236\u5c06\u6570\u636e\u5206\u9875\u5b58\u653e\uff0c\u7531Redis\u5c06\u8bbf\u95ee\u91cf\u8f83\u5c11\u7684\u9875\u5373\u51b7\u6570\u636eswap\u5230\u78c1\u76d8\u4e0a\uff0c\u8bbf\u95ee\u591a\u7684\u9875\u9762\u7531\u78c1\u76d8\u81ea\u52a8\u6362\u51fa\u5230\u5185\u5b58\u4e2d\uff08\u5728\u540e\u9762\u7684\u6587\u7ae0\u6211\u4f1a\u4ed4\u7ec6\u5206\u6790Redis\u7684VM\u673a\u5236\uff09<\/p>\n<p><strong>vm-enabled no<\/strong><\/p>\n<p>22. \u865a\u62df\u5185\u5b58\u6587\u4ef6\u8def\u5f84\uff0c\u9ed8\u8ba4\u503c\u4e3a\/tmp\/redis.swap\uff0c\u4e0d\u53ef\u591a\u4e2aRedis\u5b9e\u4f8b\u5171\u4eab<\/p>\n<p><strong>vm-swap-file \/tmp\/redis.swap<\/strong><\/p>\n<p>23. \u5c06\u6240\u6709\u5927\u4e8evm-max-memory\u7684\u6570\u636e\u5b58\u5165\u865a\u62df\u5185\u5b58,\u65e0\u8bbavm-max-memory\u8bbe\u7f6e\u591a\u5c0f,\u6240\u6709\u7d22\u5f15\u6570\u636e\u90fd\u662f\u5185\u5b58\u5b58\u50a8\u7684(Redis\u7684\u7d22\u5f15\u6570\u636e \u5c31\u662fkeys),\u4e5f\u5c31\u662f\u8bf4,\u5f53vm-max-memory\u8bbe\u7f6e\u4e3a0\u7684\u65f6\u5019,\u5176\u5b9e\u662f\u6240\u6709value\u90fd\u5b58\u5728\u4e8e\u78c1\u76d8\u3002\u9ed8\u8ba4\u503c\u4e3a0<\/p>\n<p><strong>vm-max-memory 0<\/strong><\/p>\n<p>24. Redis swap\u6587\u4ef6\u5206\u6210\u4e86\u5f88\u591a\u7684page\uff0c\u4e00\u4e2a\u5bf9\u8c61\u53ef\u4ee5\u4fdd\u5b58\u5728\u591a\u4e2apage\u4e0a\u9762\uff0c\u4f46\u4e00\u4e2apage\u4e0a\u4e0d\u80fd\u88ab\u591a\u4e2a\u5bf9\u8c61\u5171\u4eab\uff0cvm-page-size\u662f\u8981\u6839\u636e\u5b58\u50a8\u7684 \u6570\u636e\u5927\u5c0f\u6765\u8bbe\u5b9a\u7684\uff0c\u4f5c\u8005\u5efa\u8bae\u5982\u679c\u5b58\u50a8\u5f88\u591a\u5c0f\u5bf9\u8c61\uff0cpage\u5927\u5c0f\u6700\u597d\u8bbe\u7f6e\u4e3a32\u6216\u800564bytes\uff1b\u5982\u679c\u5b58\u50a8\u5f88\u5927\u5927\u5bf9\u8c61\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u66f4\u5927\u7684page\uff0c\u5982\u679c\u4e0d \u786e\u5b9a\uff0c\u5c31\u4f7f\u7528\u9ed8\u8ba4\u503c<\/p>\n<p><strong>vm-page-size 32<\/strong><\/p>\n<p>25. \u8bbe\u7f6eswap\u6587\u4ef6\u4e2d\u7684page\u6570\u91cf\uff0c\u7531\u4e8e\u9875\u8868\uff08\u4e00\u79cd\u8868\u793a\u9875\u9762\u7a7a\u95f2\u6216\u4f7f\u7528\u7684bitmap\uff09\u662f\u5728\u653e\u5728\u5185\u5b58\u4e2d\u7684\uff0c\uff0c\u5728\u78c1\u76d8\u4e0a\u6bcf8\u4e2apages\u5c06\u6d88\u80171byte\u7684\u5185\u5b58\u3002<\/p>\n<p><strong>vm-pages 134217728<\/strong><\/p>\n<p>26. \u8bbe\u7f6e\u8bbf\u95eeswap\u6587\u4ef6\u7684\u7ebf\u7a0b\u6570,\u6700\u597d\u4e0d\u8981\u8d85\u8fc7\u673a\u5668\u7684\u6838\u6570,\u5982\u679c\u8bbe\u7f6e\u4e3a0,\u90a3\u4e48\u6240\u6709\u5bf9swap\u6587\u4ef6\u7684\u64cd\u4f5c\u90fd\u662f\u4e32\u884c\u7684\uff0c\u53ef\u80fd\u4f1a\u9020\u6210\u6bd4\u8f83\u957f\u65f6\u95f4\u7684\u5ef6\u8fdf\u3002\u9ed8\u8ba4\u503c\u4e3a4<\/p>\n<p><strong>vm-max-threads 4<\/strong><\/p>\n<p>27. \u8bbe\u7f6e\u5728\u5411\u5ba2\u6237\u7aef\u5e94\u7b54\u65f6\uff0c\u662f\u5426\u628a\u8f83\u5c0f\u7684\u5305\u5408\u5e76\u4e3a\u4e00\u4e2a\u5305\u53d1\u9001\uff0c\u9ed8\u8ba4\u4e3a\u5f00\u542f<\/p>\n<p><strong>glueoutputbuf yes<\/strong><\/p>\n<p>28. \u6307\u5b9a\u5728\u8d85\u8fc7\u4e00\u5b9a\u7684\u6570\u91cf\u6216\u8005\u6700\u5927\u7684\u5143\u7d20\u8d85\u8fc7\u67d0\u4e00\u4e34\u754c\u503c\u65f6\uff0c\u91c7\u7528\u4e00\u79cd\u7279\u6b8a\u7684\u54c8\u5e0c\u7b97\u6cd5<\/p>\n<p><strong>hash-max-zipmap-entries 64<\/strong><\/p>\n<p><strong>hash-max-zipmap-value 512<\/strong><\/p>\n<p>29. \u6307\u5b9a\u662f\u5426\u6fc0\u6d3b\u91cd\u7f6e\u54c8\u5e0c\uff0c\u9ed8\u8ba4\u4e3a\u5f00\u542f\uff08\u540e\u9762\u5728\u4ecb\u7ecdRedis\u7684\u54c8\u5e0c\u7b97\u6cd5\u65f6\u5177\u4f53\u4ecb\u7ecd\uff09<\/p>\n<p><strong>activerehashing yes<\/strong><\/p>\n<p>30. \u6307\u5b9a\u5305\u542b\u5176\u5b83\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u5728\u540c\u4e00\u4e3b\u673a\u4e0a\u591a\u4e2aRedis\u5b9e\u4f8b\u4e4b\u95f4\u4f7f\u7528\u540c\u4e00\u4efd\u914d\u7f6e\u6587\u4ef6\uff0c\u800c\u540c\u65f6\u5404\u4e2a\u5b9e\u4f8b\u53c8\u62e5\u6709\u81ea\u5df1\u7684\u7279\u5b9a\u914d\u7f6e\u6587\u4ef6<\/p>\n<p><strong>include \/path\/to\/local.conf<\/strong><\/p>\n<div>=============================================================<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>\u95ee\u9898\u8ba8\u8bba: <\/strong><br \/>\n1. Redis\u5b98\u65b9\u6587\u6863\u5bf9VM\u7684\u4f7f\u7528\u63d0\u51fa\u4e86\u4e00\u4e9b\u5efa\u8bae:<br \/>\n\u5f53\u4f60\u7684key\u5f88\u5c0f\u800cvalue\u5f88\u5927\u65f6,\u4f7f\u7528VM\u7684\u6548\u679c\u4f1a\u6bd4\u8f83\u597d.\u56e0\u4e3a\u8fd9\u6837\u8282\u7ea6\u7684\u5185\u5b58\u6bd4\u8f83\u5927.<br \/>\n\u5f53\u4f60\u7684key\u4e0d\u5c0f\u65f6,\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4e00\u4e9b\u975e\u5e38\u65b9\u6cd5\u5c06\u5f88\u5927\u7684key\u53d8\u6210\u5f88\u5927\u7684value,\u6bd4\u5982\u4f60\u53ef\u4ee5\u8003\u8651\u5c06key,value\u7ec4\u5408\u6210\u4e00\u4e2a\u65b0\u7684value.<br \/>\n\u6700\u597d\u4f7f\u7528linux ext3 \u7b49\u5bf9\u7a00\u758f\u6587\u4ef6\u652f\u6301\u6bd4\u8f83\u597d\u7684\u6587\u4ef6\u7cfb\u7edf\u4fdd\u5b58\u4f60\u7684swap\u6587\u4ef6.<br \/>\nvm-max-threads\u8fd9\u4e2a\u53c2\u6570,\u53ef\u4ee5\u8bbe\u7f6e\u8bbf\u95eeswap\u6587\u4ef6\u7684\u7ebf\u7a0b\u6570,\u8bbe\u7f6e\u6700\u597d\u4e0d\u8981\u8d85\u8fc7\u673a\u5668\u7684\u6838\u6570.\u5982\u679c\u8bbe\u7f6e\u4e3a0,\u90a3\u4e48\u6240\u6709\u5bf9swap\u6587\u4ef6\u7684\u64cd\u4f5c\u90fd\u662f\u4e32\u884c\u7684.\u53ef\u80fd\u4f1a\u9020\u6210\u6bd4\u8f83\u957f\u65f6\u95f4\u7684\u5ef6\u8fdf,\u4f46\u662f\u5bf9\u6570\u636e\u5b8c\u6574\u6027\u6709\u5f88\u597d\u7684\u4fdd\u8bc1.<br \/>\n2. \u5173\u4e8eRedis\u65b0\u7684\u5b58\u50a8\u6a21\u5f0fdiskstore\uff08http:\/\/timyang.net\/data\/redis-diskstore\uff09\uff0c<br \/>\n\u8282\u9009\uff1a<br \/>\n\u9002\u5408Web 2.0\u6570\u636e\u8bbf\u95ee\u6700\u4f73\u7684\u65b9\u5f0f\u5c31\u662f\u5b8c\u5168\u57fa\u4e8e\u5185\u5b58\uff0c\u6bd4\u5982\u7528Memcached\u6216\u8005Redis snapshot\u65b9\u5f0f\u3002\u4f46\u662f\u66f4\u591a\u7684\u4e1a\u52a1\u573a\u666f\u662f\u6570\u636e\u89c4\u6a21\u4f1a\u8d85\u8fc7RAM\u5bb9\u91cf\uff0c\u56e0\u6b64\u6709\u51e0\u79cd\u4e0d\u540c\u7684\u8bbe\u8ba1\u6a21\u5f0f\u3002<\/p>\n<div><strong>VM\u65b9\u5f0f<\/strong>: \u5c06\u6570\u636e\u5206\u9875\u5b58\u653e\uff0c\u7531\u5e94\u7528(\u5982Redis)\u6216\u8005\u64cd\u4f5c\u7cfb\u7edf(\u5982Varnish)\u5c06\u8bbf\u95ee\u91cf\u8f83\u5c11\u7684\u9875\u5373\u51b7\u6570\u636eswap\u5230\u78c1\u76d8\u4e0a\uff0c\u8bbf\u95ee\u591a\u7684\u9875\u9762\u7531\u78c1\u76d8\u81ea\u52a8\u6362\u51fa\u5230\u5185\u5b58\u4e2d\u3002\u5e94\u7528\u5b9e\u73b0VM\u7f3a\u70b9\u662f\u4ee3\u7801\u903b\u8f91\u590d\u6742\uff0c\u5982\u679c\u4e1a\u52a1\u4e0a\u51b7\u70ed\u6570\u636e\u8fb9\u754c\u5e76\u4e0d\u5206\u660e\uff0c\u5219\u6362\u5165\u6362\u51fa\u4ee3\u4ef7\u592a\u9ad8\uff0c\u7cfb\u7edf\u6574\u4f53\u6027\u80fd\u4f4e\u3002\u4e0d\u5c11\u62a2\u9c9c\u7684\u7f51\u53cb\u5728\u5fae\u535a\u4e0a\u4e5f\u53cd\u9988\u8fc7\u4f7f\u7528VM\u79cd\u79cd\u4e0d\u7a33\u5b9a\u60c5\u51b5\u3002<a href=\"http:\/\/timyang.net\/data\/redis-misunderstanding\/\">\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u73b0\u7f3a\u70b9\u5728\u4e8e<\/a>\u4e3b\u8981OS\u7684VM\u6362\u5165\u6362\u51fa\u662f\u57fa\u4e8ePage\u6982\u5ff5\uff0c\u6bd4\u5982OS VM1\u4e2aPage\u662f4K, 4K\u4e2d\u53ea\u8981\u8fd8\u6709\u4e00\u4e2a\u5143\u7d20\u5373\u4f7f\u53ea\u67091\u4e2a\u5b57\u8282\u88ab\u8bbf\u95ee\uff0c\u8fd9\u4e2a\u9875\u4e5f\u4e0d\u4f1a\u88abSWAP,\u6362\u5165\u4e5f\u540c\u6837\u9053\u7406\uff0c\u8bfb\u5230\u4e00\u4e2a\u5b57\u8282\u53ef\u80fd\u4f1a\u6362\u51654K\u65e0\u7528\u7684\u5185\u5b58\u3002\u800cRedis\u81ea\u5df1\u5b9e\u73b0\u5219\u53ef\u4ee5\u8fbe\u5230\u63a7\u5236\u6362\u5165\u7684\u7c92\u5ea6\u3002\u53e6\u5916\u8bbf\u95ee\u64cd\u4f5c\u7cfb\u7edfSWAP\u5185\u5b58\u533a\u57df\u65f6block\u8fdb\u7a0b\uff0c\u4e5f\u662f\u5bfc\u81f4Redis\u8981\u81ea\u5df1\u5b9e\u73b0VM\u539f\u56e0\u4e4b\u4e00\u3002 &nbsp; <strong>\u78c1\u76d8\u65b9\u5f0f: <\/strong>\u6240\u6709\u7684\u6570\u636e\u8bfb\u5199\u8bbf\u95ee\u90fd\u662f\u57fa\u4e8e\u78c1\u76d8\uff0c\u7531\u64cd\u4f5c\u7cfb\u7edf\u6765\u53ea\u80fd\u7684\u7f13\u5b58\u8bbf\u95ee\u7684\u6570\u636e\u3002\u7531\u4e8e\u73b0\u4ee3\u64cd\u4f5c\u7cfb\u7edf\u90fd\u975e\u5e38\u806a\u660e\uff0c\u4f1a\u5c06\u9891\u7e41\u8bbf\u95ee\u7684\u6570\u636e\u52a0\u5165\u5230\u5185\u5b58\u4e2d\uff0c\u56e0\u6b64\u5e94\u7528\u5e76\u4e0d\u9700\u8981\u8fc7\u591a\u7279\u6b8a\u903b\u8f91\u3002MongoDB\u5c31\u662f\u8fd9\u79cd\u8bbe\u8ba1\u65b9\u5f0f\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u6709\u4e00\u4e9b\u5df2\u77e5\u7684\u7f3a\u70b9\uff0c\u6bd4\u5982\u64cd\u4f5cMMap\u5199\u5165\u78c1\u76d8\u7531\u64cd\u4f5c\u7cfb\u7edf\u63a7\u5236\uff0c\u64cd\u4f5c\u7cfb\u7edf\u5148\u5199\u54ea\u91cc\u540e\u5199\u54ea\u91cc\u5e94\u7528\u5e76\u4e0d\u77e5\u60c5\uff0c\u5982\u679c\u5199\u5165\u8fc7\u7a0b\u4e2d\u53d1\u751f\u4e86crash\u5219\u6570\u636e\u4e00\u81f4\u6027\u4f1a\u5b58\u5728\u95ee\u9898\u3002\u8fd9\u4e2a\u4e5f\u662fMongoDB\u9971\u53d7\u4e89\u8bae\u7684\u5355\u673a<a href=\"http:\/\/blog.mongodb.org\/post\/381927266\/what-about-durability\">Durability<\/a>\u95ee\u9898&nbsp; <\/p>\n<p><strong>\u786c\u76d8\u5b58\u50a8+cache\u65b9\u5f0f: <\/strong>\u5b9e\u9645\u539f\u7406\u548cmysql+memcache\u65b9\u5f0f\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u5c06\u4e24\u8005\u529f\u80fd\u5408\u4e8c\u4e3a\u4e00\u5230\u4e00\u4e2a\u5e95\u5c42\u670d\u52a1\u4e2d\uff0c\u7b80\u5316\u4e86\u8c03\u7528\u3002<\/p>\n<div>\u5728\u4e0a\u9762\u51e0\u79cd\u65b9\u5f0f\u4e2d\uff0c\u9664\u53bbVM\uff0cantirez\u89c9\u5f97MongoDB\u65b9\u5f0f\u4e5f\u4e0d\u592a\u9002\u5408\uff0c\u56e0\u6b64\u9009\u62e9\u4e86disktore\u65b9\u5f0f\u6765\u5b9e\u73b0\u65b0\u7684\u78c1\u76d8\u5b58\u50a8\uff0c\u5177\u4f53\u7ec6\u8282\u662f<\/div>\n<div>1) \u8bfb\u64cd\u4f5c\uff0c\u4f7f\u7528read through\u4ee5\u53caLRU\u65b9\u5f0f\u3002\u5185\u5b58\u4e2d\u4e0d\u5b58\u5728\u7684\u6570\u636e\u4ece\u78c1\u76d8\u62c9\u53d6\u5e76\u653e\u5165\u5185\u5b58\uff0c\u5185\u5b58\u4e2d\u653e\u4e0d\u4e0b\u7684\u6570\u636e\u91c7\u7528LRU\u6dd8\u6c70\u3002<\/div>\n<div>\n<p>&nbsp;<\/p>\n<div>2) \u5199\u64cd\u4f5c\uff0c\u91c7\u7528\u53e6\u5916spawn\u4e00\u4e2a\u7ebf\u7a0b\u5355\u72ec\u5904\u7406\uff0c\u5199\u7ebf\u7a0b\u901a\u5e38\u662f\u5f02\u6b65\u7684\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u628acache-flush-delay\u914d\u7f6e\u8bbe\u62100\uff0cRedis\u5c3d\u91cf\u4fdd\u8bc1\u5373\u65f6\u5199\u5165\u3002\u4f46\u662f\u5728\u5f88\u591a\u573a\u5408\u5ef6\u8fdf\u5199\u4f1a\u6709\u66f4\u597d\u7684\u6027\u80fd\uff0c\u6bd4\u5982\u4e00\u4e9b\u8ba1\u6570\u5668\u7528Redis\u5b58\u50a8\uff0c\u5728\u77ed\u65f6\u95f4\u5982\u679c\u67d0\u4e2a\u8ba1\u6570\u53cd\u590d\u88ab\u4fee\u6539\uff0cRedis\u53ea\u9700\u8981\u5c06\u6700\u7ec8\u7684\u7ed3\u679c\u5199\u5165\u78c1\u76d8\u3002\u8fd9\u79cd\u505a\u6cd5\u4f5c\u8005\u53ebper key persistence\u3002\u7531\u4e8e\u5199\u5165\u4f1a\u6309key\u5408\u5e76\uff0c\u56e0\u6b64\u548csnapshot\u8fd8\u662f\u6709\u5dee\u5f02\uff0cdisk store\u5e76\u4e0d\u80fd\u4fdd\u8bc1\u65f6\u95f4\u4e00\u81f4\u6027\u3002\u7531\u4e8e\u5199\u64cd\u4f5c\u662f\u5355\u7ebf\u7a0b\uff0c\u5373\u4f7fcache-flush-delay\u8bbe\u62100\uff0c\u591a\u4e2aclient\u540c\u65f6\u5199\u5219\u9700\u8981\u6392\u961f\u7b49\u5f85\uff0c\u5982\u679c\u961f\u5217\u5bb9\u91cf\u8d85\u8fc7cache-max-memory,Redis\u8bbe\u8ba1\u4f1a\u8fdb\u5165\u7b49\u5f85\u72b6\u6001\uff0c\u9020\u6210\u8c03\u7528\u65b9\u5361\u4f4f\u3002Google Group\u4e0a\u6709\u70ed\u5fc3\u7f51\u53cb\u8fc5\u901f\u5b8c\u6210\u4e86\u538b\u529b\u6d4b\u8bd5\uff0c\u5f53\u5185\u5b58\u7528\u5b8c\u4e4b\u540e\uff0cset\u6bcf\u79d2\u5904\u7406\u901f\u5ea6\u4ece25k\u4e0b\u964d\u523010k\u518d\u5230\u540e\u6765\u51e0\u4e4e\u5361\u4f4f\u3002\u867d\u7136\u901a\u8fc7\u589e\u52a0cache-flush-delay\u53ef\u4ee5\u63d0\u9ad8\u76f8\u540ckey\u91cd\u590d\u5199\u5165\u6027\u80fd\uff1b\u901a\u8fc7\u589e\u52a0cache-max-memory\u53ef\u4ee5\u5e94\u5bf9\u4e34\u65f6\u5cf0\u503c\u5199\u5165\u3002\u4f46\u662fdiskstore\u5199\u5165\u74f6\u9888\u6700\u7ec8\u8fd8\u662f\u5728IO\u3002<br \/>\n3) rdb \u548c\u65b0 diskstore \u683c\u5f0f\u5173\u7cfb<br \/>\nrdb\u662f\u4f20\u7edfRedis\u5185\u5b58\u65b9\u5f0f\u7684\u5b58\u50a8\u683c\u5f0f\uff0cdiskstore\u662f\u53e6\u5916\u4e00\u79cd\u683c\u5f0f\uff0c\u90a3\u4e24\u8005\u5173\u7cfb\u5982\u4f55\uff1f1.\u901a\u8fc7BGSAVE\u53ef\u4ee5\u968f\u65f6\u5c06diskstore\u683c\u5f0f\u53e6\u5b58\u4e3ardb\u683c\u5f0f\uff0c\u800c\u4e14rdb\u683c\u5f0f\u8fd8\u7528\u4e8eRedis\u590d\u5236\u4ee5\u53ca\u4e0d\u540c\u5b58\u50a8\u65b9\u5f0f\u4e4b\u95f4\u7684\u4e2d\u95f4\u683c\u5f0f\u3002&nbsp; <\/p>\n<p>2.\u901a\u8fc7\u5de5\u5177\u53ef\u4ee5\u5c06rdb\u683c\u5f0f\u8f6c\u6362\u6210diskstore\u683c\u5f0f\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Windows\u7248\u7684Redis\u53ef\u5230\u6b64\u5904\u4e0b\u8f7d\uff0c\u975e\u5b98\u65b9\u7248<br \/>\n<a href=\"http:\/\/code.google.com\/p\/servicestack\/wiki\/RedisWindowsDownload\"><span style=\"color:#1463c4;\">http:\/\/code.google.com\/p\/servicestack\/wiki\/RedisWindowsDownload<\/span><\/a><\/p>\n<p>redis.conf<br \/>\n\u590d\u5236\u4ee5\u4e0b===\u4e0e====\u4e4b\u5185\u7684\u5185\u5bb9<br \/>\n=================================<br \/>\n# Redis configuration file example<\/p>\n<p># By default Redis does not run as a daemon. Use 'yes' if you need it.<br \/>\n# Note that Redis will write a pid... <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/187\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[282],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry","category-cache"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}