環境準備
服務器系統 | Centos7.5 |
---|---|
內存 | 2G |
CPU | 2核 |
IP地址 | 192.168.46.131 |
服務器系統 | Centos7.5 |
---|---|
內存 | 2G |
CPU | 2核 |
IP地址 | 192.168.46.160 |
RocketMQ包地址:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.5.1/rocketmq-all-4.5.1-bin-release.zip
jdk環境地址:https://www.oracle.com/java/technologies/javase-downloads.html
131上操作
vim /etc/hosts
192.168.46.131 rocketmq-nameserver1
192.168.46.160 rocketmq-nameserver2
192.168.46.131 rocketmq-master1
192.168.46.131 rocketmq-slave2
192.168.46.160 rocketmq-master2
192.168.46.160 rocketmq-slave1
160上操作
vim /etc/hosts
192.168.46.160 rocketmq-nameserver2
192.168.46.131 rocketmq-nameserver1
192.168.46.160 rocketmq-master2
192.168.46.160 rocketmq-slave1
192.168.46.131 rocketmq-master1
192.168.46.131 rocketmq-slave2
在131、160上操作
解壓包
unzip rocketmq-all-4.4.0-bin-release.zip -d /usr/local/rocketmq
在文件的末尾處添加
vim /etc/profile
ROCKETMQ_HOME=/usr/local/rocketmq/rocketmq-all-4.4.0-bin-release
PATH=$PATH:$ROCKETMQ_HOME/bin
export ROCKETMQ_HOME PATH
輸入:wq! 保存並退出, 並使得配置立刻生效
source /etc/profile
mkdir /usr/local/rocketmq/store/{commitlog,consumequeue,index} -p
回到131上操作
vim /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-a.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=88
storePathRootDir=/usr/local/rocketmq/store
storePathCommitLog=/usr/local/rocketmq/store/commitlog
storePathConsumeQueue=/usr/local/rocketmq/store/consumequeue
storePathIndex=/usr/local/rocketmq/store/index
storeCheckpoint=/usr/local/rocketmq/store/checkpoint
abortFile=/usr/local/rocketmq/store/abort
maxMessageSize=65536
brokerRole=SYNC_MASTER
flushDiskType=SYNC_FLUSH
vim /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-b-s.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-b
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=11011
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=88
storePathRootDir=/usr/local/src/rocketmq/store
storePathCommitLog=/usr/local/src/rocketmq/store/commitlog
storePathConsumeQueue=/usr/local/src/rocketmq/store/consumequeue
storePathIndex=/usr/local/src/rocketmq/store/index
storeCheckpoint=/usr/local/src/rocketmq/store/checkpoint
abortFile=/usr/local/src/rocketmq/store/abort
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
再去160上操作
vim /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-b.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=88
storePathRootDir=/usr/local/rocketmq/store
storePathCommitLog=/usr/local/rocketmq/store/commitlog
storePathConsumeQueue=/usr/local/rocketmq/store/consumequeue
storePathIndex=/usr/local/rocketmq/store/index
storeCheckpoint=/usr/local/rocketmq/store/checkpoint
abortFile=/usr/local/rocketmq/store/abort
maxMessageSize=65536
brokerRole=SYNC_MASTER
flushDiskType=SYNC_FLUSH
vim /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-a-s.properties
brokerClusterName=rocketmq-cluster
brokerName=broker-a
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=11011
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=88
storePathRootDir=/usr/local/src/rocketmq/store
storePathCommitLog=/usr/local/src/rocketmq/store/commitlog
storePathConsumeQueue=/usr/local/src/rocketmq/store/consumequeue
storePathIndex=/usr/local/src/rocketmq/store/index
storeCheckpoint=/usr/local/src/rocketmq/store/checkpoint
abortFile=/usr/local/src/rocketmq/store/abort
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
mkdir /usr/local/src/rocketmq/store/{commitlog,consumequeue,index} -p
修改啓動腳本文件,131、160主機上操作
vim /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/bin/runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m"
runserver.sh
vim /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/bin/runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
服務啓動
啓動NameServe集羣
分別在192.168.46.131和192.168.46.160啓動NameServer
cd /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/bin/
nohup sh mqnamesrv &
啓動Broker集羣
在192.168.46.131上啓動master1和slave2
master1
cd /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/bin/
nohup sh mqbroker -c /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-a.properties &
slave2
nohup sh mqbroker -c /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-b-s.properties &
在192.168.46.160上啓動master2和slave2
cd /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/bin/
nohup sh mqbroker -c /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-b.properties &
nohup sh mqbroker -c /usr/local/rocketmq/rocketmq-all-4.4.0-bin-release/conf/2m-2s-sync/broker-a-s.properties &
nohup sh mqbroker -n 192.168.46.131:9876 &
nohup sh mqbroker -n 192.168.46.160:9876 &
查看namesrv的日誌
tail -500f ~/logs/rocketmqlogs/namesrv.log
查看broker的日誌
tail -500f ~/logs/rocketmqlogs/broker.log
131、160上操作
git clone https://github.com/apache/rocketmq-externals
cd rocketmq-externals/rocketmq-console/
yum -y install maven
mvn clean package -Dmaven.test.skip=true
vim /root/rocketmq-externals/rocketmq-console/src/main/resources/application.properties
rocketmq.config.namesrvAddr=192.168.46.131:9876;192.168.46.160:9876
cd rocketmq-externals/rocketmq-console/target/
java -jar rocketmq-console-ng-1.0.1.jar
mvn clean package -Dmaven.test.skip=true
java -jar rocketmq-console-ng-1.0.1.jar