您好,登錄后才能下訂單哦!
本篇內容主要講解“RokcetMq安裝和快速啟動的方法”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“RokcetMq安裝和快速啟動的方法”吧!
訪問: http://rocketmq.apache.org/dowloading/releases/ 下載最新版本
將下載的最新版本包放在linux服務器,這里以rocketmq-all-4.5.2-bin-release.zip為例;
[jenkins@test01 rocketmq]$ ll 總用量 12296 -rw-r--r--. 1 jenkins jenkins 12589252 10月 22 15:45 rocketmq-all-4.5.2-bin-release.zip [jenkins@test01 rocketmq]$ unzip rocketmq-all-4.5.2-bin-release.zip Archive: rocketmq-all-4.5.2-bin-release.zip creating: rocketmq-all-4.5.2-bin-release/ creating: rocketmq-all-4.5.2-bin-release/benchmark/ inflating: rocketmq-all-4.5.2-bin-release/benchmark/consumer.sh inflating: rocketmq-all-4.5.2-bin-release/benchmark/runclass.sh inflating: rocketmq-all-4.5.2-bin-release/benchmark/tproducer.sh inflating: rocketmq-all-4.5.2-bin-release/benchmark/producer.sh ........
然后參考官網快速啟動文檔: http://rocketmq.apache.org/docs/quick-start/
由于name server和broker默認配置為4g到8g的內存,如果服務器內存不足需要修改默認內存;
解決辦法,找到runserver.sh和runbroker.sh,編輯 JAVA_OPT=”${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m”
[jenkins@test01 rocketmq]$ mv rocketmq-all-4.5.2-bin-release rocketmq-all-4.5.2 [jenkins@test01 rocketmq]$ cd rocketmq-all-4.5.2 [jenkins@test01 rocketmq-all-4.5.2]$ ll 總用量 44 drwxr-xr-x. 2 jenkins jenkins 4096 8月 2 10:05 benchmark drwxr-xr-x. 3 jenkins jenkins 4096 7月 31 21:11 bin drwxr-xr-x. 6 jenkins jenkins 4096 7月 31 21:09 conf drwxr-xr-x. 2 jenkins jenkins 4096 8月 2 10:05 lib -rw-r--r--. 1 jenkins jenkins 17336 7月 31 21:09 LICENSE -rw-r--r--. 1 jenkins jenkins 1338 7月 31 21:09 NOTICE -rw-r--r--. 1 jenkins jenkins 4020 7月 31 21:09 README.md [jenkins@test01 rocketmq-all-4.5.2]$ nohup sh bin/mqnamesrv > mqnamesrv.out & [1] 13179 nohup: 忽略輸入重定向錯誤到標準輸出端 [jenkins@test01 rocketmq-all-4.5.2]$ tail -500f mqnamesrv.out 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
看到The Name Server boot success. serializeType=JSON代表已經部署name server成功。
[jenkins@test01 rocketmq-all-4.5.2]$ nohup sh bin/mqbroker -n 10.130.44.165:9876 > mqbroker.out & [8] 13782 [6] Exit 143 nohup sh bin/mqbroker -n 10.130.44.165:9876 > mqbroker.out [jenkins@test01 rocketmq-all-4.5.2]$ nohup: 忽略輸入重定向錯誤到標準輸出端 [jenkins@test01 rocketmq-all-4.5.2]$ tail -500f mqbroker.out The broker[test01, 10.130.44.165:10911] boot success. serializeType=JSON and name server is 10.130.44.165:9876
看到The broker[test01, 10.130.44.165:10911] boot success代表Broker已啟動,并且已經連接到name server。
先設置 NAMESRV_ADDR環境變量,然后使用消息發送工具
[jenkins@test01 rocketmq-all-4.5.2]$ export NAMESRV_ADDR=localhost:9876 [jenkins@test01 rocketmq-all-4.5.2]$ sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer 14:55:28.799 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. SendResult [sendStatus=SEND_OK, msgId=0A822CA5432112A3A380747FC2A30000, offsetMsgId=0A822CA500002A9F0000000000000000, messageQueue=MessageQueue [topic=TopicTest, brokerName=test01, queueId=0], queueOffset=0] SendResult [sendStatus=SEND_OK, msgId=0A822CA5432112A3A380747FC3120001, offsetMsgId=0A822CA500002A9F00000000000000B2, messageQueue=MessageQueue [topic=TopicTest, brokerName=test01, …………………… SendResult [sendStatus=SEND_OK, msgId=0A822CA5432112A3A380747FD3FD03E7, offsetMsgId=0A822CA500002A9F000000000002BDFE, messageQueue=MessageQueue [topic=TopicTest, brokerName=test01, queueId=3], queueOffset=249] 14:55:34.461 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[127.0.0.1:9876] result: true 14:55:34.470 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[10.130.44.165:10911] result: true [jenkins@test01 rocketmq-all-4.5.2]$
啟動消息接收工具,消息接收工具會一直等待消息發送,不會自動停止
[jenkins@test01 rocketmq-all-4.5.2]$ sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer 14:59:55.032 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework Consumer Started. …………………… ConsumeMessageThread_2 Receive New Messages: [MessageExt [queueId=2, storeSize=180, queueOffset=485, sysFlag=0, bornTimestamp=1571813940924, bornHost=/10.130.44.165:58852, storeTimestamp=1571813940925, storeHost=/10.130.44.165:10911, msgId=0A822CA500002A9F0000000000055334, commitLogOffset=348980, bodyCRC=1786477042, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=500, CONSUME_START_TIME=1571813984202, UNIQ_KEY=0A822CA543EA12A3A3807482FABC03AC, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 57, 52, 48], transactionId='null'}]] ConsumeMessageThread_5 Receive New Messages: [MessageExt [queueId=2, storeSize=180, queueOffset=482, sysFlag=0, bornTimestamp=1571813940894, bornHost=/10.130.44.165:58852, storeTimestamp=1571813940895, storeHost=/10.130.44.165:10911, msgId=0A822CA500002A9F0000000000054AC4, commitLogOffset=346820, bodyCRC=855266886, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=500, CONSUME_START_TIME=1571813984200, UNIQ_KEY=0A822CA543EA12A3A3807482FA9E03A0, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 57, 50, 56], transactionId='null'}]]
至此環境搭建完成,并通過測試。
停止需要先暫停broker,再停止namesrv,具體命令如下:
[jenkins@test01 rocketmq-all-4.5.2]$ sh bin/mqshutdown broker The mqbroker(13790) is running... Send shutdown request to mqbroker(13790) OK [jenkins@test01 rocketmq-all-4.5.2]$ sh bin/mqshutdown namesrv The mqnamesrv(13501) is running... Send shutdown request to mqnamesrv(13501) OK [jenkins@test01 rocketmq-all-4.5.2]$
RocketMq默認日志目錄放在當前用戶的logs目錄下。
[jenkins@test01 rocketmqlogs]$ pwd /home/jenkins/logs/rocketmqlogs [jenkins@test01 rocketmqlogs]$ ll 總用量 31220 -rw-rw-r--. 1 jenkins jenkins 5063 10月 23 17:01 broker_default.log -rw-rw-r--. 1 jenkins jenkins 707575 10月 23 18:26 broker.log -rw-rw-r--. 1 jenkins jenkins 0 10月 22 17:03 commercial.log -rw-rw-r--. 1 jenkins jenkins 0 10月 22 17:03 filter.log -rw-rw-r--. 1 jenkins jenkins 0 10月 22 17:03 lock.log -rw-rw-r--. 1 jenkins jenkins 3157 10月 23 17:00 namesrv_default.log -rw-rw-r--. 1 jenkins jenkins 203504 10月 23 18:21 namesrv.log -rw-rw-r--. 1 jenkins jenkins 0 10月 22 17:03 protection.log -rw-rw-r--. 1 jenkins jenkins 157157 10月 23 18:19 remoting.log -rw-rw-r--. 1 jenkins jenkins 1368353 10月 23 18:19 rocketmq_client.log -rw-rw-r--. 1 jenkins jenkins 194451 10月 23 18:26 stats.log -rw-rw-r--. 1 jenkins jenkins 0 10月 22 17:03 storeerror.log -rw-rw-r--. 1 jenkins jenkins 3510867 10月 23 18:25 store.log -rw-rw-r--. 1 jenkins jenkins 1515006 10月 23 18:25 transaction.log -rw-rw-r--. 1 jenkins jenkins 24251040 10月 23 18:26 watermark.log
到此,相信大家對“RokcetMq安裝和快速啟動的方法”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。