CentOS7.4安装配置RocketMQ4.5.0

目录

1、环境规划... 2

2、配置环境变量... 2

3、上传安装包... 2

4、解压安装包... 2

5、修改配置文件... 3

5.1、节点一133.55. 3

5.2、节点二133.56. 5

6、创建相关目录... 8

7、根据上述目录修改xml配置文件... 8

8、修改初始化内存大小... 8

9、停防火墙... 9

10、停selinux. 9

11、起namesrv服务... 9

12、起broker. 9

13、查看启动是否成功... 9

14、起broker. 9

15、查看集群状态... 10

16、启停集群... 10

17、测试消息队列... 10

 

1、环境规划

CentOS7.4安装配置RocketMQ4.5.0_第1张图片

 

2、配置环境变量

export ROCKETMQ_HOME=/usr/data/svr/rocketmq

export PATH=$Pexport PATH=$PATH::$ROCKETMQ_HOME/binATH::$ROCKETMQ_HOME/bin

3、上传安装包

manage@finance_encrypt1[/usr/data/manage]$ll rocketmq-all-4.5.0-bin-release.zip

-rw-rw-r--. 1 manage manage 12536572 7月  27 09:23 rocketmq-all-4.5.0-bin-release.zip

5、解压的文件mv到home目录

cd rocketmq-all-4.5.0-bin-release

cp -R ./* /usr/data/svr/rocketmq/

注意:

/usr/data/svr/rocketmq/是上面环境变量中配置的ROCKETMQ_HOME目录。

4、解压安装包

unzip rocketmq-all-4.5.0-bin-release.zip

5、修改配置文件

5.1、节点一133.55

/usr/data/svr/rocketmq/conf/2m-2s-sync/broker-a.properties

5.1.1、broker-a

root@finance_encrypt1[/usr/data/svr/rocketmq/conf/2m-2s-sync]#cat broker-a.properties

# Licensed to the Apache Software Foundation (ASF) under one or more

# contributor license agreements.  See the NOTICE file distributed with

# this work for additional information regarding copyright ownership.

# The ASF licenses this file to You under the Apache License, Version 2.0

# (the "License"); you may not use this file except in compliance with

# the License.  You may obtain a copy of the License at

#

#     http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

#brokerClusterName=DefaultCluster

#brokerName=broker-a

#brokerId=0

#deleteWhen=04

#fileReservedTime=48

#brokerRole=SYNC_MASTER

#flushDiskType=ASYNC_FLUSH

 

 

brokerClusterName=tl-rocketmq-cluster

brokerName=broker-a

brokerId=0

namesrvAddr=xxx.xxx.133.55:9876;xxx.xxx.133.56:9876

defaultTopicQueueNums=4

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

brokerIP1=xxx.xxx.133.55

listenPort=10911

deleteWhen=04

fileReservedTime=120

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=300000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

storePathRootDir=/usr/data/svr/rocketmq/data/store/master/

storePathCommitLog=/usr/data/svr/rocketmq/data/store/master/commitlog

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

checkTransactionMessageEnable=false

sendMessageThreadPoolNums=128

pullMessageThreadPoolNums=128

brokerRole=SYNC_MASTER

flushDiskType=ASYNC_FLUSH

 

5.1.2、broker-b-s

root@finance_encrypt1[/usr/data/svr/rocketmq/conf/2m-2s-sync]#cat broker-b-s.properties

# Licensed to the Apache Software Foundation (ASF) under one or more

# contributor license agreements.  See the NOTICE file distributed with

# this work for additional information regarding copyright ownership.

# The ASF licenses this file to You under the Apache License, Version 2.0

# (the "License"); you may not use this file except in compliance with

# the License.  You may obtain a copy of the License at

#

#     http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

#brokerClusterName=DefaultCluster

#brokerName=broker-b

#brokerId=1

#deleteWhen=04

#fileReservedTime=48

#brokerRole=SLAVE

#flushDiskType=ASYNC_FLUSH

 

 

brokerClusterName=tl-rocketmq-cluster

brokerName=broker-b

brokerId=1

namesrvAddr=finance_encrypt1:9876;finance_encrypt2:9876

defaultTopicQueueNums=4

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

listenPort=10921

deleteWhen=04

fileReservedTime=120

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=300000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

storePathRootDir=/usr/data/svr/rocketmq/data/store/slave/

storePathCommitLog=/usr/data/svr/rocketmq/data/store/slave/commitlog

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

checkTransactionMessageEnable=false

sendMessageThreadPoolNums=128

pullMessageThreadPoolNums=128

brokerRole=SLAVE

flushDiskType=SYNC_FLUSH

 

5.2、节点二133.56

/usr/data/svr/rocketmq/conf/2m-2s-sync/broker-a.properties

5.2.1、broker-a-s

manage@finance_encrypt2[/usr/data/svr/rocketmq/conf/2m-2s-sync]$cat broker-a-s.properties

# Licensed to the Apache Software Foundation (ASF) under one or more

# contributor license agreements.  See the NOTICE file distributed with

# this work for additional information regarding copyright ownership.

# The ASF licenses this file to You under the Apache License, Version 2.0

# (the "License"); you may not use this file except in compliance with

# the License.  You may obtain a copy of the License at

#

#     http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

#brokerClusterName=DefaultCluster

#brokerName=broker-a

#brokerId=1

#deleteWhen=04

#fileReservedTime=48

#brokerRole=SLAVE

#flushDiskType=ASYNC_FLUSH

 

 

 

brokerClusterName=tl-rocketmq-cluster

brokerName=broker-a

brokerId=1

namesrvAddr=xxx.xxx.133.55:9876;xxx.xxx.133.56:9876

defaultTopicQueueNums=4

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

listenPort=10921

brokerIP1=xxx.xxx.133.56

deleteWhen=04

fileReservedTime=120

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=300000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

storePathRootDir=/usr/data/svr/rocketmq/data/store/slave/

storePathCommitLog=/usr/data/svr/rocketmq/data/store/slave/commitlog

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

checkTransactionMessageEnable=false

sendMessageThreadPoolNums=128

pullMessageThreadPoolNums=128

brokerRole=SLAVE

flushDiskType=ASYNC_FLUSH

 

5.2.2、broker-b

manage@finance_encrypt2[/usr/data/svr/rocketmq/conf/2m-2s-sync]$cat broker-b.properties

# Licensed to the Apache Software Foundation (ASF) under one or more

# contributor license agreements.  See the NOTICE file distributed with

# this work for additional information regarding copyright ownership.

# The ASF licenses this file to You under the Apache License, Version 2.0

# (the "License"); you may not use this file except in compliance with

# the License.  You may obtain a copy of the License at

#

#     http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

#brokerClusterName=DefaultCluster

#brokerName=broker-b

#brokerId=0

#deleteWhen=04

#fileReservedTime=48

#brokerRole=SYNC_MASTER

#flushDiskType=ASYNC_FLUSH

 

 

 

brokerClusterName=tl-rocketmq-cluster

brokerName=broker-b

brokerId=0

namesrvAddr=finance_encrypt1:9876;finance_encrypt2:9876

defaultTopicQueueNums=4

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

listenPort=10911

deleteWhen=04

fileReservedTime=120

mapedFileSizeCommitLog=1073741824

mapedFileSizeConsumeQueue=300000

destroyMapedFileIntervalForcibly=120000

redeleteHangedFileInterval=120000

diskMaxUsedSpaceRatio=88

storePathRootDir=/usr/data/svr/rocketmq/data/store/master/

storePathCommitLog=/usr/data/svr/rocketmq/data/store/master/commitlog

maxMessageSize=65536

flushCommitLogLeastPages=4

flushConsumeQueueLeastPages=2

flushCommitLogThoroughInterval=10000

flushConsumeQueueThoroughInterval=60000

checkTransactionMessageEnable=false

sendMessageThreadPoolNums=128

pullMessageThreadPoolNums=128

brokerRole=SYNC_MASTER

flushDiskType=SYNC_FLUSH

 

6、创建相关目录

sudo mkdir /usr/data/svr/rocketmq/data

sudo mkdir /usr/data/svr/rocketmq/data/store/commitlog

sudo mkdir /usr/data/svr/rocketmq/data/store/consumequeue

sudo mkdir /usr/data/svr/rocketmq/data/store/index

sudo mkdir /usr/data/svr/rocketmq/logs

 

7、根据上述目录修改xml配置文件

cd /usr/data/svr/rocketmq/conf&&sudo sed -i 's#${user.home}#/usr/data/svr/rocketmq#g' *.xml

 

 

grep "user.home" *.xml

grep "/usr/data/svr/rocketmq" *.xml

 

sudo mkdir -p /usr/data/svr/rocketmq/logs/rocketmqlogs/

sudo mkdir -p /usr/data/svr/rocketmq/logs/rocketmqlogs/otherdays/

 

8、修改初始化内存大小

bin/runbroker.sh

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn128m"

 

bin/runserver.sh

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

 

9、停防火墙

sudo systemctl stop firewalld

sudo systemctl disable firewalld

 

10、停selinux

vi /etc/selinux/config

 

11、起namesrv服务

cd /usr/data/svr/rocketmq/bin目录下执行命令

两个节点:

nohup sh mqnamesrv &

 

12、起broker

启动broker:

节点1:

nohup mqbroker -c /usr/data/svr/rocketmq/conf/broker-a.properties &

节点2:

nohup mqbroker -c /usr/data/svr/rocketmq/conf/broker-a-s.properties &

 

13、查看启动是否成功

manage@finance_encrypt1[/usr/data/svr/rocketmq/bin]$jps

39314 BrokerStartup

40066 Jps

36441 BrokerStartup

24924 NamesrvStartup

 

14、起broker

启动broker:

节点2:

nohup mqbroker -c /usr/data/svr/rocketmq/conf/broker-b.properties &

节点1:

nohup mqbroker -c /usr/data/svr/rocketmq/conf/broker-b-s.properties &

 

15、查看集群状态

mqadmin clusterList -n xxx.xxx.121.73:9876

 

manage@finance_encrypt1[/usr/data/svr/rocketmq/bin]$mqadmin clusterList -n xxx.xxx.121.73:9876

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

#Cluster Name     #Broker Name            #BID  #Addr                  #Version                #InTPS(LOAD)       #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE

tracluster        broker-a                0     xxx.xxx.121.73:10911    V4_5_1                   0.00(0,0ms)         0.00(0,0ms)          0 434628.76 -1.0000

tracluster        broker-b                1     xxx.xxx.121.73:10921    V4_5_1                   0.00(0,0ms)         0.00(0,0ms)          0 434628.76 -1.0000

 

manage@finance_encrypt2[/usr/data/svr/rocketmq/bin]$mqadmin clusterList -n xxx.xxx.121.74:9876

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

#Cluster Name     #Broker Name            #BID  #Addr                  #Version                #InTPS(LOAD)       #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE

tracluster        broker-a                1     xxx.xxx.121.74:10921    V4_5_1                   0.00(0,0ms)         0.00(0,0ms)          0 434628.78 -1.0000

tracluster        broker-b                0     xxx.xxx.121.74:10911    V4_5_1                   0.00(0,0ms)         0.00(0,0ms)          0 434628.78 -1.0000

备注:

1、节点1和节点2都是双网卡

xxx.xxx.121.73就是xxx.xxx.133.55

xxx.xxx.121.7/4就是xxx.xxx.133.56

2、/etc/hosts

节点1

cat /etc/hosts
xxx.xxx.133.55   finance_encrypt1
xxx.xxx.133.56   finance_encrypt2

节点2

cat /etc/hosts

xxx.xxx.133.55   finance_encrypt1
xxx.xxx.133.56   finance_encrypt2

16、启停集群

启停

mqshutdown broker

mqshutdown namesrv

 

17、测试消息队列

export NAMESRV_ADDR='xxx.xxx.121.73:9876;xxx.xxx.121.74:9876'

 

测试生产者

tools.sh org.apache.rocketmq.example.quickstart.Producer

 

测试消费者

tools.sh org.apache.rocketmq.example.quickstart.Consumer

确保上述生产者和消费者测试都不抛异常即可。

 

你可能感兴趣的:(centos,rocketMQ)