RocketMQ实践-Linux环境安装

RocketMQ实践-Linux环境安装

RocketMQ安装有两种方式,一种是源码安装,一种则是直接下载binary版本进行安装,我为了省事,便选择了后者

运行`RocketMQ需要安装JDK1.8,这里我直接安装OpenJDK

1
yum install java-1.8.0-openjdk
1
2
3
4
[root@instance-epknpagk ~]# java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)

接着下载RocketMQ, 在Linux执行

1
wget https://dlcdn.apache.org/rocketmq/4.9.4/rocketmq-all-4.9.4-bin-release.zip

但是,这种方式可能非常慢,一个31M的文件,居然要下载几个小时,不得已,我只有用迅雷下载好rocketmq-all-4.9.4-bin-release.zip,然后再上传到Linux服务器上。

接下来解压zip文件

1
unzip rocketmq-all-4.9.4-bin-release.zip

然后进入到解压目录,执行

1
nohup sh bin/mqnamesrv &

然后通过tail -f ~/logs/rocketmqlogs/namesrv.log查看启动日志

1
2
3
4
5
6
7
8
9
10
11
12
[root@instance-epknpagk rocketmq-all-4.9.4-bin-release]# tail -f ~/logs/rocketmqlogs/namesrv.log
2022-08-19 11:18:31 INFO main - tls.client.authServer = false
2022-08-19 11:18:31 INFO main - tls.client.trustCertPath = null
2022-08-19 11:18:31 INFO main - Using JDK SSL provider
2022-08-19 11:18:31 INFO main - SSLContext created for server
2022-08-19 11:18:32 INFO main - Try to start service thread:FileWatchService started:false lastThread:null
2022-08-19 11:18:32 INFO NettyEventExecutor - NettyEventExecutor service started
2022-08-19 11:18:32 INFO main - The Name Server boot success. serializeType=JSON
2022-08-19 11:18:32 INFO FileWatchService - FileWatchService service started
2022-08-19 11:19:31 INFO NSScheduledThread1 - --------------------------------------------------------
2022-08-19 11:19:31 INFO NSScheduledThread1 - configTable SIZE: 0

如果有The Name Server boot success的字眼,表示我们启动成功

然后启动Broker

1
nohup sh bin/mqbroker -n localhost:9876 &

这时候,如果服务器的内存比较小的话,会卡死,因为,Broker默认启动的JVM内存配置得较高,这个需要根据实际情况去调整一下runbroker.sh,启动起来后,再通过tail -f ~/logs/rocketmqlogs/broker.log 来查看日志

1
2
3
4
5
6
7
8
9
10
11
12
[root@instance-epknpagk rocketmq-all-4.9.4-bin-release]# tail -f ~/logs/rocketmqlogs/broker.log
2022-08-19 14:52:34 INFO main - Try to start service thread:FileWatchService started:false lastThread:null
2022-08-19 14:52:34 INFO FileWatchService - FileWatchService service started
2022-08-19 14:52:34 INFO main - Try to start service thread:PullRequestHoldService started:false lastThread:null
2022-08-19 14:52:34 INFO PullRequestHoldService - PullRequestHoldService service started
2022-08-19 14:52:34 INFO main - Try to start service thread:TransactionalMessageCheckService started:false lastThread:null
2022-08-19 14:52:34 INFO brokerOutApi_thread_1 - register broker[0]to name server localhost:9876 OK
2022-08-19 14:52:34 INFO main - The broker[instance-epknpagk, 172.16.19.64:10911] boot success. serializeType=JSON and name server is localhost:9876
2022-08-19 14:52:44 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2022-08-19 14:52:44 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2022-08-19 14:52:44 INFO brokerOutApi_thread_2 - register broker[0]to name server localhost:9876 OK

至此,RocketMQNameServerBroker便启动好了,我们再来安装一个RocketMQ的扩展项目Apache RocketMQ Dashboard。我先下载源码,修改appliction.properties中的rocketmq.config.namesrvAddr值,这里我设置为localhost:9876,然后在本地执行mvn clean package -Dmaven.test.skip=true进行编译,将编译好的jar包上传至服务端执行nohup java -jar rocketmq-dashboard-1.0.0.jar &运行即可,

RocketMQ实践-Linux环境安装

https://blogs.52fx.biz/posts/730051435.html

作者

eyiadmin

发布于

2022-08-19

更新于

2024-05-31

许可协议

评论