当前位置:   article > 正文

阿里云主机安装RocketMQ 集群支持外网访问_如何搭建一个可外部访问的rocketmq

如何搭建一个可外部访问的rocketmq

背景:因公司迁移机房,需要在云主机上部署一套和本地一样的rocketMQ,原本计划直接购买云rocketMQ,云rocketMQ仅支持5.0.0,本地rocketMQ 是3.4.6,公司多个服务都使用本地的3.4.6版本的RocketMQ,所以需要再云上搭建一套简易版RocketMQ集群,并支持外网访问。

准备:两台开通外网的云主机,带宽100M,16G内存,500G硬盘,两台成本1000+

           设置主机名,安装jdk,配置免密等等,前期的准备工作。

           安装包:rocketmq-3.4.6.tar.gz

           下载地址:

因为是只有两台,所以规划是2m-noslave

vi /opt/servers/rocketmq-3.4.6/devenv/conf/2m-noslave/broker-a.properties

  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. brokerClusterName=AdpMqCluster
  16. brokerName=broker-a
  17. #0 表示 Master, >0 表示 Slave
  18. brokerId=0
  19. namesrvAddr=hadoop001:9876;hadoop002:9876
  20. #外网ip
  21. brokerIP1=101.200.149.*
  22. #内网ip
  23. brokerIP2=172.17.128.14
  24. deleteWhen=04
  25. #在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
  26. defaultTopicQueueNums=4
  27. #是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
  28. autoCreateTopicEnable=true
  29. #是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
  30. autoCreateSubscriptionGroup=true
  31. #Broker 对外服务的监听端口
  32. listenPort=10911
  33. #删除文件时间点,默认凌晨 0
  34. deleteWhen=00
  35. #文件保留时间,默认 48 小时
  36. fileReservedTime=120
  37. #commitLog每个文件的大小默认1G
  38. mapedFileSizeCommitLog=1073741824
  39. #ConsumeQueue每个文件默认存30W条,根据业务情况调整
  40. mapedFileSizeConsumeQueue=50000000
  41. destroyMapedFileIntervalForcibly=120000
  42. redeleteHangedFileInterval=120000
  43. #检测物理文件磁盘空间
  44. diskMaxUsedSpaceRatio=88
  45. #存储路径
  46. storePathRootDir=/opt/servers/rocketmq/data
  47. #commitLog 存储路径
  48. storePathCommitLog=/opt/servers/rocketmq/data/commitlog
  49. #消费队列存储路径存储路径
  50. storePathConsumeQueue=/opt/servers/rocketmq/data/consumequeue
  51. #消息索引存储路径
  52. storePathIndex=/opt/servers/rocketmq/data/index
  53. #checkpoint 文件存储路径
  54. storeCheckpoint=/opt/servers/rocketmq/data/checkpoint
  55. #abort 文件存储路径
  56. abortFile=/opt/servers/rocketmq/data/abort
  57. #限制的消息大小
  58. #maxMessageSize=65536
  59. maxMessageSize=5242880
  60. #flushCommitLogLeastPages=4
  61. #flushConsumeQueueLeastPages=2
  62. #flushCommitLogThoroughInterval=10000
  63. #flushConsumeQueueThoroughInterval=60000
  64. #Broker 的角色
  65. #- ASYNC_MASTER 异步复制Master
  66. #- SYNC_MASTER 同步双写Master
  67. #- SLAVE
  68. brokerRole=ASYNC_MASTER
  69. #刷盘方式
  70. #- ASYNC_FLUSH 异步刷盘
  71. #- SYNC_FLUSH 同步刷盘
  72. flushDiskType=ASYNC_FLUSH
  73. #checkTransactionMessageEnable=false
  74. #发消息线程池数量
  75. sendMessageThreadPoolNums=128
  76. #拉消息线程池数量
  77. pullMessageThreadPoolNums=128

vi /opt/servers/rocketmq-3.4.6/devenv/conf/2m-noslave/broker-b.properties

  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. brokerClusterName=AdpMqCluster
  16. brokerName=broker-b
  17. #0 表示 Master, >0 表示 Slave
  18. brokerId=0
  19. namesrvAddr=hadoop001:9876;hadoop002:9876
  20. #外网ip
  21. brokerIP1=123.57.61.*
  22. #内网ip
  23. brokerIP2=172.17.128.15
  24. deleteWhen=04
  25. #在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
  26. defaultTopicQueueNums=4
  27. #是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
  28. autoCreateTopicEnable=true
  29. #是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
  30. autoCreateSubscriptionGroup=true
  31. #Broker 对外服务的监听端口
  32. listenPort=10911
  33. #删除文件时间点,默认凌晨 0
  34. deleteWhen=00
  35. #文件保留时间,默认 48 小时
  36. fileReservedTime=120
  37. #commitLog每个文件的大小默认1G
  38. mapedFileSizeCommitLog=1073741824
  39. #ConsumeQueue每个文件默认存30W条,根据业务情况调整
  40. mapedFileSizeConsumeQueue=50000000
  41. destroyMapedFileIntervalForcibly=120000
  42. redeleteHangedFileInterval=120000
  43. #检测物理文件磁盘空间
  44. diskMaxUsedSpaceRatio=88
  45. #存储路径
  46. storePathRootDir=/opt/servers/rocketmq/data
  47. #commitLog 存储路径
  48. storePathCommitLog=/opt/servers/rocketmq/data/commitlog
  49. #消费队列存储路径存储路径
  50. storePathConsumeQueue=/opt/servers/rocketmq/data/consumequeue
  51. #消息索引存储路径
  52. storePathIndex=/opt/servers/rocketmq/data/index
  53. #checkpoint 文件存储路径
  54. storeCheckpoint=/opt/servers/rocketmq/data/checkpoint
  55. #abort 文件存储路径
  56. abortFile=/opt/servers/rocketmq/data/abort
  57. #限制的消息大小
  58. #maxMessageSize=65536
  59. maxMessageSize=5242880
  60. #flushCommitLogLeastPages=4
  61. #flushConsumeQueueLeastPages=2
  62. #flushCommitLogThoroughInterval=10000
  63. #flushConsumeQueueThoroughInterval=60000
  64. #Broker 的角色
  65. #- ASYNC_MASTER 异步复制Master
  66. #- SYNC_MASTER 同步双写Master
  67. #- SLAVE
  68. brokerRole=ASYNC_MASTER
  69. #刷盘方式
  70. #- ASYNC_FLUSH 异步刷盘
  71. #- SYNC_FLUSH 同步刷盘
  72. flushDiskType=ASYNC_FLUSH
  73. #checkTransactionMessageEnable=false
  74. #发消息线程池数量
  75. sendMessageThreadPoolNums=128
  76. #拉消息线程池数量
  77. pullMessageThreadPoolNums=128

同步目录 /opt/servers/rocketmq-3.4.6  到hadoop002;

在hadoop001上启动NamesrvStartup:

nohup sh runserver.sh com.alibaba.rocketmq.namesrv.NamesrvStartup &

在hadoop001上启动BrokerStartup:

nohup sh mqbroker autoCreateTopicEnable=true -c /opt/servers/rocketmq/devenv/conf/2m-noslave/broker-a.properties &

在hadoop002上启动NamesrvStartup:

nohup sh runserver.sh com.alibaba.rocketmq.namesrv.NamesrvStartup &

在hadoop002上启动BrokerStartup:

nohup sh mqbroker autoCreateTopicEnable=true -c /opt/servers/rocketmq/devenv/conf/2m-noslave/broker-b.properties &

在hadoop002上启动console:
vi  /opt/servers/rocketmq/rocketmq-externals-master/rocketmq-console/target/runconsole.sh
 

java -jar rocketmq-console-ng-1.0.0.jar --server.port=12581 --rocketmq.config.namesrvAddr=hadoop001:9876;hadoop002:9876

sh runconsole.sh

使用外网ip:12581 打开console界面

其他找运维人员设置相应的网络访问策略。

安装完成。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/578028
推荐阅读
  

闽ICP备14008679号