搭建 Pulsar 集群需要 3 个组件:ZooKeeper 集群、BookKeeper 集群和 broker 集群
以下部署策略:
192.168.1.46 (部署BookKeeper,部署broker)
192.168.1.47 (部署BookKeeper,部署broker)
192.168.1.48 (部署单个ZK,部署BookKeeper,部署broker)
前期准备
1)jdk1.8
2)在各机器根下创建 data目录,下载apache-pulsar-2.4.2-bin.tar.gz拷到data目录下
chmod 777 apache-pulsar-2.4.2-bin.tar.gz
tar xvfz apache-pulsar-2.4.2-bin.tar.gz
一 ZooKeeper 集群
为了简单一台机器上部署单个ZK使用.
1) 在data目录下创建 zookeeper和zookeeper/logs目录
2) 修改 zookeeper.conf 文件
dataDir=/data/zookeeper
dataLogDir=/data/zookeeper/logs
server.3=192.168.1.48:2888:3888
3) 执行命令 echo 3 > /data/zookeeper/zookeeper/myid
4) 启动zk
/data/apache-pulsar-2.4.2$ PULSAR_EXTRA_OPTS="-Dstats_server_port=8001" bin/pulsar-daemon start zookeeper
(注意:因为ZK和broker部署在同一机器启动时要加上PULSAR_EXTRA_OPTS="-Dstats_server_port=8001" 改变端口,否则到后边在冲突)
5) 初始化集群元数据
bin/pulsar initialize-cluster-metadata \
--cluster pulsar-cluster-zk \
--zookeeper 192.168.1.48:2181 \
--configuration-store 192.168.1.48:2181 \
--web-service-url http://192.168.1.48:8080 \
--web-service-url-tls https://192.168.1.48:8443 \
--broker-service-url pulsar://192.168.1.48:6650 \
--broker-service-url-tls pulsar+ssl://192.168.1.48:6651
二 BookKeeper 集群
1)创建 /data/bookkeeper/目录
2)bookkeeper.conf 文件
advertisedAddress=HOSTNAMEIP (根据机器IP填写)
zkServers=192.168.1.48:2181
journalDirectory=/data/bookkeeper/journal
ledgerDirectories=/data/bookkeeper/ledgers
3 执行初始化元数据命令;若出现提示,输入 Y,继续(只需在一个bookie节点执行一次)
/data/apache-pulsar-2.4.2$ bin/bookkeeper shell metaformat
4)启动 data/apache-pulsar-2.4.2$ bin/pulsar-daemon start bookie
5)另两台机器根据以上操作分别启动
三部署 broker集群
1 修改配置文件broker.conf
zookeeperServers=192.168.1.48:2181
configurationStoreServers=192.168.1.48:2181
advertisedAddress=HOSTNAME (根据机器IP填写)
clusterName=pulsar-cluster-zk
2 启动data/apache-pulsar-2.4.2$ bin/pulsar-daemon start broker
3 另两台机器根据以上操作分别启动
新闻标题:3台linux搭建Pulsar集群环境用于测试
当前地址:
http://jkwzsj.com/article/peedii.html