Docker 启动Redis 并设置密码的操作
redis使用redisversion5的apline(阿尔卑斯)镜像,小巧快速
新建一个docker-compose.yml文件
直接启动,不需连接密码配置如下:
version:'3.3' services: cache: image:redis:5-alpine restart:always ports: -"6379:6379"
端口映射为:6379(redis默认端口)
在docker-compose.yml文件的目录下运行下面指令,启动Redis:
docker-composeup-d
Tip:如果设置主机上设置了docker服务的开机启动,那么机器重启后,redis也会自动启动。
如果需要设置链接密码:
version:'3.3' services: cache: image:redis:5-alpine restart:always ports: -"6379:6379" command:["redis-server","--appendonly","yes","--requirepass","123456"]
--requirepass后面参数就是需要设置的链接密码
停止Redis,在docker-compose.yml文件的目录下运行下面指令
docker-composedown
补充知识:在yum安装(docker方式安装)的redis配置认证密码和限定IP登录
一.redis配置密码
1.通过配置文件进行配置
yum方式安装的redis配置文件通常在/etc/redis.conf中,打开配置文件找到
#requirepassfoobared
去掉行前的注释,并修改密码为所需的密码,保存文件
requirepassmyRedis
重启redis
sudoserviceredisrestart
或者
sudoserviceredisstop
sudoredis-server/etc/redis.conf
这个时候尝试登录redis,发现可以登上,但是执行具体命令是提示操作不允许
redis-cli-h127.0.0.1-p6379 redis127.0.0.1:6379> redis127.0.0.1:6379>keys* (error)ERRoperationnotpermitted redis127.0.0.1:6379>select1 (error)ERRoperationnotpermitted redis127.0.0.1:6379[1]>
尝试用密码登录并执行具体的命令看到可以成功执行
redis-cli-h127.0.0.1-p6379-amyRedis
redis127.0.0.1:6379>keys*
1)"myset"
2)"mysortset"
redis127.0.0.1:6379>select1 OK redis127.0.0.1:6379[1]>configgetrequirepass
1)"requirepass"
2)"myRedis"
2.通过命令行进行配置
redis127.0.0.1:6379[1]>configsetrequirepassmy_redis OK redis127.0.0.1:6379[1]>configgetrequirepass
1)"requirepass"
2)"my_redis"
无需重启redis
使用第一步中配置文件中配置的老密码登录redis,会发现原来的密码已不可用,操作被拒绝
redis-cli-h127.0.0.1-p6379-amyRedis redis127.0.0.1:6379>configgetrequirepass (error)ERRoperationnotpermitted
使用修改后的密码登录redis,可以执行相应操作
redis-cli-h127.0.0.1-p6379-amy_redis
redis127.0.0.1:6379>configgetrequirepass
1)"requirepass"
2)"my_redis
尝试重启一下redis,用新配置的密码登录redis执行操作,发现新的密码失效,redis重新使用了配置文件中的密码
sudoserviceredisrestart Stoppingredis-server:[OK] Startingredis-server:[OK] redis-cli-h127.0.0.1-p6379-amy_redis redis127.0.0.1:6379>configgetrequirepass (error)ERRoperationnotpermitted redis-cli-h127.0.0.1-p6379-amyRedis redis127.0.0.1:6379>configgetrequirepass
1)"requirepass"
2)"myRedis"
除了在登录时通过-a参数制定密码外,还可以登录时不指定密码,而在执行操作前进行认证。
redis-cli-h127.0.0.1-p6379 redis127.0.0.1:6379>configgetrequirepass (error)ERRoperationnotpermitted redis127.0.0.1:6379>authmyRedis OK redis127.0.0.1:6379>configgetrequirepass
1)"requirepass"
2)"myRedis"
3.master配置了密码,slave如何配置
若master配置了密码则slave也要配置相应的密码参数否则无法进行正常复制的。
slave中配置文件内找到如下行,移除注释,修改密码即可
#masterauthmstpassword
3.在docker中的redis进行配置
a.编写Dockerfile文件
FROMredis MAINTAINER"roamer" #自定义的配置文件,以替换原有image中的配置文件 COPYredis.conf/usr/local/etc/redis/redis.conf CMD["redis-server","/usr/local/etc/redis/redis.conf"] #RUNapt-getupdate&&apt-getinstallvim-y
b.编写redis的配置文件
这个文件通过Dockerfile进行build的时候,复制到rediscontainer里面,并且通过启动redis-server的时候指定使用这个配置文件
#Redisconfigurationfileexample. # #Notethatinordertoreadtheconfigurationfile,Redismustbe #startedwiththefilepathasfirstargument: # #./redis-server/path/to/redis.conf #Noteonunits:whenmemorysizeisneeded,itispossibletospecify #itintheusualformof1k5GB4Mandsoforth: # #1k=>1000bytes #1kb=>1024bytes #1m=>1000000bytes #1mb=>1024*1024bytes #1g=>1000000000bytes #1gb=>1024*1024*1024bytes # #unitsarecaseinsensitiveso1GB1Gb1gBareallthesame. ##################################INCLUDES################################### #Includeoneormoreotherconfigfileshere.Thisisusefulifyou #haveastandardtemplatethatgoestoallRedisserversbutalsoneed #tocustomizeafewper-serversettings.Includefilescaninclude #otherfiles,sousethiswisely. # #Noticeoption"include"won'tberewrittenbycommand"CONFIGREWRITE" #fromadminorRedisSentinel.SinceRedisalwaysusesthelastprocessed #lineasvalueofaconfigurationdirective,you'dbetterputincludes #atthebeginningofthisfiletoavoidoverwritingconfigchangeatruntime. # #Ifinsteadyouareinterestedinusingincludestooverrideconfiguration #options,itisbettertouseincludeasthelastline. # #include/path/to/local.conf #include/path/to/other.conf ##################################NETWORK##################################### #Bydefault,ifno"bind"configurationdirectiveisspecified,Redislistens #forconnectionsfromallthenetworkinterfacesavailableontheserver. #Itispossibletolistentojustoneormultipleselectedinterfacesusing #the"bind"configurationdirective,followedbyoneormoreIPaddresses. # #Examples: # #bind192.168.1.10010.0.0.1 #bind127.0.0.1::1 # #~~~WARNING~~~IfthecomputerrunningRedisisdirectlyexposedtothe #internet,bindingtoalltheinterfacesisdangerousandwillexposethe #instancetoeverybodyontheinternet.Sobydefaultweuncommentthe #followingbinddirective,thatwillforceRedistolistenonlyinto #theIPv4lookbackinterfaceaddress(thismeansRediswillbeableto #acceptconnectionsonlyfromclientsrunningintothesamecomputerit #isrunning). # #IFYOUARESUREYOUWANTYOURINSTANCETOLISTENTOALLTHEINTERFACES #JUSTCOMMENTTHEFOLLOWINGLINE. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #bind127.0.0.1 #Protectedmodeisalayerofsecurityprotection,inordertoavoidthat #Redisinstancesleftopenontheinternetareaccessedandexploited. # #Whenprotectedmodeisonandif: # #1)Theserverisnotbindingexplicitlytoasetofaddressesusingthe #"bind"directive. #2)Nopasswordisconfigured. # #Theserveronlyacceptsconnectionsfromclientsconnectingfromthe #IPv4andIPv6loopbackaddresses127.0.0.1and::1,andfromUnixdomain #sockets. # #Bydefaultprotectedmodeisenabled.Youshoulddisableitonlyif #youaresureyouwantclientsfromotherhoststoconnecttoRedis #evenifnoauthenticationisconfigured,noraspecificsetofinterfaces #areexplicitlylistedusingthe"bind"directive. protected-modeyes #Acceptconnectionsonthespecifiedport,defaultis6379(IANA#815344). #Ifport0isspecifiedRediswillnotlistenonaTCPsocket. port6379 #TCPlisten()backlog. # #Inhighrequests-per-secondenvironmentsyouneedanhighbackloginorder #toavoidslowclientsconnectionsissues.NotethattheLinuxkernel #willsilentlytruncateittothevalueof/proc/sys/net/core/somaxconnso #makesuretoraiseboththevalueofsomaxconnandtcp_max_syn_backlog #inordertogetthedesiredeffect. tcp-backlog511 #Unixsocket. # #SpecifythepathfortheUnixsocketthatwillbeusedtolistenfor #incomingconnections.Thereisnodefault,soRediswillnotlisten #onaunixsocketwhennotspecified. # #unixsocket/tmp/redis.sock #unixsocketperm700 #ClosetheconnectionafteraclientisidleforNseconds(0todisable) timeout0 #TCPkeepalive. # #Ifnon-zero,useSO_KEEPALIVEtosendTCPACKstoclientsinabsence #ofcommunication.Thisisusefulfortworeasons: # #1)Detectdeadpeers. #2)Taketheconnectionalivefromthepointofviewofnetwork #equipmentinthemiddle. # #OnLinux,thespecifiedvalue(inseconds)istheperiodusedtosendACKs. #Notethattoclosetheconnectionthedoubleofthetimeisneeded. #Onotherkernelstheperioddependsonthekernelconfiguration. # #Areasonablevalueforthisoptionis300seconds,whichisthenew #RedisdefaultstartingwithRedis3.2.1. tcp-keepalive300 #################################GENERAL##################################### #BydefaultRedisdoesnotrunasadaemon.Use'yes'ifyouneedit. #NotethatRediswillwriteapidfilein/var/run/redis.pidwhendaemonized. daemonizeno #IfyourunRedisfromupstartorsystemd,Rediscaninteractwithyour #supervisiontree.Options: #supervisedno-nosupervisioninteraction #supervisedupstart-signalupstartbyputtingRedisintoSIGSTOPmode #supervisedsystemd-signalsystemdbywritingREADY=1to$NOTIFY_SOCKET #supervisedauto-detectupstartorsystemdmethodbasedon #UPSTART_JOBorNOTIFY_SOCKETenvironmentvariables #Note:thesesupervisionmethodsonlysignal"processisready." #Theydonotenablecontinuouslivenesspingsbacktoyoursupervisor. supervisedno #Ifapidfileisspecified,Rediswritesitwherespecifiedatstartup #andremovesitatexit. # #Whentheserverrunsnondaemonized,nopidfileiscreatedifnoneis #specifiedintheconfiguration.Whentheserverisdaemonized,thepidfile #isusedevenifnotspecified,defaultingto"/var/run/redis.pid". # #Creatingapidfileisbesteffort:ifRedisisnotabletocreateit #nothingbadhappens,theserverwillstartandrunnormally. pidfile/var/run/redis_6379.pid #Specifytheserververbositylevel. #Thiscanbeoneof: #debug(alotofinformation,usefulfordevelopment/testing) #verbose(manyrarelyusefulinfo,butnotamesslikethedebuglevel) #notice(moderatelyverbose,whatyouwantinproductionprobably) #warning(onlyveryimportant/criticalmessagesarelogged) loglevelnotice #Specifythelogfilename.Alsotheemptystringcanbeusedtoforce #Redistologonthestandardoutput.Notethatifyouusestandard #outputforloggingbutdaemonize,logswillbesentto/dev/null logfile"" #Toenableloggingtothesystemlogger,justset'syslog-enabled'toyes, #andoptionallyupdatetheothersyslogparameterstosuityourneeds. #syslog-enabledno #Specifythesyslogidentity. #syslog-identredis #Specifythesyslogfacility.MustbeUSERorbetweenLOCAL0-LOCAL7. #syslog-facilitylocal0 #Setthenumberofdatabases.ThedefaultdatabaseisDB0,youcanselect #adifferentoneonaper-connectionbasisusingSELECTwhere #dbidisanumberbetween0and'databases'-1 databases16 ################################SNAPSHOTTING################################ # #SavetheDBondisk: # #save # #WillsavetheDBifboththegivennumberofsecondsandthegiven #numberofwriteoperationsagainsttheDBoccurred. # #Intheexamplebelowthebehaviourwillbetosave: #after900sec(15min)ifatleast1keychanged #after300sec(5min)ifatleast10keyschanged #after60secifatleast10000keyschanged # #Note:youcandisablesavingcompletelybycommentingoutall"save"lines. # #Itisalsopossibletoremoveallthepreviouslyconfiguredsave #pointsbyaddingasavedirectivewithasingleemptystringargument #likeinthefollowingexample: # #save"" save9001 save30010 save6010000 #BydefaultRediswillstopacceptingwritesifRDBsnapshotsareenabled #(atleastonesavepoint)andthelatestbackgroundsavefailed. #Thiswillmaketheuseraware(inahardway)thatdataisnotpersisting #ondiskproperly,otherwisechancesarethatnoonewillnoticeandsome #disasterwillhappen. # #IfthebackgroundsavingprocesswillstartworkingagainRediswill #automaticallyallowwritesagain. # #HoweverifyouhavesetupyourpropermonitoringoftheRedisserver #andpersistence,youmaywanttodisablethisfeaturesothatRediswill #continuetoworkasusualevenifthereareproblemswithdisk, #permissions,andsoforth. stop-writes-on-bgsave-erroryes #CompressstringobjectsusingLZFwhendump.rdbdatabases? #Fordefaultthat'ssetto'yes'asit'salmostalwaysawin. #IfyouwanttosavesomeCPUinthesavingchildsetitto'no'but #thedatasetwilllikelybebiggerifyouhavecompressiblevaluesorkeys. rdbcompressionyes #Sinceversion5ofRDBaCRC64checksumisplacedattheendofthefile. #Thismakestheformatmoreresistanttocorruptionbutthereisaperformance #hittopay(around10%)whensavingandloadingRDBfiles,soyoucandisableit #formaximumperformances. # #RDBfilescreatedwithchecksumdisabledhaveachecksumofzerothatwill #telltheloadingcodetoskipthecheck. rdbchecksumyes #ThefilenamewheretodumptheDB dbfilenamedump.rdb #Theworkingdirectory. # #TheDBwillbewritteninsidethisdirectory,withthefilenamespecified #aboveusingthe'dbfilename'configurationdirective. # #TheAppendOnlyFilewillalsobecreatedinsidethisdirectory. # #Notethatyoumustspecifyadirectoryhere,notafilename. dir./ #################################REPLICATION################################# #Master-Slavereplication.UseslaveoftomakeaRedisinstanceacopyof #anotherRedisserver.AfewthingstounderstandASAPaboutRedisreplication. # #1)Redisreplicationisasynchronous,butyoucanconfigureamasterto #stopacceptingwritesifitappearstobenotconnectedwithatleast #agivennumberofslaves. #2)Redisslavesareabletoperformapartialresynchronizationwiththe #masterifthereplicationlinkislostforarelativelysmallamountof #time.Youmaywanttoconfigurethereplicationbacklogsize(seethenext #sectionsofthisfile)withasensiblevaluedependingonyourneeds. #3)Replicationisautomaticanddoesnotneeduserintervention.Aftera #networkpartitionslavesautomaticallytrytoreconnecttomasters #andresynchronizewiththem. # #slaveof #Ifthemasterispasswordprotected(usingthe"requirepass"configuration #directivebelow)itispossibletotelltheslavetoauthenticatebefore #startingthereplicationsynchronizationprocess,otherwisethemasterwill #refusetheslaverequest. # #masterauth #Whenaslavelosesitsconnectionwiththemaster,orwhenthereplication #isstillinprogress,theslavecanactintwodifferentways: # #1)ifslave-serve-stale-dataissetto'yes'(thedefault)theslavewill #stillreplytoclientrequests,possiblywithoutofdatedata,orthe #datasetmayjustbeemptyifthisisthefirstsynchronization. # #2)ifslave-serve-stale-dataissetto'no'theslavewillreplywith #anerror"SYNCwithmasterinprogress"toallthekindofcommands #buttoINFOandSLAVEOF. # slave-serve-stale-datayes #Youcanconfigureaslaveinstancetoacceptwritesornot.Writingagainst #aslaveinstancemaybeusefultostoresomeephemeraldata(becausedata #writtenonaslavewillbeeasilydeletedafterresyncwiththemaster)but #mayalsocauseproblemsifclientsarewritingtoitbecauseofa #misconfiguration. # #SinceRedis2.6bydefaultslavesareread-only. # #Note:readonlyslavesarenotdesignedtobeexposedtountrustedclients #ontheinternet.It'sjustaprotectionlayeragainstmisuseoftheinstance. #Stillareadonlyslaveexportsbydefaultalltheadministrativecommands #suchasCONFIG,DEBUG,andsoforth.Toalimitedextentyoucanimprove #securityofreadonlyslavesusing'rename-command'toshadowallthe #administrative/dangerouscommands. slave-read-onlyyes #ReplicationSYNCstrategy:diskorsocket. # #------------------------------------------------------- #WARNING:DISKLESSREPLICATIONISEXPERIMENTALCURRENTLY #------------------------------------------------------- # #Newslavesandreconnectingslavesthatarenotabletocontinuethereplication #processjustreceivingdifferences,needtodowhatiscalleda"full #synchronization".AnRDBfileistransmittedfromthemastertotheslaves. #Thetransmissioncanhappenintwodifferentways: # #1)Disk-backed:TheRedismastercreatesanewprocessthatwritestheRDB #fileondisk.Laterthefileistransferredbytheparent #processtotheslavesincrementally. #2)Diskless:TheRedismastercreatesanewprocessthatdirectlywritesthe #RDBfiletoslavesockets,withouttouchingthediskatall. # #Withdisk-backedreplication,whiletheRDBfileisgenerated,moreslaves #canbequeuedandservedwiththeRDBfileassoonasthecurrentchildproducing #theRDBfilefinishesitswork.Withdisklessreplicationinsteadonce #thetransferstarts,newslavesarrivingwillbequeuedandanewtransfer #willstartwhenthecurrentoneterminates. # #Whendisklessreplicationisused,themasterwaitsaconfigurableamountof #time(inseconds)beforestartingthetransferinthehopethatmultipleslaves #willarriveandthetransfercanbeparallelized. # #Withslowdisksandfast(largebandwidth)networks,disklessreplication #worksbetter. repl-diskless-syncno #Whendisklessreplicationisenabled,itispossibletoconfigurethedelay #theserverwaitsinordertospawnthechildthattransferstheRDBviasocket #totheslaves. # #Thisisimportantsinceoncethetransferstarts,itisnotpossibletoserve #newslavesarriving,thatwillbequeuedforthenextRDBtransfer,sotheserver #waitsadelayinordertoletmoreslavesarrive. # #Thedelayisspecifiedinseconds,andbydefaultis5seconds.Todisable #itentirelyjustsetitto0secondsandthetransferwillstartASAP. repl-diskless-sync-delay5 #SlavessendPINGstoserverinapredefinedinterval.It'spossibletochange #thisintervalwiththerepl_ping_slave_periodoption.Thedefaultvalueis10 #seconds. # #repl-ping-slave-period10 #Thefollowingoptionsetsthereplicationtimeoutfor: # #1)BulktransferI/OduringSYNC,fromthepointofviewofslave. #2)Mastertimeoutfromthepointofviewofslaves(data,pings). #3)Slavetimeoutfromthepointofviewofmasters(REPLCONFACKpings). # #Itisimportanttomakesurethatthisvalueisgreaterthanthevalue #specifiedforrepl-ping-slave-periodotherwiseatimeoutwillbedetected #everytimethereislowtrafficbetweenthemasterandtheslave. # #repl-timeout60 #DisableTCP_NODELAYontheslavesocketafterSYNC? # #Ifyouselect"yes"RediswilluseasmallernumberofTCPpacketsand #lessbandwidthtosenddatatoslaves.Butthiscanaddadelayfor #thedatatoappearontheslaveside,upto40millisecondswith #Linuxkernelsusingadefaultconfiguration. # #Ifyouselect"no"thedelayfordatatoappearontheslavesidewill #bereducedbutmorebandwidthwillbeusedforreplication. # #Bydefaultweoptimizeforlowlatency,butinveryhightrafficconditions #orwhenthemasterandslavesaremanyhopsaway,turningthisto"yes"may #beagoodidea. repl-disable-tcp-nodelayno #Setthereplicationbacklogsize.Thebacklogisabufferthataccumulates #slavedatawhenslavesaredisconnectedforsometime,sothatwhenaslave #wantstoreconnectagain,oftenafullresyncisnotneeded,butapartial #resyncisenough,justpassingtheportionofdatatheslavemissedwhile #disconnected. # #Thebiggerthereplicationbacklog,thelongerthetimetheslavecanbe #disconnectedandlaterbeabletoperformapartialresynchronization. # #Thebacklogisonlyallocatedoncethereisatleastaslaveconnected. # #repl-backlog-size1mb #Afteramasterhasnolongerconnectedslavesforsometime,thebacklog #willbefreed.Thefollowingoptionconfigurestheamountofsecondsthat #needtoelapse,startingfromthetimethelastslavedisconnected,for #thebacklogbuffertobefreed. # #Avalueof0meanstoneverreleasethebacklog. # #repl-backlog-ttl3600 #TheslavepriorityisanintegernumberpublishedbyRedisintheINFOoutput. #ItisusedbyRedisSentinelinordertoselectaslavetopromoteintoa #masterifthemasterisnolongerworkingcorrectly. # #Aslavewithalowprioritynumberisconsideredbetterforpromotion,so #forinstanceiftherearethreeslaveswithpriority10,100,25Sentinelwill #picktheonewithpriority10,thatisthelowest. # #Howeveraspecialpriorityof0markstheslaveasnotabletoperformthe #roleofmaster,soaslavewithpriorityof0willneverbeselectedby #RedisSentinelforpromotion. # #Bydefaultthepriorityis100. slave-priority100 #Itispossibleforamastertostopacceptingwritesiftherearelessthan #Nslavesconnected,havingalaglessorequalthanMseconds. # #TheNslavesneedtobein"online"state. # #Thelaginseconds,thatmustbe<=thespecifiedvalue,iscalculatedfrom #thelastpingreceivedfromtheslave,thatisusuallysenteverysecond. # #ThisoptiondoesnotGUARANTEEthatNreplicaswillacceptthewrite,but #willlimitthewindowofexposureforlostwritesincasenotenoughslaves #areavailable,tothespecifiednumberofseconds. # #Forexampletorequireatleast3slaveswithalag<=10secondsuse: # #min-slaves-to-write3 #min-slaves-max-lag10 # #Settingoneortheotherto0disablesthefeature. # #Bydefaultmin-slaves-to-writeissetto0(featuredisabled)and #min-slaves-max-lagissetto10. ##################################SECURITY################################### #RequireclientstoissueAUTH beforeprocessinganyother #commands.Thismightbeusefulinenvironmentsinwhichyoudonottrust #otherswithaccesstothehostrunningredis-server. # #Thisshouldstaycommentedoutforbackwardcompatibilityandbecausemost #peopledonotneedauth(e.g.theyruntheirownservers). # #Warning:sinceRedisisprettyfastanoutsideusercantryupto #150kpasswordspersecondagainstagoodbox.Thismeansthatyoushould #useaverystrongpasswordotherwiseitwillbeveryeasytobreak. # requirepassmyRedis #Commandrenaming. # #Itispossibletochangethenameofdangerouscommandsinashared #environment.ForinstancetheCONFIGcommandmayberenamedintosomething #hardtoguesssothatitwillstillbeavailableforinternal-usetools #butnotavailableforgeneralclients. # #Example: # #rename-commandCONFIGb840fc02d524045429941cc15f59e41cb7be6c52 # #Itisalsopossibletocompletelykillacommandbyrenamingitinto #anemptystring: # #rename-commandCONFIG"" # #Pleasenotethatchangingthenameofcommandsthatareloggedintothe #AOFfileortransmittedtoslavesmaycauseproblems. ###################################LIMITS#################################### #Setthemaxnumberofconnectedclientsatthesametime.Bydefault #thislimitissetto10000clients,howeveriftheRedisserverisnot #abletoconfiguretheprocessfilelimittoallowforthespecifiedlimit #themaxnumberofallowedclientsissettothecurrentfilelimit #minus32(asRedisreservesafewfiledescriptorsforinternaluses). # #OncethelimitisreachedRediswillcloseallthenewconnectionssending #anerror'maxnumberofclientsreached'. # #maxclients10000 #Don'tusemorememorythanthespecifiedamountofbytes. #WhenthememorylimitisreachedRediswilltrytoremovekeys #accordingtotheevictionpolicyselected(seemaxmemory-policy). # #IfRediscan'tremovekeysaccordingtothepolicy,orifthepolicyis #setto'noeviction',Rediswillstarttoreplywitherrorstocommands #thatwouldusemorememory,likeSET,LPUSH,andsoon,andwillcontinue #toreplytoread-onlycommandslikeGET. # #ThisoptionisusuallyusefulwhenusingRedisasanLRUcache,ortoset #ahardmemorylimitforaninstance(usingthe'noeviction'policy). # #WARNING:Ifyouhaveslavesattachedtoaninstancewithmaxmemoryon, #thesizeoftheoutputbuffersneededtofeedtheslavesaresubtracted #fromtheusedmemorycount,sothatnetworkproblems/resyncswill #nottriggeraloopwherekeysareevicted,andinturntheoutput #bufferofslavesisfullwithDELsofkeysevictedtriggeringthedeletion #ofmorekeys,andsoforthuntilthedatabaseiscompletelyemptied. # #Inshort...ifyouhaveslavesattacheditissuggestedthatyousetalower #limitformaxmemorysothatthereissomefreeRAMonthesystemforslave #outputbuffers(butthisisnotneededifthepolicyis'noeviction'). # #maxmemory #MAXMEMORYPOLICY:howRediswillselectwhattoremovewhenmaxmemory #isreached.Youcanselectamongfivebehaviors: # #volatile-lru->removethekeywithanexpiresetusinganLRUalgorithm #allkeys-lru->removeanykeyaccordingtotheLRUalgorithm #volatile-random->removearandomkeywithanexpireset #allkeys-random->removearandomkey,anykey #volatile-ttl->removethekeywiththenearestexpiretime(minorTTL) #noeviction->don'texpireatall,justreturnanerroronwriteoperations # #Note:withanyoftheabovepolicies,Rediswillreturnanerroronwrite #operations,whentherearenosuitablekeysforeviction. # #Atthedateofwritingthesecommandsare:setsetnxsetexappend #incrdecrrpushlpushrpushxlpushxlinsertlsetrpoplpushsadd #sintersinterstoresunionsunionstoresdiffsdiffstorezaddzincrby #zunionstorezinterstorehsethsetnxhmsethincrbyincrbydecrby #getsetmsetmsetnxexecsort # #Thedefaultis: # #maxmemory-policynoeviction #LRUandminimalTTLalgorithmsarenotprecisealgorithmsbutapproximated #algorithms(inordertosavememory),soyoucantuneitforspeedor #accuracy.FordefaultRediswillcheckfivekeysandpicktheonethatwas #usedlessrecently,youcanchangethesamplesizeusingthefollowing #configurationdirective. # #Thedefaultof5producesgoodenoughresults.10Approximatesveryclosely #trueLRUbutcostsabitmoreCPU.3isveryfastbutnotveryaccurate. # #maxmemory-samples5 ##############################APPENDONLYMODE############################### #BydefaultRedisasynchronouslydumpsthedatasetondisk.Thismodeis #goodenoughinmanyapplications,butanissuewiththeRedisprocessor #apoweroutagemayresultintoafewminutesofwriteslost(dependingon #theconfiguredsavepoints). # #TheAppendOnlyFileisanalternativepersistencemodethatprovides #muchbetterdurability.Forinstanceusingthedefaultdatafsyncpolicy #(seelaterintheconfigfile)Rediscanlosejustonesecondofwritesina #dramaticeventlikeaserverpoweroutage,orasinglewriteifsomething #wrongwiththeRedisprocessitselfhappens,buttheoperatingsystemis #stillrunningcorrectly. # #AOFandRDBpersistencecanbeenabledatthesametimewithoutproblems. #IftheAOFisenabledonstartupRediswillloadtheAOF,thatisthefile #withthebetterdurabilityguarantees. # #Pleasecheckhttp://redis.io/topics/persistenceformoreinformation. appendonlyno #Thenameoftheappendonlyfile(default:"appendonly.aof") appendfilename"appendonly.aof" #Thefsync()calltellstheOperatingSystemtoactuallywritedataondisk #insteadofwaitingformoredataintheoutputbuffer.SomeOSwillreallyflush #dataondisk,someotherOSwilljusttrytodoitASAP. # #Redissupportsthreedifferentmodes: # #no:don'tfsync,justlettheOSflushthedatawhenitwants.Faster. #always:fsyncaftereverywritetotheappendonlylog.Slow,Safest. #everysec:fsynconlyonetimeeverysecond.Compromise. # #Thedefaultis"everysec",asthat'susuallytherightcompromisebetween #speedanddatasafety.It'suptoyoutounderstandifyoucanrelaxthisto #"no"thatwilllettheoperatingsystemflushtheoutputbufferwhen #itwants,forbetterperformances(butifyoucanlivewiththeideaof #somedatalossconsiderthedefaultpersistencemodethat'ssnapshotting), #oronthecontrary,use"always"that'sveryslowbutabitsaferthan #everysec. # #Moredetailspleasecheckthefollowingarticle: #http://antirez.com/post/redis-persistence-demystified.html # #Ifunsure,use"everysec". #appendfsyncalways appendfsynceverysec #appendfsyncno #WhentheAOFfsyncpolicyissettoalwaysoreverysec,andabackground #savingprocess(abackgroundsaveorAOFlogbackgroundrewriting)is #performingalotofI/Oagainstthedisk,insomeLinuxconfigurations #Redismayblocktoolongonthefsync()call.Notethatthereisnofixfor #thiscurrently,asevenperformingfsyncinadifferentthreadwillblock #oursynchronouswrite(2)call. # #Inordertomitigatethisproblemit'spossibletousethefollowingoption #thatwillpreventfsync()frombeingcalledinthemainprocesswhilea #BGSAVEorBGREWRITEAOFisinprogress. # #Thismeansthatwhileanotherchildissaving,thedurabilityofRedisis #thesameas"appendfsyncnone".Inpracticalterms,thismeansthatitis #possibletoloseupto30secondsoflogintheworstscenario(withthe #defaultLinuxsettings). # #Ifyouhavelatencyproblemsturnthisto"yes".Otherwiseleaveitas #"no"thatisthesafestpickfromthepointofviewofdurability. no-appendfsync-on-rewriteno #Automaticrewriteoftheappendonlyfile. #Redisisabletoautomaticallyrewritethelogfileimplicitlycalling #BGREWRITEAOFwhentheAOFlogsizegrowsbythespecifiedpercentage. # #Thisishowitworks:RedisremembersthesizeoftheAOFfileafterthe #latestrewrite(ifnorewritehashappenedsincetherestart,thesizeof #theAOFatstartupisused). # #Thisbasesizeiscomparedtothecurrentsize.Ifthecurrentsizeis #biggerthanthespecifiedpercentage,therewriteistriggered.Also #youneedtospecifyaminimalsizefortheAOFfiletoberewritten,this #isusefultoavoidrewritingtheAOFfileevenifthepercentageincrease #isreachedbutitisstillprettysmall. # #SpecifyapercentageofzeroinordertodisabletheautomaticAOF #rewritefeature. auto-aof-rewrite-percentage100 auto-aof-rewrite-min-size64mb #AnAOFfilemaybefoundtobetruncatedattheendduringtheRedis #startupprocess,whentheAOFdatagetsloadedbackintomemory. #ThismayhappenwhenthesystemwhereRedisisrunning #crashes,especiallywhenanext4filesystemismountedwithoutthe #data=orderedoption(howeverthiscan'thappenwhenRedisitself #crashesorabortsbuttheoperatingsystemstillworkscorrectly). # #Rediscaneitherexitwithanerrorwhenthishappens,orloadasmuch #dataaspossible(thedefaultnow)andstartiftheAOFfileisfound #tobetruncatedattheend.Thefollowingoptioncontrolsthisbehavior. # #Ifaof-load-truncatedissettoyes,atruncatedAOFfileisloadedand #theRedisserverstartsemittingalogtoinformtheuseroftheevent. #Otherwiseiftheoptionissettono,theserverabortswithanerror #andrefusestostart.Whentheoptionissettono,theuserrequires #tofixtheAOFfileusingthe"redis-check-aof"utilitybeforetorestart #theserver. # #NotethatiftheAOFfilewillbefoundtobecorruptedinthemiddle #theserverwillstillexitwithanerror.Thisoptiononlyapplieswhen #RediswilltrytoreadmoredatafromtheAOFfilebutnotenoughbytes #willbefound. aof-load-truncatedyes ################################LUASCRIPTING############################### #MaxexecutiontimeofaLuascriptinmilliseconds. # #IfthemaximumexecutiontimeisreachedRediswilllogthatascriptis #stillinexecutionafterthemaximumallowedtimeandwillstartto #replytoquerieswithanerror. # #Whenalongrunningscriptexceedsthemaximumexecutiontimeonlythe #SCRIPTKILLandSHUTDOWNNOSAVEcommandsareavailable.Thefirstcanbe #usedtostopascriptthatdidnotyetcalledwritecommands.Thesecond #istheonlywaytoshutdowntheserverinthecaseawritecommandwas #alreadyissuedbythescriptbuttheuserdoesn'twanttowaitforthenatural #terminationofthescript. # #Setitto0oranegativevalueforunlimitedexecutionwithoutwarnings. lua-time-limit5000 ################################REDISCLUSTER############################### # #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #WARNINGEXPERIMENTAL:RedisClusterisconsideredtobestablecode,however #inordertomarkitas"mature"weneedtowaitforanontrivialpercentage #ofuserstodeployitinproduction. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # #NormalRedisinstancescan'tbepartofaRedisCluster;onlynodesthatare #startedasclusternodescan.InordertostartaRedisinstanceasa #clusternodeenabletheclustersupportuncommentingthefollowing: # #cluster-enabledyes #Everyclusternodehasaclusterconfigurationfile.Thisfileisnot #intendedtobeeditedbyhand.ItiscreatedandupdatedbyRedisnodes. #EveryRedisClusternoderequiresadifferentclusterconfigurationfile. #Makesurethatinstancesrunninginthesamesystemdonothave #overlappingclusterconfigurationfilenames. # #cluster-config-filenodes-6379.conf #Clusternodetimeoutistheamountofmillisecondsanodemustbeunreachable #forittobeconsideredinfailurestate. #Mostotherinternaltimelimitsaremultipleofthenodetimeout. # #cluster-node-timeout15000 #Aslaveofafailingmasterwillavoidtostartafailoverifitsdata #lookstooold. # #Thereisnosimplewayforaslavetoactuallyhaveaexactmeasureof #its"dataage",sothefollowingtwochecksareperformed: # #1)Iftherearemultipleslavesabletofailover,theyexchangemessages #inordertotrytogiveanadvantagetotheslavewiththebest #replicationoffset(moredatafromthemasterprocessed). #Slaveswilltrytogettheirrankbyoffset,andapplytothestart #ofthefailoveradelayproportionaltotheirrank. # #2)Everysingleslavecomputesthetimeofthelastinteractionwith #itsmaster.Thiscanbethelastpingorcommandreceived(ifthemaster #isstillinthe"connected"state),orthetimethatelapsedsincethe #disconnectionwiththemaster(ifthereplicationlinkiscurrentlydown). #Ifthelastinteractionistooold,theslavewillnottrytofailover #atall. # #Thepoint"2"canbetunedbyuser.Specificallyaslavewillnotperform #thefailoverif,sincethelastinteractionwiththemaster,thetime #elapsedisgreaterthan: # #(node-timeout*slave-validity-factor)+repl-ping-slave-period # #Soforexampleifnode-timeoutis30seconds,andtheslave-validity-factor #is10,andassumingadefaultrepl-ping-slave-periodof10seconds,the #slavewillnottrytofailoverifitwasnotabletotalkwiththemaster #forlongerthan310seconds. # #Alargeslave-validity-factormayallowslaveswithtooolddatatofailover #amaster,whileatoosmallvaluemaypreventtheclusterfrombeingableto #electaslaveatall. # #Formaximumavailability,itispossibletosettheslave-validity-factor #toavalueof0,whichmeans,thatslaveswillalwaystrytofailoverthe #masterregardlessofthelasttimetheyinteractedwiththemaster. #(Howeverthey'llalwaystrytoapplyadelayproportionaltotheir #offsetrank). # #Zeroistheonlyvalueabletoguaranteethatwhenallthepartitionsheal #theclusterwillalwaysbeabletocontinue. # #cluster-slave-validity-factor10 #Clusterslavesareabletomigratetoorphanedmasters,thataremasters #thatareleftwithoutworkingslaves.Thisimprovestheclusterability #toresisttofailuresasotherwiseanorphanedmastercan'tbefailedover #incaseoffailureifithasnoworkingslaves. # #Slavesmigratetoorphanedmastersonlyiftherearestillatleasta #givennumberofotherworkingslavesfortheiroldmaster.Thisnumber #isthe"migrationbarrier".Amigrationbarrierof1meansthataslave #willmigrateonlyifthereisatleast1otherworkingslaveforitsmaster #andsoforth.Itusuallyreflectsthenumberofslavesyouwantforevery #masterinyourcluster. # #Defaultis1(slavesmigrateonlyiftheirmastersremainwithatleast #oneslave).Todisablemigrationjustsetittoaverylargevalue. #Avalueof0canbesetbutisusefulonlyfordebugginganddangerous #inproduction. # #cluster-migration-barrier1 #BydefaultRedisClusternodesstopacceptingqueriesiftheydetectthere #isatleastanhashslotuncovered(noavailablenodeisservingit). #Thiswayiftheclusterispartiallydown(forexamplearangeofhashslots #arenolongercovered)alltheclusterbecomes,eventually,unavailable. #Itautomaticallyreturnsavailableassoonasalltheslotsarecoveredagain. # #Howeversometimesyouwantthesubsetoftheclusterwhichisworking, #tocontinuetoacceptqueriesforthepartofthekeyspacethatisstill #covered.Inordertodoso,justsetthecluster-require-full-coverage #optiontono. # #cluster-require-full-coverageyes #Inordertosetupyourclustermakesuretoreadthedocumentation #availableathttp://redis.iowebsite. ##################################SLOWLOG################################### #TheRedisSlowLogisasystemtologqueriesthatexceededaspecified #executiontime.TheexecutiontimedoesnotincludetheI/Ooperations #liketalkingwiththeclient,sendingthereplyandsoforth, #butjustthetimeneededtoactuallyexecutethecommand(thisistheonly #stageofcommandexecutionwherethethreadisblockedandcannotserve #otherrequestsinthemeantime). # #Youcanconfiguretheslowlogwithtwoparameters:onetellsRedis #whatistheexecutiontime,inmicroseconds,toexceedinorderforthe #commandtogetlogged,andtheotherparameteristhelengthofthe #slowlog.Whenanewcommandisloggedtheoldestoneisremovedfromthe #queueofloggedcommands. #Thefollowingtimeisexpressedinmicroseconds,so1000000isequivalent #toonesecond.Notethatanegativenumberdisablestheslowlog,while #avalueofzeroforcestheloggingofeverycommand. slowlog-log-slower-than10000 #Thereisnolimittothislength.Justbeawarethatitwillconsumememory. #YoucanreclaimmemoryusedbytheslowlogwithSLOWLOGRESET. slowlog-max-len128 ################################LATENCYMONITOR############################## #TheRedislatencymonitoringsubsystemsamplesdifferentoperations #atruntimeinordertocollectdatarelatedtopossiblesourcesof #latencyofaRedisinstance. # #ViatheLATENCYcommandthisinformationisavailabletotheuserthatcan #printgraphsandobtainreports. # #Thesystemonlylogsoperationsthatwereperformedinatimeequalor #greaterthantheamountofmillisecondsspecifiedviathe #latency-monitor-thresholdconfigurationdirective.Whenitsvalueisset #tozero,thelatencymonitoristurnedoff. # #Bydefaultlatencymonitoringisdisabledsinceitismostlynotneeded #ifyoudon'thavelatencyissues,andcollectingdatahasaperformance #impact,thatwhileverysmall,canbemeasuredunderbigload.Latency #monitoringcaneasilybeenabledatruntimeusingthecommand #"CONFIGSETlatency-monitor-threshold "ifneeded. latency-monitor-threshold0 #############################EVENTNOTIFICATION############################## #RediscannotifyPub/Subclientsabouteventshappeninginthekeyspace. #Thisfeatureisdocumentedathttp://redis.io/topics/notifications # #Forinstanceifkeyspaceeventsnotificationisenabled,andaclient #performsaDELoperationonkey"foo"storedintheDatabase0,two #messageswillbepublishedviaPub/Sub: # #PUBLISH__keyspace@0__:foodel #PUBLISH__keyevent@0__:delfoo # #ItispossibletoselecttheeventsthatRediswillnotifyamongaset #ofclasses.Everyclassisidentifiedbyasinglecharacter: # #KKeyspaceevents,publishedwith__keyspace@ __prefix. #EKeyeventevents,publishedwith__keyevent@ __prefix. #gGenericcommands(non-typespecific)likeDEL,EXPIRE,RENAME,... #$Stringcommands #lListcommands #sSetcommands #hHashcommands #zSortedsetcommands #xExpiredevents(eventsgeneratedeverytimeakeyexpires) #eEvictedevents(eventsgeneratedwhenakeyisevictedformaxmemory) #AAliasforg$lshzxe,sothatthe"AKE"stringmeansalltheevents. # #The"notify-keyspace-events"takesasargumentastringthatiscomposed #ofzeroormultiplecharacters.Theemptystringmeansthatnotifications #aredisabled. # #Example:toenablelistandgenericevents,fromthepointofviewofthe #eventname,use: # #notify-keyspace-eventsElg # #Example2:togetthestreamoftheexpiredkeyssubscribingtochannel #name__keyevent@0__:expireduse: # #notify-keyspace-eventsEx # #Bydefaultallnotificationsaredisabledbecausemostusersdon'tneed #thisfeatureandthefeaturehassomeoverhead.Notethatifyoudon't #specifyatleastoneofKorE,noeventswillbedelivered. notify-keyspace-events"" ###############################ADVANCEDCONFIG############################### #Hashesareencodedusingamemoryefficientdatastructurewhentheyhavea #smallnumberofentries,andthebiggestentrydoesnotexceedagiven #threshold.Thesethresholdscanbeconfiguredusingthefollowingdirectives. hash-max-ziplist-entries512 hash-max-ziplist-value64 #Listsarealsoencodedinaspecialwaytosavealotofspace. #Thenumberofentriesallowedperinternallistnodecanbespecified #asafixedmaximumsizeoramaximumnumberofelements. #Forafixedmaximumsize,use-5through-1,meaning: #-5:maxsize:64Kb<--notrecommendedfornormalworkloads #-4:maxsize:32Kb<--notrecommended #-3:maxsize:16Kb<--probablynotrecommended #-2:maxsize:8Kb<--good #-1:maxsize:4Kb<--good #Positivenumbersmeanstoreupto_exactly_thatnumberofelements #perlistnode. #Thehighestperformingoptionisusually-2(8Kbsize)or-1(4Kbsize), #butifyourusecaseisunique,adjustthesettingsasnecessary. list-max-ziplist-size-2 #Listsmayalsobecompressed. #Compressdepthisthenumberofquicklistziplistnodesfrom*each*sideof #thelistto*exclude*fromcompression.Theheadandtailofthelist #arealwaysuncompressedforfastpush/popoperations.Settingsare: #0:disablealllistcompression #1:depth1means"don'tstartcompressinguntilafter1nodeintothelist, #goingfromeithertheheadortail" #So:[head]->node->node->...->node->[tail] #[head],[tail]willalwaysbeuncompressed;innernodeswillcompress. #2:[head]->[next]->node->node->...->node->[prev]->[tail] #2heremeans:don'tcompressheadorhead->nextortail->prevortail, #butcompressallnodesbetweenthem. #3:[head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] #etc. list-compress-depth0 #Setshaveaspecialencodinginjustonecase:whenasetiscomposed #ofjuststringsthathappentobeintegersinradix10intherange #of64bitsignedintegers. #Thefollowingconfigurationsettingsetsthelimitinthesizeofthe #setinordertousethisspecialmemorysavingencoding. set-max-intset-entries512 #Similarlytohashesandlists,sortedsetsarealsospeciallyencodedin #ordertosavealotofspace.Thisencodingisonlyusedwhenthelengthand #elementsofasortedsetarebelowthefollowinglimits: zset-max-ziplist-entries128 zset-max-ziplist-value64 #HyperLogLogsparserepresentationbyteslimit.Thelimitincludesthe #16bytesheader.WhenanHyperLogLogusingthesparserepresentationcrosses #thislimit,itisconvertedintothedenserepresentation. # #Avaluegreaterthan16000istotallyuseless,sinceatthatpointthe #denserepresentationismorememoryefficient. # #Thesuggestedvalueis~3000inordertohavethebenefitsof #thespaceefficientencodingwithoutslowingdowntoomuchPFADD, #whichisO(N)withthesparseencoding.Thevaluecanberaisedto #~10000whenCPUisnotaconcern,butspaceis,andthedatasetis #composedofmanyHyperLogLogswithcardinalityinthe0-15000range. hll-sparse-max-bytes3000 #Activerehashinguses1millisecondevery100millisecondsofCPUtimein #ordertohelprehashingthemainRedishashtable(theonemappingtop-level #keystovalues).ThehashtableimplementationRedisuses(seedict.c) #performsalazyrehashing:themoreoperationyourunintoahashtable #thatisrehashing,themorerehashing"steps"areperformed,soifthe #serverisidletherehashingisnevercompleteandsomemorememoryisused #bythehashtable. # #Thedefaultistousethismillisecond10timeseverysecondinorderto #activelyrehashthemaindictionaries,freeingmemorywhenpossible. # #Ifunsure: #use"activerehashingno"ifyouhavehardlatencyrequirementsanditis #notagoodthinginyourenvironmentthatRediscanreplyfromtimetotime #toquerieswith2millisecondsdelay. # #use"activerehashingyes"ifyoudon'thavesuchhardrequirementsbut #wanttofreememoryasapwhenpossible. activerehashingyes #Theclientoutputbufferlimitscanbeusedtoforcedisconnectionofclients #thatarenotreadingdatafromtheserverfastenoughforsomereason(a #commonreasonisthataPub/Subclientcan'tconsumemessagesasfastasthe #publishercanproducethem). # #Thelimitcanbesetdifferentlyforthethreedifferentclassesofclients: # #normal->normalclientsincludingMONITORclients #slave->slaveclients #pubsub->clientssubscribedtoatleastonepubsubchannelorpattern # #Thesyntaxofeveryclient-output-buffer-limitdirectiveisthefollowing: # #client-output-buffer-limit # #Aclientisimmediatelydisconnectedoncethehardlimitisreached,orif #thesoftlimitisreachedandremainsreachedforthespecifiednumberof #seconds(continuously). #Soforinstanceifthehardlimitis32megabytesandthesoftlimitis #16megabytes/10seconds,theclientwillgetdisconnectedimmediately #ifthesizeoftheoutputbuffersreach32megabytes,butwillalsoget #disconnectediftheclientreaches16megabytesandcontinuouslyovercomes #thelimitfor10seconds. # #Bydefaultnormalclientsarenotlimitedbecausetheydon'treceivedata #withoutasking(inapushway),butjustafterarequest,soonly #asynchronousclientsmaycreateascenariowheredataisrequestedfaster #thanitcanread. # #Insteadthereisadefaultlimitforpubsubandslaveclients,since #subscribersandslavesreceivedatainapushfashion. # #Boththehardorthesoftlimitcanbedisabledbysettingthemtozero. client-output-buffer-limitnormal000 client-output-buffer-limitslave256mb64mb60 client-output-buffer-limitpubsub32mb8mb60 #Rediscallsaninternalfunctiontoperformmanybackgroundtasks,like #closingconnectionsofclientsintimeout,purgingexpiredkeysthatare #neverrequested,andsoforth. # #Notalltasksareperformedwiththesamefrequency,butRedischecksfor #taskstoperformaccordingtothespecified"hz"value. # #Bydefault"hz"issetto10.RaisingthevaluewillusemoreCPUwhen #Redisisidle,butatthesametimewillmakeRedismoreresponsivewhen #therearemanykeysexpiringatthesametime,andtimeoutsmaybe #handledwithmoreprecision. # #Therangeisbetween1and500,howeveravalueover100isusuallynot #agoodidea.Mostusersshouldusethedefaultof10andraisethisupto #100onlyinenvironmentswhereverylowlatencyisrequired. hz10 #WhenachildrewritestheAOFfile,ifthefollowingoptionisenabled #thefilewillbefsync-edevery32MBofdatagenerated.Thisisuseful #inordertocommitthefiletothediskmoreincrementallyandavoid #biglatencyspikes. aof-rewrite-incremental-fsyncyes
c.builderdocker的容器
dockerbuild-tsimba/redis.
d.运行docker容器
dockerrun--namesimba-redis-d-p16379:6379--restart=alwayssimba/redis
e.配置只允许特定ip访问redis-server
在配置文件中查找
bind127.0.0.1
部分进行设置
以上这篇Docker启动Redis并设置密码的操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。