Redis windows 测试redis持久化功能.docx
- 文档编号:7471265
- 上传时间:2023-01-24
- 格式:DOCX
- 页数:12
- 大小:21.21KB
Redis windows 测试redis持久化功能.docx
《Redis windows 测试redis持久化功能.docx》由会员分享,可在线阅读,更多相关《Redis windows 测试redis持久化功能.docx(12页珍藏版)》请在冰豆网上搜索。
Rediswindows测试redis持久化功能
Rediswindows测试redis持久化功能
还需要在redis根目录增加一个redis的配置文件redis.conf,文件具体内容有:
1.#Redisconfigurationfileexample
2.
3.#BydefaultRedisdoesnotrunasadaemon.Use'yes'ifyouneedit.
4.#NotethatRediswillwriteapidfilein/var/run/redis.pidwhendaemonized.
5.daemonizeno
6.
7.#Whenrunasadaemon,Rediswriteapidfilein/var/run/redis.pidbydefault.
8.#Youcanspecifyacustompidfilelocationhere.
9.pidfile/var/run/redis.pid
10.
11.#Acceptconnectionsonthespecifiedport,defaultis6379
12.port6379
13.
14.#Ifyouwantyoucanbindasingleinterface,ifthebindoptionisnot
15.#specifiedalltheinterfaceswilllistenforconnections.
16.#
17.#bind127.0.0.1
18.
19.#ClosetheconnectionafteraclientisidleforNseconds(0todisable)
20.timeout300
21.
22.#Setserververbosityto'debug'
23.#itcanbeoneof:
24.#debug(alotofinformation,usefulfordevelopment/testing)
25.#notice(moderatelyverbose,whatyouwantinproductionprobably)
26.#warning(onlyveryimportant/criticalmessagesarelogged)
27.logleveldebug
28.
29.#Specifythelogfilename.Also'stdout'canbeusedtoforce
30.#thedemontologonthestandardoutput.Notethatifyouusestandard
31.#outputforloggingbutdaemonize,logswillbesentto/dev/null
32.logfilestdout
33.
34.#Setthenumberofdatabases.ThedefaultdatabaseisDB0,youcanselect
35.#adifferentoneonaper-connectionbasisusingSELECT
36.#dbidisanumberbetween0and'databases'-1
37.databases16
38.
39.################################SNAPSHOTTING#################################
40.#
41.#SavetheDBondisk:
42.#
43.#save
44.#
45.#WillsavetheDBifboththegivennumberofsecondsandthegiven
46.#numberofwriteoperationsagainsttheDBoccurred.
47.#
48.#Intheexamplebelowthebehaviourwillbetosave:
49.#after900sec(15min)ifatleast1keychanged
50.#after300sec(5min)ifatleast10keyschanged
51.#after60secifatleast10000keyschanged
52.save9001
53.save30010
54.save6010000
55.
56.#CompressstringobjectsusingLZFwhendump.rdbdatabases?
57.#Fordefaultthat'ssetto'yes'asit'salmostalwaysawin.
58.#IfyouwanttosavesomeCPUinthesavingchildsetitto'no'but
59.#thedatasetwilllikelybebiggerifyouhavecompressiblevaluesorkeys.
60.rdbcompressionyes
61.
62.#ThefilenamewheretodumptheDB
63.dbfilenamedump.rdb
64.
65.#Fordefaultsave/loadDBin/fromtheworkingdirectory
66.#Notethatyoumustspecifyadirectorynotafilename.
67.dir./
68.
69.#################################REPLICATION#################################
70.
71.#Master-Slavereplication.UseslaveoftomakeaRedisinstanceacopyof
72.#anotherRedisserver.Notethattheconfigurationislocaltotheslave
73.#soforexampleitispossibletoconfiguretheslavetosavetheDBwitha
74.#differentinterval,ortolistentoanotherport,andsoon.
75.#
76.#slaveof
77.
78.#Ifthemasterispasswordprotected(usingthe"requirepass"configuration
79.#directivebelow)itispossibletotelltheslavetoauthenticatebefore
80.#startingthereplicationsynchronizationprocess,otherwisethemasterwill
81.#refusetheslaverequest.
82.#
83.#masterauth
84.
85.##################################SECURITY###################################
86.
87.#RequireclientstoissueAUTH
88.#commands.Thismightbeusefulinenvironmentsinwhichyoudonottrust
89.#otherswithaccesstothehostrunningredis-server.
90.#
91.#Thisshouldstaycommentedoutforbackwardcompatibilityandbecausemost
92.#peopledonotneedauth(e.g.theyruntheirownservers).
93.#
94.#requirepassfoobared
95.
96.###################################LIMITS####################################
97.
98.#Setthemaxnumberofconnectedclientsatthesametime.Bydefaultthere
99.#isnolimit,andit'suptothenumberoffiledescriptorstheRedisprocess
100.#isabletoopen.Thespecialvalue'0'meansnolimts.
101.#OncethelimitisreachedRediswillcloseallthenewconnectionssending
102.#anerror'maxnumberofclientsreached'.
103.#
104.#maxclients128
105.
106.#Don'tusemorememorythanthespecifiedamountofbytes.
107.#WhenthememorylimitisreachedRediswilltrytoremovekeyswithan
108.#EXPIREset.Itwilltrytostartfreeingkeysthataregoingtoexpire
109.#inlittletimeandpreservekeyswithalongertimetolive.
110.#Rediswillalsotrytoremoveobjectsfromfreelistsifpossible.
111.#
112.#Ifallthisfails,Rediswillstarttoreplywitherrorstocommands
113.#thatwillusemorememory,likeSET,LPUSH,andsoon,andwillcontinue
114.#toreplytomostread-onlycommandslikeGET.
115.#
116.#WARNING:
maxmemorycanbeagoodideamainlyifyouwanttouseRedisasa
117.#'state'serverorcache,notasarealDB.WhenRedisisusedasareal
118.#databasethememoryusagewillgrowovertheweeks,itwillbeobviousif
119.#itisgoingtousetoomuchmemoryinthelongrun,andyou'llhavethetime
120.#toupgrade.Withmaxmemoryafterthelimitisreachedyou'llstarttoget
121.#errorsforwriteoperations,andthismayevenleadtoDBinconsistency.
122.#
123.#maxmemory
124.
125.##############################APPENDONLYMODE###############################
126.
127.#BydefaultRedisasynchronouslydumpsthedatasetondisk.Ifyoucanlive
128.#withtheideathatthelatestrecordswillbelostifsomethinglikeacrash
129.#happensthisisthepreferredwaytorunRedis.Ifinsteadyoucarealot
130.#aboutyourdataanddon'twanttothatasinglerecordcangetlostyoushould
131.#enabletheappendonlymode:
whenthismodeisenabledRediswillappend
132.#everywriteoperationreceivedinthefileappendonly.log.Thisfilewill
133.#bereadonstartupinordertorebuildthefulldatasetinmemory.
134.#
135.#Notethatyoucanhaveboththeasyncdumpsandtheappendonlyfileifyou
136.#like(youhavetocommentthe"save"statementsabovetodisablethedumps).
137.#StillifappendonlymodeisenabledRediswillloadthedatafromthe
138.#logfileatstartupignoringthedump.rdbfile.
139.#
140.#Thenameoftheappendonlyfileis"appendonly.log"
141.#
142.#IMPORTANT:
ChecktheBGREWRITEAOFtocheckhowtorewritetheappend
143.#logfileinbackgroundwhenitgetstoobig.
144.
145.appendonlyyes
146.
147.#Thefsync()calltellstheOperatingSystemtoactuallywritedataondisk
148.#insteadtowaitformoredataintheoutputbuffer.SomeOSwillreallyflush
149.#dataondisk,someotherOSwilljusttrytodoitASAP.
150.#
151.#Redissupportsthreedifferentmodes:
152.#
153.#no:
don'tfsync,justlettheOSflushthedatawhenitwants.Faster.
154.#always:
fsyncaftereverywritetotheappendonlylog.Slow,Safest.
155.#everysec:
fsynconlyifonesecondpassedsincethelastfsync.Compromise.
156.#
157.#Thedefaultis"always"that'sthesaferoftheoptions.It'suptoyouto
158.#understandifyoucanrelaxthisto"everysec"thatwillfsynceverysecond
159.#orto"no"thatwilllettheoperatingsystemflushtheoutputbufferwhen
160.#itwant,forbetterperformances(butifyoucanlivewiththeideaof
161.#somedatalossconsiderthedefaultpersistencemodethat'ssnapshotting).
162.
163.appendfsyncalways
164.#appendfsynceverysec
165.#appendfsyncno
166.
167.###############################ADVANCEDCONFIG###############################
168.
169.#Gluesmalloutputbufferstogetherinordertosendsmallrepliesina
170.#singleTCPpacket.UsesabitmoreCPUbutmostofthetimesitisawin
171.#intermsofnumberofqueriespersecond.Use'yes'ifunsure.
172.glueoutputbufyes
173.
174.#Useobjectsharing.Cansavealotofmemoryifyouhavemanycommon
175.#stringinyourdataset,butperformslookupsagainstthesharedobjects
176.#poolsoitusesmoreCPUandcanbeabitslower.Usuallyit'sagood
177.#idea.
178.#
179.#Whenobjectsharingisenabled(shareobjectsyes)youcanuse
180.#shareobjectspoolsizetocontrolthesizeofthepoolusedinordertotry
181.#objectsharing.Abiggerpoolsizewillleadtobettersharingcapabilities.
182.#Ingeneralyouwantthisvaluetobeatleastthedoubleofthenumberof
183.#verycommonstringsyouhaveinyourdataset.
184.#
185.#WARNING:
objectsharingisexperimental,don'tenablethisfeature
186.#inproductionbeforeofRedis1.0-stable.Stillpleasetrythisfeaturein
187.#yourdevelopmentenvironmentsothatwecantestitbetter.
188.#shareobjectsno
189.#shareobjectspoolsize1024
启动redis
打开运行窗口
F:
\>cdredis-2.0.2
F:
\redis-2.0.2>redis-server.exeredis.conf
[2944]15Jun22:
44:
29*Serverstarted,Redisversion2.0.2
[2944]15Jun22:
44:
29*DBloadedfromappendonlyfile:
0seconds
[2944]15Jun22:
44:
29*Theserverisnowreadytoacceptconnectionsonport
379
[2944]15Jun22:
44:
30-DB0:
1keys(0volatile)in4slotsHT.
[2944]15Jun22:
44:
30-0clientsconnected(0slaves),450888bytesinuse
在打开一个窗口运行客户端
F:
\redis-2.0.2>redis-cli.exe
redis>
设置值:
redis>setajunajun
Reconnecting...OK
OK
取值:
redis>getajun
"ajun"
停止redis服务
redis>shutdown
如果需要redis持久化数据需要配置redis日志开启
在每次更新操作后进行日志记录,如果不开启,可能会在断电时导致一段时间内的数据丢失。
因为redis本身同步数据文件是按上面save条件来同步的,所以有的数据会在一段时间内只存在于内存中。
默认值为no
此时要在redis.conf中修改或者添加
appendonlyyes
更新日志文件名,默认值为appendonly.aof
#更新日志条件,共有3个可选值。
no表示等操作系统进行数据缓存同步到磁盘,always表示每次更新操作后手动调用fsync()将数据写到磁盘,everysec表示每秒同步一次(默认值)。
#appendfsyncalways
appendfsynceverysec
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Redis windows 测试redis持久化功能 测试 持久 功能