以下是Debian與Zookeeper網絡配置指南:
使用/etc/network/interfaces
文件(適用于較舊版本Debian),編輯配置靜態IP或DHCP,如auto eth0
,iface eth0 inet static
,設置address
、netmask
、gateway
等參數,然后重啟網絡服務sudo systemctl restart networking
。也可使用netplan
(適用于Debian 10及更高版本),編輯/etc/netplan/01 - netcfg.yaml
文件進行配置,應用配置用sudo netplan apply
。
安裝Zookeeper后,編輯/etc/zookeeper/conf/zoo.cfg
文件,設置dataDir
為數據目錄,clientPort
為客戶端端口,默認2181。在集群模式下,通過server.X
條目配置節點ID和網絡地址,如server.1=192.168.1.1:2888:3888
,并為每個節點在dataDir
目錄下創建myid
文件,寫入對應服務器ID。
使用ufw
開放Zookeeper端口,默認2181用于客戶端連接,2888和3888用于節點間通信,命令為sudo ufw allow 2181
、sudo ufw allow 2888
、sudo ufw allow 3888
。