10019---访问远程Redis服务。Connect to Remote Redis Server
生活随笔
收集整理的這篇文章主要介紹了
10019---访问远程Redis服务。Connect to Remote Redis Server
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
原文
通常來(lái)說(shuō),生產(chǎn)環(huán)境下的Redis服務(wù)器只設(shè)置為僅本機(jī)訪(fǎng)問(wèn)(Redis默認(rèn)也只允許本機(jī)訪(fǎng)問(wèn))。有時(shí)候我們也許需要使Redi能被遠(yuǎn)程訪(fǎng)問(wèn)。此文介紹配置Redis允許遠(yuǎn)程訪(fǎng)問(wèn)。
配置
修改Redis配置文件/etc/redis/redis.conf,找到bind那行配置:
# bind 127.0.0.1去掉#注釋并改為:
bind 0.0.0.0指定配置文件然后重啟Redis服務(wù)即可:
$ sudo redis-server /etc/redis/redis.conf關(guān)于bind配置的含義,配置文件里的注釋是這樣說(shuō)的:
# By default Redis listens for connections from all the network interfaces # available on the server. It is possible to listen to just one or multiple # interfaces using the "bind" configuration directive, followed by one or # more IP addresses. # # Examples: # # bind 192.168.1.100 10.0.0.1 # bind 127.0.0.1
遠(yuǎn)程連接
配置好Redis服務(wù)并重啟服務(wù)后。就可以使用客戶(hù)端遠(yuǎn)程連接Redis服務(wù)了。命令格式如下:
$ redis-cli -h {redis_host} -p {redis_port}
其中{redis_host}就是遠(yuǎn)程的Redis服務(wù)所在服務(wù)器地址,{redis_port}就是Redis服務(wù)端口(Redis默認(rèn)端口是6379)。例如:
$ redis-cli -h 120.120.10.10 -p 6379 redis>ping PONG 如果需要密碼時(shí),則修改配置文件的 requirepass test001, 連接時(shí) redis-cli -h host -p port -a passwd
總結(jié)
以上是生活随笔為你收集整理的10019---访问远程Redis服务。Connect to Remote Redis Server的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: P1228 地毯填补问题(Java语言实
- 下一篇: 安装MySQL绿色版本,不用装软件、不用