以下是Ubuntu Kafka網絡設置指南:
/etc/netplan/
目錄下配置文件(如01-netcfg.yaml
)設置靜態IP或動態IP,使用sudo netplan apply
應用配置。/etc/netplan/
配置文件中添加nameservers
字段設置DNS服務器,或修改/etc/resolv.conf
文件。/usr/local/kafka/config/server.properties
,設置listeners
(監聽地址,如PLAINTEXT://:9092
)、advertised.listeners
(客戶端連接地址,如PLAINTEXT://your.kafka.server.ip:9092
)、zookeeper.connect
(Zookeeper連接地址)等參數。server.properties
中broker.id
需唯一,listeners
和advertised.listeners
根據節點IP配置不同。使用ufw
或iptables
開放Kafka端口(默認9092)和Zookeeper端口(默認2181),允許客戶端訪問。
創建Topic并使用生產者和消費者測試,確保能正常通信。