1.官网下载安装包
版本选择4.4.0,基于下面的版本去选择,版本高,问题也多。先搞个稳定的版本,用的人多,遇到问题好解决(不是没用过高版本,问题太多,服务器软件需要全部重装,太麻烦了),基本的数据验证使用够用了。
2.上传到服务器
3.解压到指定目录
[root@rhel soft]# unzip rocketmq-all-4.4.0-bin-release.zip -d /usr/local
4.进入解压目录
[root@rhel local]# cd rocketmq-all-4.4.0-bin-release/
[root@rhel rocketmq-all-4.4.0-bin-release]# ll
total 40
drwxr-xr-x 2 root root 83 Jan 17 2019 benchmark
drwxr-xr-x 2 root root 4096 Jan 17 2019 bin
drwxr-xr-x 5 root root 4096 Jan 17 2019 conf
drwxr-xr-x 2 root root 4096 Jan 17 2019 lib
-rw-r--r-- 1 root root 17336 Jan 17 2019 LICENSE
-rw-r--r-- 1 root root 1337 Jan 17 2019 NOTICE
-rw-r--r-- 1 root root 2481 Jan 17 2019 README.md
#目录介绍
* benchmark:demo测试脚本
* bin:启动脚本,包括shell脚本和CMD脚本
* conf:实例配置文件 ,包括broker配置文件、logback配置文件等
* lib:依赖jar包,包括Netty、commons-lang、FastJSON等
5.启动RocketMQ
启动NameServer
# 在bin目录下执行该命令
# 1.启动NameServer
[root@rhel bin]# nohup sh mqnamesrv &
[1] 18237
nohup: ignoring input and appending output to 'nohup.out'
# 2.查看启动日志
[root@rhel bin]# tail -f ~/logs/rocketmqlogs/namesrv.log
at org.apache.rocketmq.remoting.netty.NettyRemotingServer.<init>(NettyRemotingServer.java:150) [rocketmq-remoting-4.4.0.jar:4.4.0]
at org.apache.rocketmq.namesrv.NamesrvController.initialize(NamesrvController.java:80) [rocketmq-namesrv-4.4.0.jar:4.4.0]
at org.apache.rocketmq.namesrv.NamesrvStartup.start(NamesrvStartup.java:140) [rocketmq-namesrv-4.4.0.jar:4.4.0]
at org.apache.rocketmq.namesrv.NamesrvStartup.main0(NamesrvStartup.java:58) [rocketmq-namesrv-4.4.0.jar:4.4.0]
at org.apache.rocketmq.namesrv.NamesrvStartup.main(NamesrvStartup.java:51) [rocketmq-namesrv-4.4.0.jar:4.4.0]
2024-06-16 22:39:48 INFO NettyEventExecutor - NettyEventExecutor service started
2024-06-16 22:39:48 INFO FileWatchService - FileWatchService service started
2024-06-16 22:39:48 INFO main - The Name Server boot success. serializeType=JSON
2024-06-16 22:40:48 INFO NSScheduledThread1 - --------------------------------------------------------
2024-06-16 22:40:48 INFO NSScheduledThread1 - configTable SIZE: 0
启动Broker
# 1.启动Broker
[root@rhel bin]# nohup sh mqbroker -n rhel:9876 &
[3] 18689
nohup: ignoring input and appending output to 'nohup.out'
# 2.查看启动日志
[root@rhel bin]# tail -f ~/logs/rocketmqlogs/broker.log
2024-06-16 22:48:21 WARN main - Load default discard message hook service: DefaultTransactionalMessageCheckListener
2024-06-16 22:48:21 INFO main - The broker dose not enable acl
2024-06-16 22:48:21 INFO FileWatchService - FileWatchService service started
2024-06-16 22:48:21 INFO PullRequestHoldService - PullRequestHoldService service started
2024-06-16 22:48:21 INFO brokerOutApi_thread_1 - register broker to name server rhel:9876 OK
2024-06-16 22:48:21 INFO main - Start transaction service!
2024-06-16 22:48:21 INFO main - The broker[rhel, 192.168.45.88:10911] boot success. serializeType=JSON and name server is rhel:9876
2024-06-16 22:48:31 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2024-06-16 22:48:31 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2024-06-16 22:48:31 INFO brokerOutApi_thread_2 - register broker to name server rhel:9876 OK
# 启动成功用 jps验证
[root@rhel bin]# pwd
/usr/local/rocketmq-all-4.4.0-bin-release/bin
[root@rhel bin]# jps
1621 activemq.jar
18869 Jps
18249 NamesrvStartup
18702 BrokerStartup
[root@rhel bin]#
#因为我的电脑内存为32G,所以之前安装虚拟机服务器的时候,内存配的为8G,所以不用修改JVM内存大小
#RocketMQ默认的虚拟机内存较大,为下面的配置,默认内存就是8G
JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
#RocketMQ默认的虚拟机内存较大,启动Broker如果因为内存不足失败,需要编辑如下两个配置文件,修改JVM内存大小
# 编辑runbroker.sh和runserver.sh修改默认JVM大小
vim runbroker.sh
vim runserver.sh
# 参考设置:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
6.关闭RocketMQ
# 1.关闭NameServer
sh mqshutdown namesrv
# 2.关闭Broker
sh mqshutdown broker