pulsar集群部署

pulsar集群需要zookeeper集群,本教程利用外部zookeeper集群,先确定zookeeper集群启动完成
准备三台服务器

  • 192.168.127.130
  • 192.168.127.131
  • 192.168.127.132
    在/etc/hosts文件中配置域名
192.168.127.130 node01.cuiot.cn
192.168.127.131 node02.cuiot.cn
192.168.127.132 node03.cuiot.cn

在目录/mnt/server下载apache-pulsar-2.10.2-bin.tar.gz

wget https://archive.apache.org/dist/pulsar/pulsar-2.10.2/apache-pulsar-2.10.2-bin.tar.gz

待下载结束,解压,并重命名

tar -zxvf apache-pulsar-2.10.2-bin.tar.gz
mv apache-pulsar-2.10.2-bin pulsar

进入目录/mnt/server/pulsar创建文件夹

cd /mnt/server/pulsar
mkdir -p bookkeeper/journal
mkdir -p bookkeeper/ledgers

修改配置文件bookkeeper.conf

vim /mnt/server/pulsar/conf/bookkeeper.conf
advertisedAddress=node01.cuiot.cn
journalDirectory=/mnt/server/pulsar/bookkeeper/journal
ledgerDirectories=/mnt/server/pulsar/bookkeeper/ledgers
zkServers=node01.cuiot.cn:2181,node02.cuiot.cn:2181,node03.cuiot.cn:2181

修改配置文件

vim /mnt/server/pulsar/conf/broker.conf
#修改集群名称
clusterName=pulsar-cluster
zookeeperServers=node01.cuiot.cn:2181,node02.cuiot.cn:2181,node03.cuiot.cn:2181
configurationStoreServers=node01.cuiot.cn:2181,node02.cuiot.cn:2181,node03.cuiot.cn:2181
advertisedAddress=node01.cuiot.cn

通过scp命令,将pulsar目录拷贝到192.168.127.131和192.168.127.132服务器上

scp -r pulsar [email protected]:$PWD
scp -r pulsar [email protected]:$PWD

更改192.168.127.131和192.168.127.132服务上的配置文件broker.conf和bookkeeper.conf
192.168.127.131:

#bookkeeper.conf
advertisedAddress=node02.cuiot.cn
#broker.conf
advertisedAddress=node02.cuiot.cn

192.168.127.132:

#bookkeeper.conf
advertisedAddress=node03.cuiot.cn
#broker.conf
advertisedAddress=node03.cuiot.cn

在192.168.127.130服务器进行pulsar初始化工作
首先初始化Pulsar集群元数据

#首先初始化Pulsar集群元数据
cd /mnt/server/pulsar/bin
./pulsar initialize-cluster-metadata\
--cluster pulsar-cluster\
--zookeeper node01.cuiot.cn:2181,node02.cuiot.cn:2181,node03.cuiot.cn:2181\
--configuration-store node01.cuiot.cn:2181,node02.cuiot.cn:2181,node03.cuiot.cn:2181\
--web-service-url http://node01.cuiot.cn:8080,node02.cuiot.cn:8080,node03.cuiot.cn:8080\
--web-service-url-tls https://node01.cuiot.cn:8443,node02.cuiot.cn:8443,node03.cuiot.cn:8443\
--broker-service-url pulsar://node01.cuiot.cn:6650,node02.cuiot.cn:6650,node03.cuiot.cn:6650\
--broker-service-url-tls pulsar+ssl://node01.cuiot.cn::6651,node02.cuiot.cn:6651,node03.cuiot.cn:6651

初始化bookkeeper集群

./bookkeeper shell metaformat

启动bookkeeper服务

cd /mnt/server/pulsar/bin
./pulsar-daemon start bookie 
#注意: 三个节点都需要依次启动

验证是否启动: 可三台都检测

./bookkeeper shell bookiesanity
#提示: Bookie sanity test succeeded 认为启动成功

启动broker

cd /mnt/server/pulsar/bin 
./pulsar-daemon start broker 
注意: 三个节点都需要依次启动 检测是否启动: 
./pulsar-admin brokers list pulsar-cluster
"node01.cuiot.cn:8080"
"node02.cuiot.cn:8080"
"node03.cuiot.cn:8080"

你可能感兴趣的:(pulsar,java,开发语言)