searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

Apache Pulsar 离线部署(一):直接部署

2023-08-04 09:00:24
22
0

部署规划:

集群共六台主机,其中三台部署zookeeper集群;其余三台每一台均部署Broker与Bookkeeper

Zookeeper数据路径:

/home/kafka/data/zookeeper/data

Zookeeper日志路径:

/home/kafka/data/zookeeper/log

 

Bookkeeper journal路径分别位于6块物理磁盘:

/data01/bookkeeper/journal,

/data02/bookkeeper/journal,

/data03/bookkeeper/journal,

/data04/bookkeeper/journal,

/data05/bookkeeper/journal,

/data06/bookkeeper/journal

 

Bookkeeper ledger路径分别位于3块物理磁盘:

/data07/bookkeeper/ledgers,

/data08/bookkeeper/ledgers,

/data09/bookkeeper/ledgers

 

环境准备:

确认Java版本:

Java 1.8

将安装包上传并解压:

 

Zookeeper配置与启动:

在每个节点上新建目录:

/home/kafka/data/zookeeper/data

/home/kafka/data/zookeeper/log

 

编辑zookeeper配置文件:

三个节点上,Apache Pulsar目录下,分别执行:

vim ./conf/zookeeper.conf

编辑zookeeper配置文件:

dataDir=/home/kafka/data/zookeeper/data

dataLogDir=/home/kafka/data/zookeeper/log

server.1=<zookeeper节点1地址>:2888:3888

server.2=<zookeeper节点2地址>:2888:3888

server.3=<zookeeper节点3地址>:2888:3888

 

为每个zookeeper节点新建myid:

在节点1上执行:

echo 1 > /home/kafka/data/zookeeper/data/myid

在节点2上执行:

echo 2 > /home/kafka/data/zookeeper/data/myid

在节点3上执行:

echo 3 > /home/kafka/data/zookeeper/data/myid

 

启动zookeeper:

Apache Pulsar目录下,使用命令:

bin/pulsar-daemon start zookeeper

关闭zookeeper可以使用

bin/pulsar-daemon stop zookeeper

 

尝试客户端链接:

Apache Pulsar目录下,输入命令:

bin/pulsar zookeeper-shell

如果客户端能够正常链接,说明zookeeper启动正常:

 

初始化集群元数据:

三个zookeeper确认启动后,在其中任意节点运行以初始化集群元数据

bin/pulsar initialize-cluster-metadata \

--cluster pulsar-cluster-zk \

--zookeeper <zookeeper节点1地址>:2181 \

--configuration-store <zookeeper节点1地址>:2181 \

--web-service-url http://<broker,bookeeper节点1地址>:8080,<broker,bookeeper节点2地址>:8080,<broker,bookeeper节点3地址>:8080 \

--web-service-url-tls https://<broker,bookeeper节点1地址>:8443,<broker,bookeeper节点2地址>:8443,<broker,bookeeper节点3地址>:8443 \

--broker-service-url pulsar://<broker,bookeeper节点1地址>:6650,<broker,bookeeper节点2地址>:6650,<broker,bookeeper节点3地址>:6650 \

--broker-service-url-tls pulsar+ssl://<broker,bookeeper节点1地址>:6651,<broker,bookeeper节点2地址>:6651,<broker,bookeeper节点3地址>:6651

Apache Pulsar目录下,输入命令:

bin/pulsar zookeeper-shell

进入zookeeper控制台,使用:

ls /

查看所有节点:

 

 

Bookkeeper配置与启动:

每个节点新建目录:

/data01/bookkeeper/journal,

/data02/bookkeeper/journal,

/data03/bookkeeper/journal,

/data04/bookkeeper/journal,

/data05/bookkeeper/journal,

/data06/bookkeeper/journal

 

/data07/bookkeeper/ledgers,

/data08/bookkeeper/ledgers,

/data09/bookkeeper/ledgers

 

编辑配置文件:

Apache Pulsar目录下,通过命令:

vim conf/bookkeeper.conf

编辑bookkeeper配置项:

ledgerDirectories=/data07/bookkeeper/ledgers,/data08/bookkeeper/ledgers,/data09/bookkeeper/ledgers

zkServers=<zookeeper节点1地址>:2181,<zookeeper节点2地址>:2181,<zookeeper节点3地址>:2181

journalDirectories=/data01/bookkeeper/journal,/data02/bookkeeper/journal,/data03/bookkeeper/journal,/data04/bookkeeper/journal,/data05/bookkeeper/journal,/data06/bookkeeper/journal

advertisedAddress=<该节点地址>

 

执行初始化元数据命令:

bin/bookkeeper shell metaformat

出现提示按Y继续即可

 

启动bookkeeper:

在规划的每一个节点的Apache Pulsar目录下,输入命令:

bin/pulsar-daemon start bookie

启动进程

 

关闭bookkeeper可用:

bin/pulsar-daemon stop bookie

如果启动失败可能是因为端口冲突,需要在bookkeeper配置中修改,将

prometheusStatsHttpPort=8000

改为

prometheusStatsHttpPort=8100

 

输入命令:

bin/bookkeeper shell bookiesanity

检查bookkeeper启动情况

出现Bookie sanity test succeeded说明启动成功

 

 

Broker配置与启动:

编辑配置文件:

Apache Pulsar目录下,输入命令:

vim conf/broker.conf

增加/修改以下配置项:

zookeeperServers=<zookeeper节点1地址>:2181,<zookeeper节点2地址>:2181,<zookeeper节点3地址>:2181
configurationStoreServers=<zookeeper节点1地址>:2181,<zookeeper节点2地址>:2181,<zookeeper节点3地址>:2181
advertisedAddress=<该节点地址>
#clusterName与前面zookeeper初始化的cluster一致
clusterName=pulsar-cluster-zk

 

启动进程:

在规划的节点Apache Pulsar目录下,分别使用命令:

bin/pulsar-daemon start broker

启动broker进程

 

使用

bin/pulsar-daemon stop broker

命令关闭broker进程

 

查看节点情况:

在任意节点Apache Pulsar目录下,使用命令:

bin/pulsar-admin brokers list pulsar-cluster

检查broker节点部署情况

看到这种结果说明集群中启动的broker全部存活,端口为8080

 

 

测试集群功能:

配置客户端:

Apache Pulsar目录下,使用命令:

vim conf/client.conf

修改配置:

webServiceUrl=http://<broker,bookeeper节点1地址>:8080,<broker,bookeeper节点2地址>:8080,<broker,bookeeper节点3地址>:8080

brokerServiceUrl=pulsar:<broker,bookeeper节点1地址>:6650,<broker,bookeeper节点2地址>:6650,<broker,bookeeper节点3地址>:6650

 

消息收发测试:

然后在Apache Pulsar目录下,使用命令:

bin/pulsar-client produce persistent://public/default/test -n 1 -m "Hello Pulsar"

向persistent://public/default/test发送了1条消息,内容为“Hello Pulsar”

并获得以下结果:

 

再使用命令:

bin/pulsar-client consume persistent://public/default/test -n 10 -s "consumer-test" -t "Exclusive"

消费之前生成的消息,结果如下:

则说明集群建立成功。

 

0条评论
0 / 1000
逍遥排骨
3文章数
0粉丝数
逍遥排骨
3 文章 | 0 粉丝
逍遥排骨
3文章数
0粉丝数
逍遥排骨
3 文章 | 0 粉丝
原创

Apache Pulsar 离线部署(一):直接部署

2023-08-04 09:00:24
22
0

部署规划:

集群共六台主机,其中三台部署zookeeper集群;其余三台每一台均部署Broker与Bookkeeper

Zookeeper数据路径:

/home/kafka/data/zookeeper/data

Zookeeper日志路径:

/home/kafka/data/zookeeper/log

 

Bookkeeper journal路径分别位于6块物理磁盘:

/data01/bookkeeper/journal,

/data02/bookkeeper/journal,

/data03/bookkeeper/journal,

/data04/bookkeeper/journal,

/data05/bookkeeper/journal,

/data06/bookkeeper/journal

 

Bookkeeper ledger路径分别位于3块物理磁盘:

/data07/bookkeeper/ledgers,

/data08/bookkeeper/ledgers,

/data09/bookkeeper/ledgers

 

环境准备:

确认Java版本:

Java 1.8

将安装包上传并解压:

 

Zookeeper配置与启动:

在每个节点上新建目录:

/home/kafka/data/zookeeper/data

/home/kafka/data/zookeeper/log

 

编辑zookeeper配置文件:

三个节点上,Apache Pulsar目录下,分别执行:

vim ./conf/zookeeper.conf

编辑zookeeper配置文件:

dataDir=/home/kafka/data/zookeeper/data

dataLogDir=/home/kafka/data/zookeeper/log

server.1=<zookeeper节点1地址>:2888:3888

server.2=<zookeeper节点2地址>:2888:3888

server.3=<zookeeper节点3地址>:2888:3888

 

为每个zookeeper节点新建myid:

在节点1上执行:

echo 1 > /home/kafka/data/zookeeper/data/myid

在节点2上执行:

echo 2 > /home/kafka/data/zookeeper/data/myid

在节点3上执行:

echo 3 > /home/kafka/data/zookeeper/data/myid

 

启动zookeeper:

Apache Pulsar目录下,使用命令:

bin/pulsar-daemon start zookeeper

关闭zookeeper可以使用

bin/pulsar-daemon stop zookeeper

 

尝试客户端链接:

Apache Pulsar目录下,输入命令:

bin/pulsar zookeeper-shell

如果客户端能够正常链接,说明zookeeper启动正常:

 

初始化集群元数据:

三个zookeeper确认启动后,在其中任意节点运行以初始化集群元数据

bin/pulsar initialize-cluster-metadata \

--cluster pulsar-cluster-zk \

--zookeeper <zookeeper节点1地址>:2181 \

--configuration-store <zookeeper节点1地址>:2181 \

--web-service-url http://<broker,bookeeper节点1地址>:8080,<broker,bookeeper节点2地址>:8080,<broker,bookeeper节点3地址>:8080 \

--web-service-url-tls https://<broker,bookeeper节点1地址>:8443,<broker,bookeeper节点2地址>:8443,<broker,bookeeper节点3地址>:8443 \

--broker-service-url pulsar://<broker,bookeeper节点1地址>:6650,<broker,bookeeper节点2地址>:6650,<broker,bookeeper节点3地址>:6650 \

--broker-service-url-tls pulsar+ssl://<broker,bookeeper节点1地址>:6651,<broker,bookeeper节点2地址>:6651,<broker,bookeeper节点3地址>:6651

Apache Pulsar目录下,输入命令:

bin/pulsar zookeeper-shell

进入zookeeper控制台,使用:

ls /

查看所有节点:

 

 

Bookkeeper配置与启动:

每个节点新建目录:

/data01/bookkeeper/journal,

/data02/bookkeeper/journal,

/data03/bookkeeper/journal,

/data04/bookkeeper/journal,

/data05/bookkeeper/journal,

/data06/bookkeeper/journal

 

/data07/bookkeeper/ledgers,

/data08/bookkeeper/ledgers,

/data09/bookkeeper/ledgers

 

编辑配置文件:

Apache Pulsar目录下,通过命令:

vim conf/bookkeeper.conf

编辑bookkeeper配置项:

ledgerDirectories=/data07/bookkeeper/ledgers,/data08/bookkeeper/ledgers,/data09/bookkeeper/ledgers

zkServers=<zookeeper节点1地址>:2181,<zookeeper节点2地址>:2181,<zookeeper节点3地址>:2181

journalDirectories=/data01/bookkeeper/journal,/data02/bookkeeper/journal,/data03/bookkeeper/journal,/data04/bookkeeper/journal,/data05/bookkeeper/journal,/data06/bookkeeper/journal

advertisedAddress=<该节点地址>

 

执行初始化元数据命令:

bin/bookkeeper shell metaformat

出现提示按Y继续即可

 

启动bookkeeper:

在规划的每一个节点的Apache Pulsar目录下,输入命令:

bin/pulsar-daemon start bookie

启动进程

 

关闭bookkeeper可用:

bin/pulsar-daemon stop bookie

如果启动失败可能是因为端口冲突,需要在bookkeeper配置中修改,将

prometheusStatsHttpPort=8000

改为

prometheusStatsHttpPort=8100

 

输入命令:

bin/bookkeeper shell bookiesanity

检查bookkeeper启动情况

出现Bookie sanity test succeeded说明启动成功

 

 

Broker配置与启动:

编辑配置文件:

Apache Pulsar目录下,输入命令:

vim conf/broker.conf

增加/修改以下配置项:

zookeeperServers=<zookeeper节点1地址>:2181,<zookeeper节点2地址>:2181,<zookeeper节点3地址>:2181
configurationStoreServers=<zookeeper节点1地址>:2181,<zookeeper节点2地址>:2181,<zookeeper节点3地址>:2181
advertisedAddress=<该节点地址>
#clusterName与前面zookeeper初始化的cluster一致
clusterName=pulsar-cluster-zk

 

启动进程:

在规划的节点Apache Pulsar目录下,分别使用命令:

bin/pulsar-daemon start broker

启动broker进程

 

使用

bin/pulsar-daemon stop broker

命令关闭broker进程

 

查看节点情况:

在任意节点Apache Pulsar目录下,使用命令:

bin/pulsar-admin brokers list pulsar-cluster

检查broker节点部署情况

看到这种结果说明集群中启动的broker全部存活,端口为8080

 

 

测试集群功能:

配置客户端:

Apache Pulsar目录下,使用命令:

vim conf/client.conf

修改配置:

webServiceUrl=http://<broker,bookeeper节点1地址>:8080,<broker,bookeeper节点2地址>:8080,<broker,bookeeper节点3地址>:8080

brokerServiceUrl=pulsar:<broker,bookeeper节点1地址>:6650,<broker,bookeeper节点2地址>:6650,<broker,bookeeper节点3地址>:6650

 

消息收发测试:

然后在Apache Pulsar目录下,使用命令:

bin/pulsar-client produce persistent://public/default/test -n 1 -m "Hello Pulsar"

向persistent://public/default/test发送了1条消息,内容为“Hello Pulsar”

并获得以下结果:

 

再使用命令:

bin/pulsar-client consume persistent://public/default/test -n 10 -s "consumer-test" -t "Exclusive"

消费之前生成的消息,结果如下:

则说明集群建立成功。

 

文章来自个人专栏
Apache Pulsar
3 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0