redis設置遠程連接


1、修改redis服務器的配置文件

  本機安裝的redis-4.0.14默認的配置文件 redis.conf 設置

  綁定本機地址:bind 127.0.0.1

  開啟保護模式:protected-mode yes

  此時連接,服務器是拒絕的

     

[root@fjgh redis]# ./redis-cli -h 192.168.100.109  -p  6379 
Could not connect to Redis at 192.168.100.109:6379: Connection refused
Could not connect to Redis at 192.168.100.109:6379: Connection refused
not connected> eixt

  

        配置文件比較大,我們通過ctrl + F  查找關鍵字修改為:

  bind 0.0.0.0 

  protected-mode no

2、重啟redis服務:先通過kill -9 殺死現有redis進程在啟動redis服務

 

[root@fjgh redis]# ps -ef|grep redis
root     10768     1  0 Jun19 ?        00:01:37 ./redis-server 127.0.0.1:6379
root     11339 11251  0 10:05 pts/1    00:00:00 grep --color=auto redis
[root@fjgh redis]# kill -9 10768
[root@fjgh redis]# ps -ef|grep redis
root     11343 11251  0 10:05 pts/1    00:00:00 grep --color=auto redis
[root@fjgh redis]# ./redis-server redis.conf
11344:C 20 Jun 10:05:46.798 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11344:C 20 Jun 10:05:46.798 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11344, just started
11344:C 20 Jun 10:05:46.798 # Configuration loaded

  

3、通過IP地址連接

[root@fjgh redis]# ./redis-cli -h 192.168.100.109  -p  6379 
192.168.100.109:6379> get setUpTime
"201906191227"
192.168.100.109:6379> 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM