maven安装
cd /data/
wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
tar xf apache-maven-3.1.1-bin.tar.gz -C /usr/local/
cd /usr/local
mv apache-maven-3.1.1 maven3
vim /etc/profile
source /etc/profile
mvn -v
选择git代码下载目录,拉取源代码(可以拉取当前最新版本的分支:release-4.1.0-incubating)
git clone -b release-4.1.0-incubating https://github.com/apache/incubator-rocketmq.git
cd incubator-rocketmq
mvn -Prelease-all -DskipTests clean install -U (使用maven编译,下载jar包等待编译成功)
切换到编译完成的目录的bin目录准备启动服务器
cd distribution/target/apache-rocketmq/bin
启动命令,并且常驻内存:nohup sh mqnamesrv &
查看启动日志能看到:The Name Server boot success字样则成功: tail -f ~/logs/rocketmqlogs/namesrv.log
启动命令,并且常驻内存
nohup sh /incubator-rocketmq/distribution/target/apache-rocketmq/bin/mqnamesrv &
启动命令,并且常驻内存:注意ip地址要配置成为服务的ip地址,保证地址以及端口能够访问
nohup sh mqbroker -n "10.0.2.121:9876" -c /incubator-rocketmq/distribution/target/apache-rocketmq/conf/2m-noslave/broker-a.properties > broker.out &
停止broker服务:sh mqshutdown broker (在/data/incubator-rocketmqdistribution/target/apache-rocketmq/目录下执行)
停止nameserver服务:sh mqshutdown namesrv
在bin目录下面执行,将服务器地址引入到环境变量中 : export NAMESRV_ADDR=10.0.2.121:9876
通过java代码实现的案例生产者生产消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
通过java代码实现案例消费者消费消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
调用命令监控在target的bin目录下
sh mqadmin clusterList -n 10.0.2.121:9876