zk集群划分:
- metadataStore 单独集群;
- bookie & configurationMetadataStore 共享集群;
bookie跨机房大集群共享存储、broker层面独立小集群
注:bookie与metadataStore使用不同的zk集群时,pulsar目前的默认机架感知策略实现是有bug的,该bug会导致机架感知策略不对&数据恢复时报错等。(该bug可关注 https://github.com/apache/pulsar/pull/18672#issuecomment-1347634103)
- bookie初始化
export BOOKIE_CONF=/app/conf/bookkeeper.conf && ./bookkeeper shell metaformat
org.apache.bookkeeper.bookie.BookieShell
--conf conf/bookkeeper1.conf metaformat
- broker初始化
注:existing-bk-metadata-service-uri记得加上最后的/ledgers
org.apache.pulsar.PulsarClusterMetadataSetup
export PULSAR_BROKER_CONF=/app/conf/broker.conf && ./bin/pulsar initialize-cluster-metadata \
--cluster sf-pulsar-1 \
--metadata-store zk:10.207.128.13:2181,10.207.128.14:2181,10.207.128.15:2181,10.207.128.16:2181,10.207.128.17:2181/sf-pulsar-1 \
--configuration-metadata-store zk:10.207.128.13:2181,10.207.128.14:2181,10.207.128.15:2181,10.207.128.16:2181,10.207.128.17:2181/sf-pulsar-1 \
--existing-bk-metadata-service-uri "zk+hierarchical://10.206.128.154:2181;10.206.128.155:2181;10.206.128.156:2181;10.206.128.157:2181;10.206.128.158:2181/bk1/ledgers" \
--web-service-url http://10.206.64.12:18080 \
--broker-service-url pulsar://10.206.64.12:16650
- 事务初始化
org.apache.pulsar.PulsarTransactionCoordinatorMetadataSetup
export PULSAR_BROKER_CONF=/app/conf/broker.conf && ./pulsar initialize-transaction-coordinator-metadata --cluster sf-pulsar-1 --configuration-store 10.206.128.212:2181,10.206.128.213:2181,10.206.128.214:2181,10.206.128.215:2181,10.206.128.216:2181/pconfig
### BookieServer 启动三个
```shell
org.apache.bookkeeper.proto.BookieServer
-Dlog4j2.configurationFile=D:\opensource\pulsar\conf\log4j2.xml
--conf conf/bookkeeper1.conf
bookkeeper1.conf bookkeeper2.conf bookkeeper3.conf 配置主要配置如下参数
journalDirectories=/app/data/bookkeeper/journal
ledgerDirectories=/app/data/bookkeeper/ledgers
metadataServiceUri=zk+hierarchical://10.206.128.154:2181;10.206.128.155:2181;10.206.128.156:2181;10.206.128.157:2181;10.206.128.158:2181/bk1
useHostNameAsBookieID=true
autoRecoveryDaemonEnabled=false
httpServerEnabled=true
httpServerPort=8000
httpServerClass=org.apache.bookkeeper.http.vertx.VertxHttpServer
enableStatistics=true
statsProviderClass=org.apache.bookkeeper.stats.prometheus.PrometheusMetricsProvider
prometheusStatsHttpPort=8000
org.apache.pulsar.PulsarBrokerStarter
-Dlog4j2.configurationFile=D:\opensource\pulsar\conf\log4j2.xml
--broker-conf conf/broker1.conf
broker1.conf broker2.conf 配置主要配置如下参数
metadataStoreUrl=zk:10.206.128.154:2181,10.206.128.155:2181,10.206.128.156:2181,10.206.128.157:2181,10.206.128.158:2181/sf-pulsar-1
configurationMetadataStoreUrl=zk:10.206.128.154:2181,10.206.128.155:2181,10.206.128.156:2181,10.206.128.157:2181,10.206.128.158:2181/pconf
brokerServicePort=16650
webServicePort=18080
clusterName=sf-pulsar-1
ttlDurationDefaultInSeconds=86400
allowAutoTopicCreation=false
allowAutoTopicCreationType=partitioned
allowAutoSubscriptionCreation=false
brokerDeleteInactiveTopicsEnabled=false
brokerDeduplicationEnabled=true
defaultNumberOfNamespaceBundles=16
maxTopicsPerNamespace=1024
enableNonPersistentTopics=false
authenticationEnabled=true
authenticationProviders=org.apache.pulsar.broker.authentication.AuthenticationProviderToken
authorizationEnabled=true
authorizationAllowWildcardsMatching=true
superUserRoles=sfadmin
brokerClientAuthenticationPlugin=org.apache.pulsar.client.impl.auth.AuthenticationToken
brokerClientAuthenticationParameters=token:eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJzZmFkbWluIn0.H1Rbd9PM_APogpyK26G8qGvNF4zxJWA0Wy7XmvJqKPibP8xVxhz1Y264_pkKyAZ4CKrkTXx3975Hyi9aeXLo1Vj71j7PbIyg4QqR0dKRT66PmklLbqMOxlzmZiY92pE6_wAMKwexBkvBEwCxmKcWzNs3G6G9AVRPq82BWXJsEcXt1X0LIsAT4-drpU_JqB_ZiuiUu3tolVH00sj5B3rQJzzaS4b6whBJVVZxY1PfspKunrEYYLzMJOw2O7FUiNvv2_wk-IVXwFrmq9UaDklNSp8kKx0F4pzx1mEPWHFGILH4vOrPbZYhn9F0EeTdU7_13WVyaC156VWulOdjTQ5Bfw
tokenPublicKey=file:///app/conf/sf-pulsar-1-public.key
bookkeeperMetadataServiceUri=zk+hierarchical://10.206.128.154:2181;10.206.128.155:2181;10.206.128.156:2181;10.206.128.157:2181;10.206.128.158:2181/bk1
bookkeeperClientRackawarePolicyEnabled=true
bookkeeperClientRegionawarePolicyEnabled=false
bookkeeperClientEnforceMinNumRacksPerWriteQuorum=true
bookkeeperClientMinNumRacksPerWriteQuorum=2
managedLedgerDefaultEnsembleSize=3
managedLedgerDefaultWriteQuorum=3
managedLedgerDefaultAckQuorum=2
managedLedgerMaxEnsembleSize=9
managedLedgerMaxWriteQuorum=6
managedLedgerMaxAckQuorum=4
defaultRetentionTimeInMinutes=4320
defaultRetentionSizeInMB=-1
transactionCoordinatorEnabled=true
loadBalancerOverrideBrokerNicSpeedGbps=1
export PULSAR_BOOKKEEPER_CONF='/app/conf/bookkeeper-autorecovery.conf'
sh pulsar/bin/pulsar-daemon start autorecovery
###### bookkeeper client url config #####
metadataServiceUri=zk+hierarchical://10.206.128.154:2181;10.206.128.155:2181;10.206.128.156:2181;10.206.128.157:2181;10.206.128.158:2181/bk1
###### bookkeeper client rack config #####
ensemblePlacementPolicy=org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy
reppDnsResolverClass=org.apache.pulsar.bookie.rackawareness.BookieRackAffinityMapping
minNumRacksPerWriteQuorum=2
enforceMinNumRacksPerWriteQuorum=true
##### BookieRackAffinityMapping config #####
metadataStoreUrl=zk:10.206.128.154:2181,10.206.128.155:2181,10.206.128.156:2181,10.206.128.157:2181,10.206.128.158:2181/sf-pulsar-1
zkTimeout=3000
https://gist.github.com/yangl/63e02ff7daaac3e6a4d06c3327bea65e