redis配置文件.conf的詳細(xì)說明_第1頁(yè)
redis配置文件.conf的詳細(xì)說明_第2頁(yè)
redis配置文件.conf的詳細(xì)說明_第3頁(yè)
redis配置文件.conf的詳細(xì)說明_第4頁(yè)
redis配置文件.conf的詳細(xì)說明_第5頁(yè)
已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

redis配置文件redis.conf#BydefaultRedisdoesnotrunasadaemon.Use'yes'ifyouneedNotethatRediswillwriteapidfileinvar/run/redis.pidwhendaemonized.#Redisyes啟daemonize#Whenrunningdaemonized,Rediswritesapidfilein/var/run/redis.pidby#default.Youcanspecifyacustompidfilelocationhere.#Redis以守護(hù)進(jìn)程的方式運(yùn)行的時(shí)候,Redispid/var/run/redis.pid,redis服務(wù)時(shí),需要指定不同的pid文件和端口pidfileAcceptconnectionsonthespecifiedport,defaultis6379.Ifport0isspecifiedRediswillnotlistenonaTCPsocket.port#Ifyouwantyoucanbindasingleinterface,ifthebindoptionisnot#specifiedalltheinterfaceswilllistenfor ingconnections.#指定Redis可接收請(qǐng)求的IP地址,不設(shè)置將處理所有請(qǐng)求,置#bind#ClosetheconnectionafteraisidleforNseconds(0todisable)timeout#Specifythelogfilename.Also'stdout'canbeusedto#Redistologonthestandardoutput.Notethatifyouusestandard#outputforloggingbutdaemonize,logswillbesentto/dev/null#log文件地址,logfile#Setthenumberofdatabases.ThedefaultdatabaseisDB0,youcanselect#adifferentoneonaper-connectionbasisusingSELECT<dbid>where#dbidisanumberbetween0and'databases'-#設(shè)置數(shù)據(jù)庫(kù)的個(gè)數(shù),SELECTdbid>命令來切換數(shù)據(jù)庫(kù)。默認(rèn)使用的數(shù)據(jù)庫(kù)是0databases##SavetheDBon# save<seconds><changes> WillsavetheDBifboththegivennumberofsecondsandthegiven numberofwriteoperationsagainsttheDBoccurred.# Intheexamplebelowthebehaviourwillbetosave: after900sec(15min)ifatleast1keychanged after300sec(5min)ifatleast10keyschanged after60secifatleast10000keyschanged# Noteyoucandisablesavingatallcommentingallthe"save"lines.#設(shè)置Redis進(jìn)行數(shù)據(jù)庫(kù)鏡像的頻率。#9001個(gè)keys#3010個(gè)keys#6010000個(gè)keyssave900save300save60#CompressstringobjectsusingLZFwhendump.rdbdatabases?#Fordefaultthat'ssetto'yes'asit'salmostalwaysawin.#IfyouwanttosavesomeCPUinthesavingchildsetitto'no'thedatasetwilllikelybebiggerifyouhavecompressiblevaluesorkeys.pressionThefilenamewheretodumptheDBdbfilename#Theworkingdirectory.#TheDBwillbewritteninsidethisdirectory,withthefilenamespecified#aboveusingthe'dbfilename'configurationdirective.##AlsotheAppendOnlyFilewillbecreatedinsidethisdirectory.#Notethatyoumustspecifyadirectoryhere,notafileRedis在進(jìn)行備份時(shí),先會(huì)將當(dāng)前數(shù)據(jù)庫(kù)的狀態(tài)寫入到一個(gè)臨時(shí)文件中,等備份完dir./#Master-Slavereplication.UseslaveoftomakeaRedisinstanceacopyof#anotherRedisserver.Notethattheconfigurationislocaltotheslave#soforexampleitispossibletoconfiguretheslavetosavetheDBwitha#differentinterval,ortolistentoanotherport,andsoon.#slaveof<masterip><masterport>#Ifthemasterispasswordprotected(usingthe"requirepass"configuration#directivebelow)itispossibletoltheslavetoauthenticatebefore#startingthereplicationsynchronizationprocess,otherwisethemasterwill#refusetheslaverequest.#masuth<master-#RequirestoissueAUTH<PASSWORD>beforeprocessinganyother#commands.Thismightbeusefulinenvironmentsinwhichyoudonottrust#otherswithaccesstothehostrunningredis-server.##Thisshouldstaycommentedoutforbackwardcompatibilityandbecause#peopledonotneedauth(e.g.theyruntheirownservers).#Warning:sinceRedisisprettyfastanoutsideusercantryup#150kpasswordspersecondagainstagoodbox.Thismeansthatyoushould#useaverystrongpasswordotherwiseitwillbeveryeasytobreak.警告:redis速度相當(dāng)快,一個(gè)外部的用戶可以在一秒鐘進(jìn)行150K次的嘗試,#requirepass#Setthemaxnumberofconnectedsatthesametime.Bydefaultthere#isnolimit,andit'suptothenumberoffiledescriptorstheRedisprocess#isabletoopen.Thespecialvalue'0'meansno#OncethelimitisreachedRediswillcloseallthenewconnectionssending#anerror'maxnumberofsreached'.#限制同時(shí)連接的客戶數(shù)量。當(dāng)連接數(shù)超過這個(gè)值時(shí),redis將不再接收其他連接請(qǐng)求,客戶端嘗試連接時(shí)將收到error信息#maxs#Don'tusemorememorythanthespecifiedamountof#WhenthememorylimitisreachedRediswilltrytoremove#accordinglytotheevictionselected(seemaxmemmory-).#IfRediscan'tremovekeysaccordingtothe,oriftheis#setto'noeviction',Rediswillstarttoreplywitherrorstocommands#thatwouldusemorememory,likeSET,LPUSH,andsoon,andwill#toreplytoread-onlycommandslikeGET.#ThisoptionisusuallyusefulwhenusingRedisasanLRUcache,ortoset#anhardmemorylimitforaninstance(usingthe'noeviction').##WARNING:Ifyouhaveslavesattachedtoaninstancewithmaxmemoryon,#thesizeoftheoutputbuffersneededtofeedtheslavesaresubtracted#fromtheusedmemorycount,sothatnetworkproblems/resyncswill#nottriggeraloopwherekeysareevicted,andinturntheoutput#bufferofslavesisfullwithDELsofkeysevictedtriggeringthedeletion#ofmorekeys,andsoforthuntilthedatabaseiscompleyemptied.##Inshort…ifyouhaveslavesattacheditissuggestedthatyouseta#limitformaxmemorysothatthereissomeRAMonthesystemforslave#outputbuffers(butthisisnotneedediftheis'noeviction').#設(shè)置redis能夠使用的最大內(nèi)存。當(dāng)內(nèi)存滿了的時(shí)候,如果還接收到set令,redis將先嘗試剔除設(shè)置過expire信息的key,而不管該key的過期時(shí)間還沒#在刪除時(shí),將按照過期時(shí)間進(jìn)行刪除,最早將要被過期的key將最先被刪除。如果帶有expire信息的key都刪光了,那么將返回錯(cuò)誤。#這樣,redis將不再接收寫請(qǐng)求,只接收get請(qǐng)求。maxmemory的設(shè)置比較適合于把redis當(dāng)作于類似memcached的緩存來使用#maxmemory#BydefaultRedisasynchronouslydumpsthedatasetondisk.Ifyoucanlive#withtheideathatthelatestrecordswillbelostifsomethinglikeacrash#happensthisisthepreferredwaytorunRedis.Ifinsteadyoucarealot#aboutyourdataanddon'twanttothatasinglerecordcangetlostyou#enabletheappendonlymode:whenthismodeisenabledRediswillappend#everywriteoperationreceivedinthefileappendonly.aof.Thisfilewill#bereadonstartupinordertorebuildthefulldatasetinmemory.#Notethatyoucanhaveboththeasyncdumpsandtheappendonlyfileifyou#like(youhavetocommentthe"save"statementsabovetodisablethe#StillifappendonlymodeisenabledRediswillloadthedatafromthe#logfileatstartupignoringthedump.rdbfile.##IMPORTANT:ChecktheBGREWRITEAOFtocheckhowtorewritethe#logfileinbackgroundwhenitgetstoo#默認(rèn)情況下,redis會(huì)在異步的把數(shù)據(jù)庫(kù)鏡像備份到磁盤,但是該備份是非#所以redis提供了另外一種更加高效的數(shù)據(jù)庫(kù)備份及恢復(fù)方式#開啟appendonly模式之后,redis會(huì)把所接收到的每一次寫操作請(qǐng)求都追加到appendonly.aof文件中,當(dāng)redis重新啟動(dòng)時(shí),會(huì)從該文件恢復(fù)出之前的狀#appendonly.aof文件過大,所以redis還支持了BGREWRITEAOF指令,對(duì)appendonly.aof進(jìn)行重新整理appendonlyno#Thefsync()calllstheOperatingSystemtoactuallywritedataon#insteadtowaitformoredataintheoutputbuffer.SomeOSwillreallyflush#dataondisk,someotherOSwilljusttrytodoitASAP.##Redissupportsthreedifferent##no:don'tfsync,justlettheOSflushthedatawhenitwants.Faster.#always:fsyncaftereverywritetotheappendonlylog.Slow,Safest.#everysec:fsynconlyifonesecondpassedsincethelastfsync.Compromise.#Thedefaultis"everysec"that'susuallytherightcompromise#speedanddatasafety.It'suptoyoutounderstandifyoucanrelaxthisto#"no"thatwillwilllettheoperatingsystemflushtheoutputbufferwhen#itwants,forbetterperformances(butifyoucanlivewiththeideaof#somedatalossconsiderthedefaultpersistencemodethat'ssnapshotting),#oronthecontrary,use"always"that'sveryslowbutabitsaferthan#everysec.#Ifunsure,use#appendonly.aof文件進(jìn)行同步的頻率。always表示每次有寫操作都進(jìn)行同步,everysec表示對(duì)寫操作進(jìn)行累積,每秒同步一次。#appendfsyncalwaysappendfsynceverysec#appendfsyncno#VirtualMemoryallowsRedistoworkwithdatasetsbiggerthantheactual#amountofRAMneededtoholdthewholedatasetinmemory.#Inordertodosoveryusedkeysaretakeninmemorywhiletheotherkeys#areswappedintoaswapfile,similarlytowhatoperatingsystemsdo#withmemory##ToenableVMjustset'vm-enabled'toyes,andsetthefollowingthree#VMparametersaccordinglytoyourneeds.#redis是一個(gè)內(nèi)存數(shù)據(jù)庫(kù),而且當(dāng)內(nèi)存滿的時(shí)候,無法接收新的寫請(qǐng)求,所以在redis2.0中,提供了虛擬內(nèi)存的支持。#但是需要注意的是,redis中,所有的key都會(huì)放在內(nèi)存中,在內(nèi)存不夠時(shí),value把vm-max-memory設(shè)置到足夠來放下你的所有的keyvm-enabled#vm-enabled#ThisisthepathoftheRedisswapfile.Asyoucanguess,swap#can'tbesharedbydifferentRedisinstances,somakesuretouseaswap#fileforeveryredisprocessyouarerunning.Rediswillcominifthe#swapfileisalreadyinuse.#ThebestkindofstoragefortheRedisswapfile(that'saccessedatrandom)#isaSolidStateDisk(SSD).##***WARNING***ifyouareusingasharedhostingthedefaultofputting#theswapfileunder/tmpisnotsecure.CreateadirwithaccessgrantedonlytoRedisuserandconfigureRedistocreatetheswapfilethere.vm-swap-file#vm-max-memoryconfigurestheVMtouseatmaxthespecifiedamountof#RAM.Everythingthatdeosnotfitwillbeswappedondisk*if*possible,that#is,ifthereisstillenoughcontiguousspaceintheswapfile.##Withvm-max-memory0thesystemwillswapeverythingitcan.Notagood#default,justspecifythemaxamountofRAMyoucaninbytes,butit's#bettertoleavesomemargin.ForinstancespecifyanamountofRAM#that'smoreorlessbetween60and80%ofyourRAM.#這里設(shè)置開啟虛擬內(nèi)存之后,redis將使用的最大物理內(nèi)存的大小。默認(rèn)為0,redis將把他所有的能放到交換文件的都放到交換文件中,以盡量少的使用物理#在生產(chǎn)環(huán)境下,需要根據(jù)實(shí)際情況設(shè)置該值,最好不要使用默認(rèn)的vm-max-memory#Redisswapfilesissplitintopages.Anobjectcanbesavedusingmultiple#contiguouspages,butpagescan'tbesharedbetweendifferentobjects.#Soifyourpageistoobig,smallobjectsswappedoutondiskwillwaste#alotofspace.Ifyoupageistoosmall,thereislessspaceintheswap#file(assumingyouconfiguredthesamenumberoftotalswapfilepages).#Ifyouusealotofsmallobjects,useapagesizeof64or32bytes.#Ifyouusealotofbigobjects,useabiggerpagesize.#Ifunsure,usethe#設(shè)置虛擬內(nèi)存的頁(yè)大小,value值比較大,value中放vmsize#Numberoftotalmemorypagesintheswap#Giventhatthepagetable(abitmapof/usedpages)istakeninmemory,#every8pagesondiskwillconsume1byteofRAM.##Thetotalswapsizeisvmsize*vms#Withthedefaultof32-bytesmemorypagesand pagesRediswill#usea4GBswapfile,thatwilluse16MBofRAMforthepagetable.##It'sbettertousethesmallestacceptablevalueforyourapplication,#butthedefaultislargeinordertoworkinmostconditions.#page數(shù)量,需要注意的是,pagetable信息會(huì)放在物理內(nèi)存中,8個(gè)page就會(huì)占據(jù)RAM中的1個(gè)byte。#vmsize*vms#MaxnumberofVMI/Othreadsrunningatthesame#Thisthreadsareusedtoread/writedatafrom/toswapfile,since#alsoencodeanddecodeobjectsfromdisktomemoryorthereverse,abigger#numberofthreadscanhelpwithbigobjectseveniftheycan'thelpwith#I/Oitselfasthephysicaldevicemaynotbeabletocouplewithmany#reads/writesoperationsatthesametime.##Thespecialvalueof0turnoffthreadedI/Oandenablestheblocking#VirtualMemoryimplementation.#VMIOvm-max-threads#Hashesareencodedinaspecialway(muchmorememoryefficient)when#haveatmaxagivennumerofelements,andthebiggestelementdoesnot#exceedagiventhreshold.Youcanconfigurethislimitswiththefol

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論