1、部署html
詳細部署步驟:http://www.javashuo.com/article/p-rccatnah-ca.html網絡
Redis5.0版本須要注意的參數配置:http://www.javashuo.com/article/p-xtzmupsm-bp.htmlide
2、遇到的問題阿里雲
一、bind公網IP地址時,會出現異常:【Cannot assign requested address】spa
首先理解bind的含義:http://www.javashuo.com/article/p-vtjgxqpc-cc.html.net
緣由:這裏沒法bind公網IP地址,是由於ECS的本地IP是經過NAT技術轉換成了公網IP,即公網IP不是ECS任意一個網卡上的IPcode
解決方案:bind 0.0.0.0,這樣不論阿里雲私網仍是公網都可以訪問server
二、SpringBoot配置Redis主備哨兵集羣后,沒法鏈接htm
緣由:ECS實例既綁定了私網IP地址,也綁定了公網IP地址,哨兵會將監控的Redis實例IP地址收集管理起來,設置bind 0.0.0.0後,使得哨兵會收集這兩個IP地址,而鏈接時使用的是私網IP地址,故沒法鏈接blog
解決方案:修改哨兵配置文件sentinel.conf,【sentinel announce-ip 哨兵所在的公網IP】
announce-ip配置項的官方解釋以下:
# sentinel announce-ip <ip> # sentinel announce-port <port> # # The above two configuration directives are useful in environments where, # because of NAT, Sentinel is reachable from outside via a non-local address. # # When announce-ip is provided, the Sentinel will claim the specified IP address # in HELLO messages used to gossip its presence, instead of auto-detecting the # local address as it usually does. # # Similarly when announce-port is provided and is valid and non-zero, Sentinel # will announce the specified TCP port. # # The two options don't need to be used together, if only announce-ip is # provided, the Sentinel will announce the specified IP and the server port # as specified by the "port" option. If only announce-port is provided, the # Sentinel will announce the auto-detected local IP and the specified port.
大體意思是:考慮到NAT網絡的存在,設置非本地IP後,哨兵能夠正常地被外部訪問
同時,哨兵啓動後,經過觀察配置文件sentinel.conf,發現已不會收集Redis實例的私網IP
最後SpringBoot能夠正常鏈接Redis主備哨兵集羣
注:以上場景爲一主三備兩哨兵,一主一備一哨兵在同一個ECS實例上,兩備一哨兵在另外一個ECS實例上,這兩個ECS實例在同一個區域,屬於同一個私有網段,且均綁定了公網IP