wget https://download.oracle.com/java/17/archive/jdk-17.0.7_linux-x64_bin.rpm
rpm -ivh jdk-17.0.7_linux-x64_bin.rpm
for i in {67..71};do scp jdk-17.0.7_linux-x64_bin.rpm 192.168.124.$i: ;donefor i in {67..71};do ssh 192.168.124.$i rpm -ivh jdk-17.0.7_linux-x64_bin.rpm ;done
# 修改配置文件, 需要注意的内容如下journalDirectory=/data/bookkeeper/journal # 预写日志(wal)目录ledgerDirectories=/data/bookkeeper/ledgers # ledgers数据目录advertisedAddress=# 宣告自己的地址, 默认使用eth0的地址, 也可以手动写dns名称或者IPmetadataServiceUri=zk+hierarchical://zk1.pulsar.ops.cn:2181;zk2.pulsar.ops.cn:2181;zk3.pulsar.ops.cn:2181/ledgers # zk地址#zkServers=localhost:2181 # 被弃用的参数,这里注释它, 使用metadataServiceUri替代# 批量修改for i in {69,70,71}do ssh 192.168.124.$i"sed -i -e 's#^journalDirectory=data/bookkeeper/journal#journalDirectory=/data/bookkeeper/journal#' -e 's#^ledgerDirectories=data/bookkeeper/ledgers#ledgerDirectories=/data/bookkeeper/ledgers#' -e 's#^metadataServiceUri=#metadataServiceUri=zk+hierarchical://zk1.pulsar.ops.cn:2181;zk2.pulsar.ops.cn:2181;zk3.pulsar.ops.cn:2181/ledgers#' -e 's@^\(zkServers=.*\)@#\1@' /usr/local/pulsar/conf/bookkeeper.conf"done# 验证for i in {69,70,71}do ssh 192.168.124.$i"echo ======$i======= ; grep -E '^journalDirectory|^ledgerDirectories|^advertisedAddress|^metadataServiceUri|^#zkServers' /usr/local/pulsar/conf/bookkeeper.conf"done# 创建预写日志(wal)目录和ledgers目录for i in {69,70,71};do ssh 192.168.124.$i"mkdir -p /data/bookkeeper/{journal,ledgers}";done# 启动bookie节点for i in {69,70,71};do ssh 192.168.124.$i"/usr/local/pulsar/bin/pulsar-daemon start bookie";done# 检查集群健康状况/usr/local/pulsar/bin/bookkeeper shell bookiesanity
7. 部署Pulsar broker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 修改配置文件, 需要注意的内容如下metadataStoreUrl=zk:zk1.pulsar.ops.cn:2181,zk2.pulsar.ops.cn:2181,zk3.pulsar.ops.cn:2181
configurationMetadataStoreUrl=zk:zk1.pulsar.ops.cn:2181,zk2.pulsar.ops.cn:2181,zk3.pulsar.ops.cn:2181
clusterName=pulsar-cluster-1 # 和初始化集群元数据的时候指定的集群名称一致brokerServicePort=6650# 默认无需修改webServicePort=8080# 默认无需修改# 批量修改for i in {66,67,68}dozk_url="zk:zk1.pulsar.ops.cn:2181,zk2.pulsar.ops.cn:2181,zk3.pulsar.ops.cn:2181"cluster_name="pulsar-cluster-1"echo ssh 192.168.124.$i"sed -i -e 's#^metadataStoreUrl=.*#metadataStoreUrl=${zk_url}#' -e 's#^configurationMetadataStoreUrl=.*#configurationMetadataStoreUrl=${zk_url}#' -e 's#^clusterName=.*#clusterName=${cluster_name}#' /usr/local/pulsar/conf/broker.conf"done# 启动for i in {66,67,68};do ssh 192.168.124.$i"/usr/local/pulsar/bin/pulsar-daemon start broker";done
8. 测试
修改客户端配置
1
2
3
vim /usr/local/pulsar/conf/client.conf
webServiceUrl=http://broker1.pulsar.ops.cn:8080,broker2.pulsar.ops.cn:8080,broker2.pulsar.ops.cn:8080
brokerServiceUrl=pulsar://broker1.pulsar.ops.cn:6650,broker2.pulsar.ops.cn:6650,broker3.pulsar.ops.cn:6650