入门安装运行
# 官方文档
前提条件:
- jdk 1.8+
- linux
# 1. Get Apache RocketMQ
download: RocketMQ 5.0+ (opens new window)
unzip rocketmq-all-5.1.3-bin-release.zip
cd rocketmq-all-5.1.3-bin-release
# 2. Start NameServer
### start namesrv
$ nohup sh bin/mqnamesrv &
### verify namesrv
$ tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
2
3
4
5
6
Once we see 'The Name Server boot success..' from namesrv.log, it means the NameServer has been started successfully.
# 3. Start Broker and Proxy
### start broker
$ nohup sh bin/mqbroker -n localhost:9876 --enable-proxy &
### verify broker
$ tail -f ~/logs/rocketmqlogs/proxy.log
The broker[broker-a,192.169.1.2:10911] boot success...
2
3
4
5
6
Once we see “The broker[brokerName,ip:port] boot success..” from proxy.log, it means the Broker has been started successfully.
# 4. Send and Receive Messages with tools
$ export NAMESRV_ADDR=localhost:9876
$ sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= ...
$ sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt...
2
3
4
5
6
# 华仔谈技术
使用机器 linux
前提 : 安装好JDK
关闭防火墙或开放对应的端口
- 下载RocketMQ
https://archive.apache.org/dist/rocketmq/
下载4.9.4为例子:
wget https://archive.apache.org/dist/rocketmq/4.9.4/rocketmq-all-4.9.4-bin-release.zip
unzip rocketmq-all-4.9.4-bin-release.zip
2
3
查看文件目录:
- NameServer
启动NameServer前,若是在本地测试使用,建议调节下jvm启动参数,因为默认的参数比较大,可能会占用大量的空间。
vim bin/runserver.sh
修改如下所示的内容:
可以直接修改为:
-server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=32m -XX:MaxMetaspaceSize=50m
修改完后,直接启动server:
nohup sh bin/mqnamesrv &
启动后,查看对应的日志:
tail -f ~/logs/rocketmqlogs/namesrv.log
成功的日志是这样:
- 启动broker
和上面的方法大概一致,我们也需要修改启动jvm内容
vim bin/runbroker.sh
修改如下的内容:
可以直接修改为:
-server -Xms1g -Xm1g -Xmn512m
接下来,我们要对broker的配置文件进行配置,就像我们配置kafka的配置文件一样。
vim conf/broker.conf
增加一处配置:
namesrvAddr = localhost:9876
修改完成后进行启动:
nohup sh bin/mqbroker -c conf/broker.conf &
启动后可以看看启动日志:
tail -f ~/logs/rocketmqlogs/broker.log
启动后怎么查看rocket进程:
jps
- 关闭rocketmq
bin/mqshutdown broker
bin/mqshutdown namesrv
2
可视化界面:下载一个jar包并启动
https://pan.baidu.com/s/1Yci-Lt5i_fW3plolfG5HNA?pwd=jpr6
使用jdk8启动
nohup java -jar -server -Xms256m -Xmx256m -Drocketmq.config.namesrvAddr=localhost:9876 -Dserver.port=8088 rocketmq-console-ng-1.0.1.jar &
对应的日志存放在:
tail -f ~/logs/consolelogs/rocketmq-console.log
Localhost:8088进入页面