rocketmq集群安装部署过程(4.0.0版本)、安装中的常见问题举例
本篇博文參考:http://www.cnblogs.com/quchunhui/p/7126868.html,然后按照自己的環境進行重新編寫
準備工作:
下載rocketmq-all-4.0.0-incubating-bin-release.zip,下載地址:http://rocketmq.apache.org/dowloading/releases/
3個虛擬節點的構成如下:
安裝步驟
| 下載安裝包 | 從Apache RocketMq官網上下載安裝包 | http://rocketmq.apache.org/dowloading/releases/ |
| 上傳并解壓 | 使用XFTP工具,將安裝包上傳至服務器 | |
| 編寫配置文件 | 完成各節點的配置文件修改 | http://rocketmq.apache.org/docs/rmq-deployment/ |
| 集群配置 | 啟動rocketmq集群 | |
| 集群驗證 | 驗證rocketmq集群是否正常 |
操作過程
1、安裝包已經上傳至其中3個節點:
hadoop11,hadoop12,hadoop13都執行以下命令:
unzip rocketmq-all-4.0.0-incubating-bin-release.zip [root@hadoop11 software]# pwd /home/tuzq/software 修改文件夾名稱: [root@hadoop11 software]# mv apache-rocketmq-all/ rocketmq查看最終的效果:
2、修改配置文件
我這里已經將配置文件提前準備好了,只呈現以下配置文件的結果。
節點1(192.168.106.101)配置文件:
配置文件放在:/home/tuzq/software/rocketmq/conf中
文件名稱是:broker-a-m.properties
文件中的內容如下:
brokerClusterName=post brokerName=broker-a namesrvAddr=192.168.106.101:9876;192.168.106.102:9876 brokerId=0 listenPort=10911 brokerIP1=192.168.106.101 deleteWhen=04 fileReservedTime=72 brokerRole=ASYNC_MASTER storePathRootDir=/home/tuzq/software/rocketmq/rootdir storePathCommitLog=/home/tuzq/software/rocketmq/commitlog defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true flushDiskType=ASYNC_FLUSH vim broker-c-s.properties文件的內容是:
brokerClusterName=post brokerName=broker-c namesrvAddr=192.168.106.101:9876;192.168.106.102:9876 brokerId=1 listenPort=10920 brokerIP1=192.168.106.101 deleteWhen=04 fileReservedTime=72 brokerRole=SLAVE storePathRootDir=/home/tuzq/software/rocketmq/rootdir storePathCommitLog=/home/tuzq/software/rocketmq/commitlog defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true flushDiskType=ASYNC_FLUSH節點2(192.168.106.102)配置文件:
cd /home/tuzq/software/rocketmq/conf vim broker-a-s.properties brokerClusterName=post brokerName=broker-a namesrvAddr=192.168.106.101:9876;192.168.106.102:9876 brokerId=1 listenPort=10920 deleteWhen=04 brokerIP1=192.168.106.102 fileReservedTime=72 brokerRole=SLAVE storePathRootDir=/home/tuzq/software/rocketmq/rootdir storePathCommitLog=/home/tuzq/software/rocketmq/commitlog defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true flushDiskType=ASYNC_FLUSH vim broker-b-m.properties文件內容是:
brokerClusterName=post brokerName=broker-b namesrvAddr=192.168.106.101:9876;192.168.106.102:9876 brokerId=0 listenPort=10911 brokerIP1=192.168.106.102 deleteWhen=04 fileReservedTime=72 brokerRole=ASYNC_MASTER storePathRootDir=/home/tuzq/software/rocketmq/rootdir storePathCommitLog=/home/tuzq/software/rocketmq/commitlog defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true flushDiskType=ASYNC_FLUSH節點3(192.168.106.103)配置文件:
cd /home/tuzq/software/rocketmq/conf vim broker-b-s.properties文件內容是:
brokerClusterName=post brokerName=broker-b namesrvAddr=192.168.106.101:9876;192.168.106.102:9876 brokerId=1 listenPort=10920 brokerIP1=192.168.106.103 deleteWhen=04 fileReservedTime=72 brokerRole=SLAVE storePathRootDir=/home/tuzq/software/rocketmq/rootdir storePathCommitLog=/home/tuzq/software/rocketmq/commitlog defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true flushDiskType=ASYNC_FLUSH vim broker-c-m.properties文件內容是:
brokerClusterName=post brokerName=broker-c namesrvAddr=192.168.106.101:9876;192.168.106.102:9876 brokerId=0 listenPort=10911 brokerIP1=192.168.106.103 deleteWhen=04 fileReservedTime=72 brokerRole=ASYNC_MASTER storePathRootDir=/home/tuzq/software/rocketmq/rootdir storePathCommitLog=/home/tuzq/software/rocketmq/commitlog defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true flushDiskType=ASYNC_FLUSH3、啟動nameserver
三臺機器上都創建logs文件夾(rocketmq中沒有這個logs文件夾):
創建文件夾命令:
節點1和節點2的啟動命令:
nohup sh /home/tuzq/software/rocketmq/bin/mqnamesrv >/home/tuzq/software/rocketmq/logs/mqnamesrv.log 2>&1 &注意:我這里將啟動日志重定義到了logs路徑下,需要提前手動創建logs文件夾,以便于統一管理日志,方便查看。
下圖中展示了啟動命令,日志中可以看到NameServer成功啟動的日志。
NameServer - 節點1
請注意hostname,下面是hadoop11
截圖如下:
在下面的演示過程中將不再進行截圖,所有的過程都把代碼粘貼出來,在進行查看的時候注意機器的hostname
NameServer = 節點2
[root@hadoop12 rocketmq]# nohup sh /home/tuzq/software/rocketmq/bin/mqnamesrv >/home/tuzq/software/rocketmq/logs/mqnamesrv.log 2>&1 & [1] 9558 [root@hadoop12 rocketmq]# cat /home/tuzq/software/rocketmq/logs/mqnamesrv.log nohup: 忽略輸入 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=320m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. The Name Server boot success. serializeType=JSON [root@hadoop12 rocketmq]#在節點1和節點2上分別執行jps命令,可以看到類似如下的結果:
[root@hadoop11 conf]# jps 9682 NamesrvStartup 9774 Jps4、啟動Broker-a(Master位于節點1、Slave位于節點2)
broker-a分為Master和slave,分別位于節點1和節點2上,需要分別啟動。
注意:需要根據啟動角色,為broker指定一個配置文件
在執行下面的命令前,先修改文件路徑:{ROCKET_HOME}/bin/runbroker.sh中的JVM參數配置,如若不改,將會因為內存不夠啟動不了broker.
修改前:JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g" 修改后:JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx512m -Xmn512m -XX:PermSize=256m -XX:MaxPermSize=640m"如圖所示:
broker-a的master - 節點1
命令:
broker-a的slave - 節點2:
命令如下:
驗證broker-a:
broker-a啟動結束,這時候可以使用命令查看一下rocketmq集群狀態:
命令:
5、啟動broker-b(Master位于節點2、slave位于節點3)
broker-b的Master - 節點2
[root@hadoop12 bin]# nohup sh /home/tuzq/software/rocketmq/bin/mqbroker -c /home/tuzq/software/rocketmq/conf/broker-b-m.properties >/home/tuzq/software/rocketmq/logs/broker-b-m.log 2>&1 & [3] 10175 [root@hadoop12 bin]# jps 10182 BrokerStartup 9564 NamesrvStartup 9933 BrokerStartup 10238 Jps [root@hadoop12 bin]# cat /home/tuzq/software/rocketmq/logs/broker-b-m.log nohup: 忽略輸入 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=640m; support was removed in 8.0 [root@hadoop12 bin]#broker-b的slave - 節點3:
[root@hadoop13 bin]# nohup sh /home/tuzq/software/rocketmq/bin/mqbroker -c /home/tuzq/software/rocketmq/conf/broker-b-s.properties >/home/tuzq/software/rocketmq/logs/broker-b-s.log 2>&1 & [1] 9953 [root@hadoop13 bin]# jps 9969 Jps 9960 BrokerStartup [root@hadoop13 bin]# cat /home/tuzq/software/rocketmq/logs/broker-b-s.log nohup: 忽略輸入 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=640m; support was removed in 8.0 [root@hadoop13 bin]#驗證broker-b
[root@hadoop13 bin]# sh /home/tuzq/software/rocketmq/bin/mqadmin clusterList -n 192.168.106.101: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 post broker-a 0 192.168.106.101:10911 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419078.98 -1.0000 post broker-a 1 192.168.106.102:10920 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419078.98 0.1532 post broker-b 0 192.168.106.102:10911 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419078.98 0.1532 post broker-b 1 192.168.106.103:10920 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419078.98 0.0190 [root@hadoop13 bin]#6、啟動broker-b(Master位于節點3,Slave位于節點1)
broker-c的Master - 節點3
[root@hadoop13 bin]# nohup sh /home/tuzq/software/rocketmq/bin/mqbroker -c /home/tuzq/software/rocketmq/conf/broker-c-m.properties >/home/tuzq/software/rocketmq/logs/broker-b-s.log 2>&1 & [2] 10201 [root@hadoop13 bin]# cat /home/tuzq/software/rocketmq/logs/broker-b-s.log nohup: 忽略輸入 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=640m; support was removed in 8.0 [root@hadoop13 bin]#broker-c的Slave - 節點1
[root@hadoop11 bin]# nohup sh /home/tuzq/software/rocketmq/bin/mqbroker -c /home/tuzq/software/rocketmq/conf/broker-c-s.properties >/home/tuzq/software/rocketmq/logs/broker-a-m.log 2>&1 & [3] 10458 [root@hadoop11 bin]# jps 10465 BrokerStartup 9682 NamesrvStartup 10519 Jps 10088 BrokerStartup [root@hadoop11 bin]# cat /home/tuzq/software/rocketmq/logs/broker-a-m.log nohup: 忽略輸入 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=640m; support was removed in 8.0 [root@hadoop11 bin]#驗證broker-c
[root@hadoop11 bin]# sh /home/tuzq/software/rocketmq/bin/mqadmin clusterList -n 192.168.106.101: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 post broker-a 0 192.168.106.101:10911 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419079.12 0.0203 post broker-a 1 192.168.106.102:10920 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419079.12 0.1532 post broker-b 0 192.168.106.102:10911 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419079.12 0.1532 post broker-b 1 192.168.106.103:10920 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419079.12 0.0190 post broker-c 0 192.168.106.103:10911 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419079.12 0.0190 post broker-c 1 192.168.106.101:10920 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 419079.12 0.0203 [root@hadoop11 bin]#7、常見問題
問題1
啟動broker的時候提示內存不夠的錯誤
解決方法:由于個人電腦配置不夠,無法為虛擬機申請更大的內存。所以,采用修改broker啟動內存的方式解決了。
修改文件路徑:{ROCKET_HOME}/bin/runbroker.sh
修改前:JAVA_OPT=”JAVAOPT?server?Xms8g?Xmx8g?Xmn4g”修改后:JAVAOPT=”{JAVA_OPT} -server -Xms256m -Xmx512m -Xmn512m -XX:PermSize=256m -XX:MaxPermSize=640m”
如圖所示:
重新啟動broker,日志中沒有錯誤,jps進程中也可以看到broker正常啟動。
問題2
在同一臺機器上啟動多個broker的時候提示如下錯誤:
問題原因:
按照本文最開始的圖所示,同一臺機器上會存在兩個Broker,如果不進行特殊指定,broker的默認端口是10911
所以一臺機器上啟動兩個broker時,第二個broker就會出現端口被占用的錯誤。
解決辦法:
修改rocketmq的配置文件,增加listenPort配置。配置之后如下所示:
同一臺機器的配置文件:
–>broker-a-m.properties
–>broker-c-s.properties
使用JPS查看一下進程是否有問題
在查看一下啟動日志是否有問題
最后使用clusterList命令來驗證一下集群健康狀態
命令:sh bin/mqadmin clusterList -n 192.168.106.101:9876
成功實現了,如本文最開始圖片所示的安裝部署
總結
以上是生活随笔為你收集整理的rocketmq集群安装部署过程(4.0.0版本)、安装中的常见问题举例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Jetty在win10上的配置,IDEA
- 下一篇: RocketMq案例,生产者,消费者,消