1. 程式人生 > 其它 >redis_cluster-防火牆操作最佳實踐【轉】

redis_cluster-防火牆操作最佳實踐【轉】

單例項環境:

  • redis在做防火牆配置時,只需要開啟對應的防火牆埠即可。如配置檔案中port指定為6379,那就只要開一個6379.指定6380那就僅僅開個6380即可。

Redis_cluster環境:

  • 但在redis_cluster叢集中,redis的埠必須開二個,一個是配置檔案中port所指定的。另一個則必須在port指定埠中加10000整數後得出。如配置檔案中port指定了6379,則在叢集環境中必須開設出16379埠用於通訊

不開放高位埠會造成的影響:

  • 在用rdis-trib.rb create 做叢集初始配置時,當在確認完叢集分配後,等待redis cluster 加入時,一直在等
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster 
aiting for the cluster to join..............................................................

官方給的解釋如下:

Redis Cluster TCP ports

Every Redis Cluster node requires two TCP connections open. The normal Redis TCP port used to serve clients, for example 6379, plus the >port obtained by adding 10000 to the data port, so 16379 in the example.

This second high port is used for the Cluster bus, that is a node-to-node communication channel using a binary protocol. The Cluster bus >is used by nodes for failure detection, configuration update, failover authorization and so forth. Clients should never try to communicate >with the cluster bus port, but always with the normal Redis command port, however make sure you open both ports in your firewall, >otherwise Redis cluster nodes will be not able to communicate.

The command port and cluster bus port offset is fixed and is always 10000.

Note that for a Redis Cluster to work properly you need, for each node:

The normal client communication port (usually 6379) used to communicate with clients to be open to all the clients that need to reach the cluster, plus all the other cluster nodes (that use the client port for keys migrations).
The cluster bus port (the client port + 10000) must be reachable from all the other cluster nodes.

If you don't open both TCP ports, your cluster will not work as expected.

The cluster bus uses a different, binary protocol, for node to node data exchange, which is more suited to exchange information between >nodes using little bandwidth and processing time.



轉自
作者:uglybob
連結:https://www.jianshu.com/p/fd07229569a7
來源:簡書
著作權歸作者所有。商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。