以下是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。