centos7 下 rocketmq 单机版安装



文档:http://rocketmq.apache.org/docs/quick-start/

先决条件

假定已安装以下软件:

  1. 建议使用64位操作系统,建议使用Linux / Unix / Mac;
  2. 64位JDK 1.8+;
  3. Maven 3.2.x;
  4. Git;
  5. 适用于Broker服务器的4g +可用磁盘

下载安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@centos7cz ~]# cd /data/download/
[root@centos7cz download]# wget http://mirror.bit.edu.cn/apache/rocketmq/4.6.0/rocketmq-all-4.6.0-bin-release.zip
[root@centos7cz download]# mkdir -p /data/tools/
[root@centos7cz download]# unzip rocketmq-all-4.6.0-bin-release.zip -d /data/tools
[root@centos7cz download]# tar -zxf rocketmq-all-4.6.0.tar.gz -C /data/tools
[root@centos7cz download]# cd /data/tools/
[root@centos7cz tools]# mv rocketmq-all-4.6.0-bin-release/ rocketmq-all-4.6.0
[root@centos7cz tools]# cd rocketmq-all-4.6.0/
[root@centos7cz rocketmq-all-4.6.0]# ll
total 40
drwxr-xr-x. 2 root root 83 Nov 20 11:04 benchmark
drwxr-xr-x. 3 root root 4096 Aug 19 15:31 bin
drwxr-xr-x. 6 root root 211 Aug 6 16:23 conf
drwxr-xr-x. 2 root root 4096 Nov 20 11:04 lib
-rw-r--r--. 1 root root 17336 Aug 6 16:23 LICENSE
-rw-r--r--. 1 root root 1338 Aug 6 16:23 NOTICE
-rw-r--r--. 1 root root 4225 Nov 1 16:54 README.md
[root@centos7cz rocketmq-all-4.6.0]#

启动和关闭

1
2
3
4
# 安装nohup
[root@centos7cz ~]# yum install coreutils -y

[root@centos7cz ~]# mkdir -p /data/tools/rocketmq-all-4.6.0/logs/

NameSrv

1
2
3
4
5
6
7
[root@centos7cz ~]# cd /data/tools/rocketmq-all-4.6.0

[root@centos7cz rocketmq-all-4.6.0]# nohup sh /data/tools/rocketmq-all-4.6.0/bin/mqnamesrv > /data/tools/rocketmq-all-4.6.0/logs/namesrv.log 2>&1 &

[root@centos7cz rocketmq-all-4.6.0]# tail -f /data/tools/rocketmq-all-4.6.0/logs/namesrv.log

[root@centos7cz rocketmq-all-4.6.0]# /data/tools/rocketmq-all-4.6.0/bin/mqshutdown namesrv

Broker

1
2
3
4
5
6
7
[root@centos7cz ~]# cd /data/tools/rocketmq-all-4.6.0

[root@centos7cz rocketmq-all-4.6.0]# nohup sh /data/tools/rocketmq-all-4.6.0/bin/mqbroker > /data/tools/rocketmq-all-4.6.0/logs/broker.log 2>&1 &

[root@centos7cz rocketmq-all-4.6.0]# tail -f /data/tools/rocketmq-all-4.6.0/logs/broker.log

[root@centos7cz rocketmq-all-4.6.0]# /data/tools/rocketmq-all-4.6.0/bin/mqshutdown broker

收发消息

1
2
3
4
5
6
7
[root@centos7cz ~]# cd /data/tools/rocketmq-all-4.6.0

[root@centos7cz rocketmq-all-4.6.0]# export NAMESRV_ADDR=localhost:9876

[root@centos7cz rocketmq-all-4.6.0]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer

[root@centos7cz rocketmq-all-4.6.0]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer