### rocketmq4.5.1 链接:https://pan.baidu.com/s/1H1XikPavLecCCd9ZBeQLVw 提取码:fh27 ### 安装前置条件 ``` [root@localhost ~]# systemctl stop firewalld [root@localhost ~]# systemctl disable firewalld killall命令安装 [root@localhost ~]# yum install -y psmisc [root@localhost ~]# yum install -y ntpdate [root@localhost ~]# ntpdate cn.pool.ntp.org [root@localhost ~]# mkdir /app [root@localhost app]# cd /app ``` ### 下载编译安装 ``` [root@localhost app]# wget https://archive.apache.org/dist/rocketmq/4.5.1/rocketmq-all-4.5.1-source-release.zip [root@localhost app]# unzip rocketmq-all-4.5.1-source-release.zip [root@localhost app]# rm -rf rocketmq-all-4.5.1-source-release.zip [root@localhost app]# cd rocketmq-all-4.5.1/ [root@localhost app]# chmod -R 777 * [root@localhost app]# mv rocketmq-all-4.5.1 apache-rocketmq [root@localhost app]# cd apache-rocketmq [root@localhost apache-rocketmq]# mvn -Prelease-all -DskipTests clean install -U ``` ![](https://img.kancloud.cn/12/b7/12b7e835e2f05bf7b3064847538d569b_1849x898.png) ### 启动mqnamesrv 前置条件 [root@localhost rocketmq-4.5.1]# cd /app/apache-rocketmq/distribution/target/rocketmq-4.5.1/rocketmq-4.5.1 [root@localhost rocketmq-4.5.1]# vi bin/runserver.sh ![](https://img.kancloud.cn/2e/73/2e737fd043bb3ea7d1d08ac239e70f75_1869x878.png) ### 启动mqnamesrv ``` [root@localhost rocketmq-4.5.1]# cd /app/apache-rocketmq/distribution/target/rocketmq-4.5.1/rocketmq-4.5.1 [root@localhost rocketmq-4.5.1]# sh bin/mqnamesrv 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 ctrl +c 中断 [root@localhost rocketmq-4.5.1]# cd /app/apache-rocketmq/distribution/target/rocketmq-4.5.1/rocketmq-4.5.1 [root@localhost rocketmq-4.5.1]# nohup sh bin/mqnamesrv & [root@localhost rocketmq-4.5.1]# jps 3336 NamesrvStartup ``` ### 查看mqnamesrv ``` [root@localhost rocketmq-4.5.1]# sh ./bin/mqnamesrv -p 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. 21:35:55.144 [main] INFO RocketmqNamesrvConsole - rocketmqHome=/app/apache-rocketmq/distribution/target/apache-rocketmq 21:35:55.151 [main] INFO RocketmqNamesrvConsole - kvConfigPath=/root/namesrv/kvConfig.json 21:35:55.152 [main] INFO RocketmqNamesrvConsole - configStorePath=/root/namesrv/namesrv.properties 21:35:55.152 [main] INFO RocketmqNamesrvConsole - productEnvName=center 21:35:55.152 [main] INFO RocketmqNamesrvConsole - clusterTest=false 21:35:55.152 [main] INFO RocketmqNamesrvConsole - orderMessageEnable=false 21:35:55.153 [main] INFO RocketmqNamesrvConsole - listenPort=9876 21:35:55.153 [main] INFO RocketmqNamesrvConsole - serverWorkerThreads=8 21:35:55.153 [main] INFO RocketmqNamesrvConsole - serverCallbackExecutorThreads=0 21:35:55.153 [main] INFO RocketmqNamesrvConsole - serverSelectorThreads=3 21:35:55.153 [main] INFO RocketmqNamesrvConsole - serverOnewaySemaphoreValue=256 21:35:55.153 [main] INFO RocketmqNamesrvConsole - serverAsyncSemaphoreValue=64 21:35:55.153 [main] INFO RocketmqNamesrvConsole - serverChannelMaxIdleTimeSeconds=120 21:35:55.154 [main] INFO RocketmqNamesrvConsole - serverSocketSndBufSize=65535 21:35:55.154 [main] INFO RocketmqNamesrvConsole - serverSocketRcvBufSize=65535 21:35:55.154 [main] INFO RocketmqNamesrvConsole - serverPooledByteBufAllocatorEnable=true 21:35:55.154 [main] INFO RocketmqNamesrvConsole - useEpollNativeSelector=false ``` ### 启动mqbroker前置条件 ``` [root@localhost conf]# cd /app/apache-rocketmq/distribution/target/rocketmq-4.5.1/rocketmq-4.5.1/conf [root@localhost conf]# vi broker.conf ``` ![](https://img.kancloud.cn/dc/e8/dce88bd13c44aedb9844db6469228391_1039x577.png) ``` [root@localhost conf]# cd /app/apache-rocketmq/distribution/target/rocketmq-4.5.1/rocketmq-4.5.1 [root@localhost rocketmq-4.5.1]# vi bin/runbroker.sh ``` ![](https://img.kancloud.cn/ac/a6/aca6257b1d3648f1c114a05b2cfbe72d_1747x877.png) ### 错误启动mqbroker ``` [root@localhost conf]# cd /app/apache-rocketmq/distribution/target/rocketmq-4.5.1/rocketmq-4.5.1 [root@localhost rocketmq-4.5.1]# sh bin/mqbroker -n localhost:9876 ``` ![](https://img.kancloud.cn/ed/67/ed6779bafdbd1ad1d5a8b7d0001f7bd8_1409x888.png) 发现启动时打印的ip与本地ip不一致,rocketmq多网卡的一个坑,核查多网卡 ![](https://img.kancloud.cn/5d/5a/5d5a3593cd7c4ae9043e80bfcce9db96_989x393.png) ### 正确启动mqbroker ``` [root@localhost rocketmq-4.5.1]# nohup sh bin/mqbroker -n localhost:9876 -c ./conf/broker.conf & [root@localhost rocketmq-4.5.1]# jps 12090 NamesrvStartup 12380 BrokerStartup 12446 Jps ``` ### 查看mqbroker ``` [root@localhost rocketmq-4.5.1]# sh ./bin/mqbroker -m 2019-05-29 21:34:28 INFO main - namesrvAddr=localhost:9876 2019-05-29 21:34:28 INFO main - brokerIP1=192.168.235.170 2019-05-29 21:34:28 INFO main - brokerName=localhost.localdomain 2019-05-29 21:34:28 INFO main - brokerClusterName=DefaultCluster 2019-05-29 21:34:28 INFO main - brokerId=0 2019-05-29 21:34:28 INFO main - autoCreateTopicEnable=true 2019-05-29 21:34:28 INFO main - autoCreateSubscriptionGroup=true 2019-05-29 21:34:28 INFO main - msgTraceTopicName=RMQ_SYS_TRACE_TOPIC 2019-05-29 21:34:28 INFO main - traceTopicEnable=false 2019-05-29 21:34:28 INFO main - rejectTransactionMessage=false 2019-05-29 21:34:28 INFO main - fetchNamesrvAddrByAddressServer=false 2019-05-29 21:34:28 INFO main - transactionTimeOut=6000 2019-05-29 21:34:28 INFO main - transactionCheckMax=15 2019-05-29 21:34:28 INFO main - transactionCheckInterval=60000 2019-05-29 21:34:28 INFO main - aclEnable=false 2019-05-29 21:34:28 INFO main - storePathRootDir=/root/store 2019-05-29 21:34:28 INFO main - storePathCommitLog=/root/store/commitlog 2019-05-29 21:34:28 INFO main - flushIntervalCommitLog=500 2019-05-29 21:34:28 INFO main - commitIntervalCommitLog=200 2019-05-29 21:34:28 INFO main - flushCommitLogTimed=false 2019-05-29 21:34:28 INFO main - deleteWhen=04 2019-05-29 21:34:28 INFO main - fileReservedTime=72 2019-05-29 21:34:28 INFO main - maxTransferBytesOnMessageInMemory=262144 2019-05-29 21:34:28 INFO main - maxTransferCountOnMessageInMemory=32 2019-05-29 21:34:28 INFO main - maxTransferBytesOnMessageInDisk=65536 2019-05-29 21:34:28 INFO main - maxTransferCountOnMessageInDisk=8 2019-05-29 21:34:28 INFO main - accessMessageInMemoryMaxRatio=40 2019-05-29 21:34:28 INFO main - messageIndexEnable=true 2019-05-29 21:34:28 INFO main - messageIndexSafe=false 2019-05-29 21:34:28 INFO main - haMasterAddress= 2019-05-29 21:34:28 INFO main - brokerRole=ASYNC_MASTER 2019-05-29 21:34:28 INFO main - flushDiskType=ASYNC_FLUSH 2019-05-29 21:34:28 INFO main - cleanFileForciblyEnable=true 2019-05-29 21:34:28 INFO main - transientStorePoolEnable=false ``` ### 生产消息 ``` [root@localhost rocketmq-4.5.1]# cd /app/apache-rocketmq/distribution/target/rocketmq-4.5.1/rocketmq-4.5.1 [root@localhost rocketmq-4.5.1]# export NAMESRV_ADDR=localhost:9876 [root@localhost rocketmq-4.5.1]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer ``` ### 消费消息 ``` [root@localhost rocketmq-4.5.1]# export NAMESRV_ADDR=localhost:9876 [root@localhost rocketmq-4.5.1]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer ``` ### 从网盘下载解压到/app启动 ``` 链接:https://pan.baidu.com/s/1H1XikPavLecCCd9ZBeQLVw 提取码:fh27 [root@localhost target]# cd /app/rocketmq-console/target [root@localhost target]# nohup java -jar rocketmq-console-ng-1.0.1.jar --server.port=8080 --rocketmq.config.namesrvAddr=192.168.235.170:9876 & ```