zoukankan      html  css  js  c++  java
  • rocketmq 4.4部署安装

    官网下载:rocketmq-all-4.4.0-bin-release.zip

    准备环境:centos7.6

              Maven

              Java8+

    操作:

    在工作目录中进行如下操作: /home/software

    解压缩:unzip rocketmq-all-4.4.0-bin-release.zip

    改名:mv rocketmq-all-4.4.0 rocketmq

    添加目录:

    mkdir -p /home/software/rocketmq/store/broker-a /home/software/rocketmq/store/broker-a/nsumequeue /home/software/rocketmq/store/broker-a/commitlog /home/software/rocketmq/store/broker-a/index /home/software/rocketmq/logs /home/software/rocketmq/store/broker-b-s /home/software/rocketmq/store/broker-b-s/nsumequeue /home/software/rocketmq/store/broker-b-s/commitlog /home/software/rocketmq/store/broker-b-s/index

    修改配置文件:

    rocketmq默认给出了三种建议配置模式

    2m-2s-async(主从异步),----本文采用这种(图中红框文件夹)

    2m-2s-sync(主从同步)

    2m-noslave(master)

     

    进入后,我的配置如下

    配置文件模板参考

    192.168.2.161上的broker-a.properties文件如下:

    #所属集群名字

    brokerClusterName=rocketmq-cluster

    #broker名字,名字可重复,为了管理,每个master起一个名字,他的slave同他,eg:Amasterbroker-a,他的slave也叫broker-a

    brokerName=broker-a

    #0 表示 Master>0 表示 Slave

    brokerId=0

    #nameServer地址,分号分割

    namesrvAddr=192.168.2.161:9876;192.168.2.163:9876

    #在发送消息时,自动创建服务器不存在的topic,默认创建的队列数

    defaultTopicQueueNums=4

    #是否允许 Broker 自动创建Topic,建议线下开启,线上关闭

    autoCreateTopicEnable=true

    #是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭

    autoCreateSubscriptionGroup=true

    #Broker 对外服务的监听端口,

    listenPort=10911

    #删除文件时间点,默认凌晨 4

    deleteWhen=04

    #文件保留时间,默认 48 小时

    fileReservedTime=120

    #commitLog每个文件的大小默认1G

    mapedFileSizeCommitLog=1073741824

    #ConsumeQueue每个文件默认存30W条,根据业务情况调整

    mapedFileSizeConsumeQueue=300000

    #destroyMapedFileIntervalForcibly=120000

    #redeleteHangedFileInterval=120000

    #检测物理文件磁盘空间

    diskMaxUsedSpaceRatio=88

    #存储路径

    storePathRootDir=/home/software/rocketmq/store/broker-a

    #commitLog 存储路径

    storePathCommitLog=/home/software/rocketmq/store/broker-a/commitlog

    #消费队列存储路径存储路径

    storePathConsumeQueue=/home/software/rocketmq/store/broker-a/consumequeue

    #消息索引存储路径

    storePathIndex=/home/software/rocketmq/store/broker-a/index

    #checkpoint 文件存储路径

    storeCheckpoint=/home/software/rocketmq/store/checkpoint

    #abort 文件存储路径

    abortFile=/home/software/rocketmq/store/abort

    #限制的消息大小

    maxMessageSize=65536

    #flushCommitLogLeastPages=4

    #flushConsumeQueueLeastPages=2

    #flushCommitLogThoroughInterval=10000

    #flushConsumeQueueThoroughInterval=60000

    #Broker 的角色

    #- ASYNC_MASTER 异步复制Master

    #- SYNC_MASTER 同步双写Master

    #- SLAVE

    brokerRole=ASYNC_MASTER

    #刷盘方式

    #- ASYNC_FLUSH 异步刷盘

    ------192.168.2.161上的broker-b-s.properties文件如下:

    #所属集群名字

    brokerClusterName=rocketmq-cluster

    #broker名字,名字可重复,为了管理,每个master起一个名字,他的slave同他,eg:Amasterbroker-a,他的slave也叫broker-a

    brokerName=broker-b

    #0 表示 Master>0 表示 Slave

    brokerId=1

    #nameServer地址,分号分割

    namesrvAddr=192.168.2.161:9876;192.168.2.162:9876

    #在发送消息时,自动创建服务器不存在的topic,默认创建的队列数

    defaultTopicQueueNums=4

    #是否允许 Broker 自动创建Topic,建议线下开启,线上关闭

    autoCreateTopicEnable=true

    #是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭

    autoCreateSubscriptionGroup=true

    #Broker 对外服务的监听端口,

    listenPort=10920

    #删除文件时间点,默认凌晨 4

    deleteWhen=04

    #文件保留时间,默认 48 小时

    fileReservedTime=120

    #commitLog每个文件的大小默认1G

    mapedFileSizeCommitLog=1073741824

    #ConsumeQueue每个文件默认存30W条,根据业务情况调整

    mapedFileSizeConsumeQueue=300000

    #destroyMapedFileIntervalForcibly=120000

    #redeleteHangedFileInterval=120000

    #检测物理文件磁盘空间

    diskMaxUsedSpaceRatio=88

    #存储路径

    storePathRootDir=/home/software/rocketmq/store/broker-b-s

    #commitLog 存储路径

    storePathCommitLog=/home/software/rocketmq/store/broker-b-s/commitlog

    #消费队列存储路径存储路径

    storePathConsumeQueue=/home/software/rocketmq/store/broker-b-s/consumequeue

    #消息索引存储路径

    storePathIndex=/home/software/rocketmq/store/broker-b-s/index

    #checkpoint 文件存储路径

    storeCheckpoint=/home/software/rocketmq/store/checkpoint

    #abort 文件存储路径

    abortFile=/home/software/rocketmq/store/abort

    #限制的消息大小

    maxMessageSize=65536

    #flushCommitLogLeastPages=4

    #flushConsumeQueueLeastPages=2

    #flushCommitLogThoroughInterval=10000

    #flushConsumeQueueThoroughInterval=60000

    #Broker 的角色

    #- ASYNC_MASTER 异步复制Master

    #- SYNC_MASTER 同步双写Master

    #- SLAVE

    brokerRole=SLAVE

    ------192.168.2.162上的broker-b.properties文件如下:

    #所属集群名字

    brokerClusterName=rocketmq-cluster

    #broker名字,名字可重复,为了管理,每个master起一个名字,他的slave同他,eg:Amasterbroker-a,他的slave也叫broker-a

    brokerName=broker-b

    #0 表示 Master>0 表示 Slave

    brokerId=0

    #nameServer地址,分号分割

    namesrvAddr=192.168.2.161:9876;192.168.2.163:9876

    #在发送消息时,自动创建服务器不存在的topic,默认创建的队列数

    defaultTopicQueueNums=4

    #是否允许 Broker 自动创建Topic,建议线下开启,线上关闭

    autoCreateTopicEnable=true

    #是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭

    autoCreateSubscriptionGroup=true

    #Broker 对外服务的监听端口,

    listenPort=10911

    #删除文件时间点,默认凌晨 4

    deleteWhen=04

    #文件保留时间,默认 48 小时

    fileReservedTime=120

    #commitLog每个文件的大小默认1G

    mapedFileSizeCommitLog=1073741824

    #ConsumeQueue每个文件默认存30W条,根据业务情况调整

    mapedFileSizeConsumeQueue=300000

    #destroyMapedFileIntervalForcibly=120000

    #redeleteHangedFileInterval=120000

    #检测物理文件磁盘空间

    diskMaxUsedSpaceRatio=88

    #存储路径

    storePathRootDir=/home/software/rocketmq/store/broker-a

    #commitLog 存储路径

    storePathCommitLog=/home/software/rocketmq/store/broker-a/commitlog

    #消费队列存储路径存储路径

    storePathConsumeQueue=/home/software/rocketmq/store/broker-a/consumequeue

    #消息索引存储路径

    storePathIndex=/home/software/rocketmq/store/broker-a/index

    #checkpoint 文件存储路径

    storeCheckpoint=/home/software/rocketmq/store/checkpoint

    #abort 文件存储路径

    abortFile=/home/software/rocketmq/store/abort

    #限制的消息大小

    maxMessageSize=65536

    #flushCommitLogLeastPages=4

    #flushConsumeQueueLeastPages=2

    #flushCommitLogThoroughInterval=10000

    #flushConsumeQueueThoroughInterval=60000

    #Broker 的角色

    #- ASYNC_MASTER 异步复制Master

    #- SYNC_MASTER 同步双写Master

    #- SLAVE

    brokerRole=ASYNC_MASTER

    #刷盘方式

    #- ASYNC_FLUSH 异步刷盘

    ------192.168.2.162上的broker-a-s.properties文件如下:

    #所属集群名字

    brokerClusterName=rocketmq-cluster

    #broker名字,名字可重复,为了管理,每个master起一个名字,他的slave同他,eg:Amasterbroker-a,他的slave也叫broker-a

    brokerName=broker-a

    #0 表示 Master>0 表示 Slave

    brokerId=1

    #nameServer地址,分号分割

    namesrvAddr=192.168.2.161:9876;192.168.2.162:9876

    #在发送消息时,自动创建服务器不存在的topic,默认创建的队列数

    defaultTopicQueueNums=4

    #是否允许 Broker 自动创建Topic,建议线下开启,线上关闭

    autoCreateTopicEnable=true

    #是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭

    autoCreateSubscriptionGroup=true

    #Broker 对外服务的监听端口,

    listenPort=10920

    #删除文件时间点,默认凌晨 4

    deleteWhen=04

    #文件保留时间,默认 48 小时

    fileReservedTime=120

    #commitLog每个文件的大小默认1G

    mapedFileSizeCommitLog=1073741824

    #ConsumeQueue每个文件默认存30W条,根据业务情况调整

    mapedFileSizeConsumeQueue=300000

    #destroyMapedFileIntervalForcibly=120000

    #redeleteHangedFileInterval=120000

    #检测物理文件磁盘空间

    diskMaxUsedSpaceRatio=88

    #存储路径

    storePathRootDir=/home/software/rocketmq/store/broker-b-s

    #commitLog 存储路径

    storePathCommitLog=/home/software/rocketmq/store/broker-b-s/commitlog

    #消费队列存储路径存储路径

    storePathConsumeQueue=/home/software/rocketmq/store/broker-b-s/consumequeue

    #消息索引存储路径

    storePathIndex=/home/software/rocketmq/store/broker-b-s/index

    #checkpoint 文件存储路径

    storeCheckpoint=/home/software/rocketmq/store/checkpoint

    #abort 文件存储路径

    abortFile=/home/software/rocketmq/store/abort

    #限制的消息大小

    maxMessageSize=65536

    #flushCommitLogLeastPages=4

    #flushConsumeQueueLeastPages=2

    #flushCommitLogThoroughInterval=10000

    #flushConsumeQueueThoroughInterval=60000

    #Broker 的角色

    #- ASYNC_MASTER 异步复制Master

    #- SYNC_MASTER 同步双写Master

    #- SLAVE

    brokerRole=SLAVE

    ----

    节点1192.168.2.161

    节点2: 192.168.2.162

    批量关闭:ps -ef | grep rocketmq | grep -v grep | awk -F ' ' '{print $2}' | xargs kill -2

    ---

    启动节点1nameserver

    nohup sh /home/software/rocketmq/bin/mqnamesrv > /home/software/rocketmq/logs/mqnamesrv.log 2>&1 &

    启动节点2nameserver

    nohup sh /home/software/rocketmq/bin/mqnamesrv > /home/software/rocketmq/logs/mqnamesrv.log 2>&1 &

    启动broker

    启动节点1broker-amaster,对应的配置文件broker-a.properties,启动多个实例时,指定对应的配置文件

    nohup sh /home/software/rocketmq/bin/mqbroker -c /home/software/rocketmq/conf/2m-2s-async/broker-a.properties > /home/software/rocketmq/logs/broker-a.log 2>&1 &

    启动节点2broker-b

    nohup sh /home/software/rocketmq/bin/mqbroker -c /home/software/rocketmq/conf/2m-2s-async/broker-b.properties > /home/software/rocketmq/logs/broker-b.log 2>&1 &

    启动slave

    启动节点2broker-a-s

    nohup sh /home/software/rocketmq/bin/mqbroker -c /home/software/rocketmq/conf/2m-2s-async/broker-a-s.properties > /home/software/rocketmq/logs/broker-a-s.log 2>&1 &

    启动节点1broker-b-s

    nohup sh /home/software/rocketmq/bin/mqbroker -c /home/software/rocketmq/conf/2m-2s-async/broker-b-s.properties > /home/software/rocketmq/logs/broker-b-s.log 2>&1 &

    查询验证

    sh /home/software/rocketmq/bin/mqadmin clusterList -n 192.168.2.161:9876

    [root@localhost 2m-2s-async]# sh /home/software/rocketmq/bin/mqadmin clusterList -n 192.168.2.161: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

    rocketmq-cluster  broker-a                0     192.168.2.161:10911    V4_4_0                   0.00(0,0ms)         0.00(0,0ms)          0 431674.28 -1.0000

    rocketmq-cluster  broker-a                1     192.168.2.162:10920    V4_4_0                   0.00(0,0ms)         0.00(0,0ms)          0 431674.28 0.0946

    rocketmq-cluster  broker-b                0     192.168.2.162:10911    V4_4_0                   0.00(0,0ms)         0.00(0,0ms)          0 431674.28 0.0946

    rocketmq-cluster  broker-b                1     192.168.2.161:10920    V4_4_0                   0.00(0,0ms)         0.00(0,0ms)          0 431674.28 0.0989

     

    启动web管理界面

    rocketmq提供多种管理方式,命令行和界面等,

    apache提供一个开源的扩展项目: https://github.com/apache/rocketmq-externals 里面包含一个子项目rocketmq-console,配置下,打个包就可以用了

     

     

    application.properties中添加rocketmq.config.namesrvAddr的值,如图

     

    回到目录开始打包:

     

    打包命令:mvn clean package -Dmaven.test.skip=true

    报错如下:

     

     由于rocketmq的4.4.0版本已经发布,所以4.4.0-SNAPSHOT已经没有了,所以还需要修改pom文件的版本信息,将<rocketmq-version>4.4.0-SNAPSHOT</rocketmq-version>改为4.4.0

     

    完成后再次打包:mvn clean package -Dmaven.test.skip=true

     

    成功后,启用jar包即可

     

    java -jar rocketmq-console-ng-1.0.0.jar >/home/software/rocketmq/logs/mq-console.log 2>&1 &

    验证:

  • 相关阅读:
    kettle 9.1 windows 安装
    C# post 方式调用 webservice
    crm 2016 隐藏 crmTopBar 新建活动 新建记录 导入数据
    SqlServer修改数据库文件存放位置
    always on 下移动数据库文件 AlwaysON move database without breaking HADR
    kettle 启动问题 spoon 处理方法
    kettle Spoon.bat 启动 java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
    SQL 查询学生缺考情况
    SQL学习笔记:选取第N条记录
    观察者模式在MVP中的应用
  • 原文地址:https://www.cnblogs.com/fatyao/p/10632924.html
Copyright © 2011-2022 走看看