Redis設定檔中關於bind參數

來源:互聯網
上載者:User

註:此文章內容有誤,正確請參考http://blog.csdn.net/hel12he/article/details/46911159


在設定檔redis.conf中,預設的bind 介面是127.0.0.1,也就是本地迴環地址。這樣的話,訪問redis服務只能通過原生用戶端串連,而無法通過遠端連線,
這樣可以避免將redis服務暴露於危險的網路環境中,防止一些不安全的人隨隨便便通過遠程
串連到redis服務。
如果bind選項為空白的話,那會接受所有來自於可用網路介面的串連。

例子:
比如有兩台redis伺服器,ip分別為:192.168.1.101和192.168.1.103,如何在101上通過redis-cli訪問103上的redis呢。在遠端連線103之前,先講下redis-cli的幾個關鍵參數:

用法:redis-cli [OPTIONS] [cmd [arg [arg ...]]]-h <主機ip>,預設是127.0.0.1
-p <連接埠>,預設是6379
-a <密碼>,如果redis加鎖,需要傳遞密碼

--help,顯示協助資訊


當在101上通過redis-cli訪問103上的redis時,首先要修改103上的redis.conf檔案,在bind下加一行:bind 192.168.1.101
這樣103上的redis服務就可以listen來自192.168.1.101的串連。

通過對rendis-cli用法介紹,在101上串連103應該很簡單: [plain]  view plain  cop [root@xsf001 ~]# redis-cli -h 192.168.1.103 -p 6379   redis 192.168.1.103:6379>   

官方文檔介紹:

Protected mode

Unfortunately many users fail to protect Redis instances from being accessed from external networks. Many instances are simply left exposed on the internet with public IPs. For this reasons since version 3.2.0, when Redis is executed with the default configuration (binding all the interfaces) and without any password in order to access it, it enters a special mode called proteced mode. In this mode Redis only replies to queries from the loopback interfaces, and reply to other clients connecting from other addresses with an error, explaining what is happening and how to configure Redis properly.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.