windows本地連不上虛擬機redis服務完美解決


 

  1. 檢查本機與虛擬機是否可以互相ping通,如本機IP:192.168.22.111  虛擬機IP:192.168.44.129 (設置虛擬機靜態IP已設置)
    • 本機 win+R 輸入cmd 進入dos 輸入 ping 192.168.44.129 ,查看數據輸送情況
    • 虛擬機: ping 192.168.22.111 查看數據輸送情況
  2. 查看6379(或者自定義redis端口)時候打開
    • firewall-cmd --query-port=6379/tcp 如果返回no則端口沒有開啟
    • firewall-cmd --add-port=6379/tcp  (加 --permanent 永久有效),返回success說明開啟成功
  3. 第2步無誤之后,檢查虛擬機防火牆設置
    • 關閉防火牆兩種方式
      • iptables 形式防火牆關閉
        • service iptables stop
        • chkconfig iptables off 永久關閉
      • firewalld 形式防火牆關閉
        • systemctl stop firewalld && systemctl disable firewalld 
        • chkconfig firewalld off 永久關閉
    • 檢查防火牆狀態(是否dead狀態)
      • systemctl status iptables
      • systemctl status firewalld

      •   
  4. 第3步無法解決問題的話,就出絕招了——修改redis.conf文件
    • ps addr 查了虛擬機分配的IP
    • 修改redis.conf中bind,指定虛擬機IP,如筆者這樣修改
      • # bind 127.0.0.1
      • bind 192.168.44.129
      • protected-mode yes 改為 protected-mode no
      • daemonized no 改為 daemonized yes 以后台靜默進程啟動(可選)
    • 重啟reidis 服務
      • systemctl restart redis
    • 啟動redis服務正確姿勢
      • 后台啟動方式 redis-server /xx/yy/redis.conf (redis.conf實際地址)
      • 顯式啟動方式
        • cd 到redis 安裝目錄 
        • redis-server &

  

  5. 在本機端用Redis Desktop Manager 測試,出現如下驚喜界面,大功告成!

  

 


免責聲明!

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



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