Redis3.2开启远程访问详细步骤
redis默认只允许本地访问,要使redis可以远程访问可以修改redis.conf
打开redis.conf文件在NETWORK部分有说明
##################################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
使redis可以远程访问只要注释掉redis.conf配置文件中的bind127.0.0.1即可以使所有的ip访问redis
若是想指定多个ip访问,但并不是全部的ip访问,可以bind多个IP
注意
在redis3.2之后,redis增加了protected-mode,在这个模式下,即使注释掉了bind127.0.0.1,再访问redisd时候还是报错,如下
(error)DENIEDRedisisrunninginprotectedmodebecauseprotectedmodeisenabled,nobindaddresswasspecified,noauthenticationpasswordisrequestedtoclients.Inthismodeconnectionsareonlyacceptedfromtheloopbackinterface.IfyouwanttoconnectfromexternalcomputerstoRedisyoumayadoptoneofthefollowingsolutions:1)Justdisableprotectedmodesendingthecommand'CONFIGSETprotected-modeno'fromtheloopbackinterfacebyconnectingtoRedisfromthesamehosttheserverisrunning,howeverMAKESURERedisisnotpubliclyaccessiblefrominternetifyoudoso.UseCONFIGREWRITEtomakethischangepermanent.2)AlternativelyyoucanjustdisabletheprotectedmodebyeditingtheRedisconfigurationfile,andsettingtheprotectedmodeoptionto'no',andthenrestartingtheserver.3)Ifyoustartedtheservermanuallyjustfortesting,restartitwiththe'--protected-modeno'option.4)Setupabindaddressoranauthenticationpassword.NOTE:Youonlyneedtodooneoftheabovethingsinorderfortheservertostartacceptingconnectionsfromtheoutside.
解决方法是修改原protected-modeyes为protected-modeno
保存配置文件重启redis即可
热门推荐
7 简短的二胎祝福语
10 简短霸气女儿生日 祝福语
11 祝福语高考小众诗句简短
12 元旦祝福语20秒简短
13 老师过年祝福语大全 简短
14 一生祝福语简短
15 产检祝福语简短霸气
16 朋友店开张祝福语简短
17 生日爱情祝福语大全简短
18 朋友女儿生日祝福语 简短