brokerIP1 当前broker监听的IP
brokerIP2 存在broker主从时,在broker主节点上配置了brokerIP2的话,broker从节点会连接主节点配置的brokerIP2来同步。
默认不配置brokerIP1和brokerIP2时,都会根据当前网卡选择一个IP使用,当你的机器有多块网卡时,很有可能会有问题。比如,我遇到的问题是我机器上有两个IP,一个公网IP,一个私网IP,结果默认选择的走公网IP,这是不正确的,我期望的是所有业务内部通信都走内网。
举个例子,在下面部署架构的情况下的各broker节点配置文件:
两个namesrv,两主两从,异步
10.10.10.1 namesrv1
10.10.10.2 namesrv2
10.10.10.3 broker-a
10.10.10.4 broker-b
10.10.10.5 broker-a-s
10.10.10.6 broker-b-s
broker-a的配置
brokerClusterName=DefaultCluster
brokerIP1=10.10.10.3
brokerIP2=10.10.10.3
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
#nameServer地址,分号分割
namesrvAddr=10.10.10.1:9876;10.10.10.2:9876
#存储路径
storePathRootDir=/home/rocketmq/rocketmq/data
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/rocketmq/data/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/rocketmq/data/consumequeue
#消息索引存储路径
storePathIndex=/home/rocketmq/rocketmq/data/index
#checkpoint 文件存储路径
storeCheckpoint=/home/rocketmq/rocketmq/data/checkpoint
#abort 文件存储路径
abortFile=/home/rocketmq/rocketmq/data/abort
broker-b的配置
brokerClusterName=DefaultCluster
brokerIP1=10.10.10.4
brokerIP2=10.10.10.4
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
#nameServer地址,分号分割
namesrvAddr=10.10.10.1:9876;10.10.10.2:9876
#存储路径
storePathRootDir=/home/rocketmq/rocketmq/data
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/rocketmq/data/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/rocketmq/data/consumequeue
#消息索引存储路径
storePathIndex=/home/rocketmq/rocketmq/data/index
#checkpoint 文件存储路径
storeCheckpoint=/home/rocketmq/rocketmq/data/checkpoint
#abort 文件存储路径
abortFile=/home/rocketmq/rocketmq/data/abort
broker-a-s的配置
brokerClusterName=DefaultCluster
brokerIP1=10.10.10.5
brokerName=broker-a
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
#nameServer地址,分号分割
namesrvAddr=10.10.10.1:9876;10.10.10.2:9876
#存储路径
storePathRootDir=/home/rocketmq/rocketmq/data
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/rocketmq/data/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/rocketmq/data/consumequeue
#消息索引存储路径
storePathIndex=/home/rocketmq/rocketmq/data/index
#checkpoint 文件存储路径
storeCheckpoint=/home/rocketmq/rocketmq/data/checkpoint
#abort 文件存储路径
abortFile=/home/rocketmq/rocketmq/data/abort
broker-b-s的配置
brokerClusterName=DefaultCluster
brokerIP1=10.10.10.6
brokerName=broker-b
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
#nameServer地址,分号分割
namesrvAddr=10.10.10.1:9876;10.10.10.2:9876
#存储路径
storePathRootDir=/home/rocketmq/rocketmq/data
#commitLog 存储路径
storePathCommitLog=/home/rocketmq/rocketmq/data/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/home/rocketmq/rocketmq/data/consumequeue
#消息索引存储路径
storePathIndex=/home/rocketmq/rocketmq/data/index
#checkpoint 文件存储路径
storeCheckpoint=/home/rocketmq/rocketmq/data/checkpoint
#abort 文件存储路径
abortFile=/home/rocketmq/rocketmq/data/abort