Pulsar安装

2021-05-13  本文已影响0人  淡淡的小番茄

Pulsar如下几点深深的吸引了我:

1、多租户

2、支持百万topic

3、服务与计算分离

尤其是支持百万topic,这是kafka实现不了的。于是,撸起来,搭建个Pulsar来学一学。

Pulsar存储使用的是BookKeeper,所以我们先来安装BookKeeper(Zookeeper安装省略)。

#1、BookKeeper集群安装

防火墙配置

查看防火墙状态: systemctl status firewalld.service 绿的running表示防火墙开启

执行关闭命令: systemctl stop firewalld.service

再次执行查看防火墙命令:systemctl status firewalld.service

执行开机禁用防火墙自启命令 : systemctl disable firewalld.service

##1.1 环境准备

192.168.22.151 node1

192.168.22.152 node2

192.168.22.153 node3

##1.2 下载文件

https://bookkeeper.apache.org/releases/

##1.3 修改bookkeeper-server/conf/bk_server.conf

zkServers=node1:2181,node2:2181,node3:2181

#############################################################################

## Journal settings

#############################################################################

# Directories BookKeeper outputs its write ahead log.

# Could define multi directories to store write head logs, separated by ','.

# For example:

#  journalDirectories=/tmp/bk-journal1,/tmp/bk-journal2

# If journalDirectories is set, bookies will skip journalDirectory and use

# this setting directory.

journalDirectories=/data/bk-txn

# Directory Bookkeeper outputs ledger snapshots

# could define multi directories to store snapshots, separated by ','

# For example:

# ledgerDirectories=/tmp/bk1-data,/tmp/bk2-data

#

# Ideally ledger dirs and journal dir are each in a differet device,

# which reduce the contention between random i/o and sequential write.

# It is possible to run with a single disk, but performance will be significantly lower.

ledgerDirectories=/data/bk-data

##1.4 格式化[任意一台机器上执行]

./bin/bookkeeper shell metaformat

只需要执行一次。

cat /data/bk-data/current/VERSION

zk里面会生产实例信息:

##1.5 启动

./bin/bookkeeper-daemon.sh start bookie

会在data目录下生成如下信息:

连接到zk,每个节点启动后,会在zk中注册相关信息:

##1.6 查看是否启动成功

./bin/bookkeeper shell bookiesanity

#2、Pulsar集群安装

##2.1 修改配置

### Zookeeper quorum connection string

zookeeperServers=192.168.22.151:2181,192.168.22.152:2181,192.168.22.153:2181

### Configuration Store connection string

configurationStoreServers=192.168.22.151:2181,192.168.22.152:2181,192.168.22.153:2181

### Name of the cluster to which this broker belongs to

clusterName=iot-ipulsar-cluster

### Broker data port for TLS - By default TLS is disabled

brokerServicePortTls=6651

### Port to use to server HTTPS request - By default TLS is disabled

webServicePortTls=8443

### Enable the deletion of inactive topics

brokerDeleteInactiveTopicsEnabled=false

##2.2 启动Pulsar

./bin/pulsar-daemon start broker

##2.3 初始化元数据信息

./bin/pulsar initialize-cluster-metadata \

  --cluster iot-ipulsar-cluster \

  --zookeeper 192.168.22.151:2181,192.168.22.152:2181,192.168.22.153:2181 \

  --configuration-store 192.168.22.151:2181,192.168.22.152:2181,192.168.22.153:2181 \

  --web-service-url http://192.168.22.151:18080,192.168.22.152:18080,192.168.22.153:18080 \

  --web-service-url-tls https://192.168.22.151:8443,192.168.22.152:8443,192.168.22.153:8443 \

  --broker-service-url pulsar://192.168.22.151:6650,192.168.22.152:6650,192.168.22.153:6650 \

  --broker-service-url-tls pulsar+ssl://192.168.22.151:6651,192.168.22.152:6651,192.168.22.153:6651   

##2.4 修改client.conf配置文件【地址需与服务端地址一致】

# Configuration for pulsar-client and pulsar-admin CLI tools

# URL for Pulsar REST API (for admin operations)

# For TLS:

# webServiceUrl=https://localhost:8443/

webServiceUrl=http://localhost:18080/

# URL for Pulsar Binary Protocol (for produce and consume operations)

# For TLS:

# brokerServiceUrl=pulsar+ssl://localhost:6651/

brokerServiceUrl=pulsar://localhost:6650/

##2.5 验证集群服务是否正常

./bin/pulsar-admin brokers list iot-ipulsar-cluster

##2.6 测试生产消息

./bin/pulsar-client produce \

  persistent://public/default/ck.forward.log \

  -n 1 \

  -m "This is my idea!"

##2.6 测试消费消息[先启动]

./bin/pulsar-client consume \

  persistent://public/default/ck.forward.log \

  -n 100 \

  -s "forward.log.g1" \

  -t "Exclusive"

上一篇下一篇

猜你喜欢

热点阅读