rabbitmq Or redis 消息通知

rocketMq的安装(mac环境)

2020-02-05  本文已影响0人  滴流乱转的小胖子

一、java环境配置

此处不赘述,请参阅: https://www.cnblogs.com/ostrich-sunshine/p/8414677.html

source ~/.profile

source ~/.bash_profile

source /etc/profile

/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

/usr/libexec/java_home

二、rocketMq 安装

1.解压与编译

unzip rocketmq-all-4.6.0-source-release.zip
cd rocketmq-all-4.6.0/
mvn -Prelease-all -DskipTests clean install -U
cd distribution/target/apache-rocketmq

2.启动Name Server服务

# 1.启动NameServer
nohup sh bin/mqnamesrv &
# 2.查看启动日志
tail -f ~/logs/rocketmqlogs/namesrv.log

输出:The Name Server boot success. 表示成功

3.修改内存大小

RocketMq默认内存较大,启动Borker如果因为内存不足启动失败,需要修改如下配置文件,修改JVM内存大小

改为: JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m"

4.启动borker

# 1.启动Broker
nohup sh bin/mqbroker -n localhost:9876 &
# 2.查看启动日志
tail -f ~/logs/rocketmqlogs/broker.log 

输出: The broker[%s, 172.30.30.233:10911] boot success...

5. 查看是否启动

 ~/Documents/rocketmq  jps
83195 NamesrvStartup
84572 BrokerStartup
86174 Jps

6.关闭rocketMq

# 关闭NameServer
sh bin/mqshutdown namesrv
# 关闭Borker
sh bin/mqshutdown broker

三、测试发送数据与接受数据

最好开两个命令行窗口

source ~/.profile
export NAMESRV_ADDR=localhost:9876
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
source ~/.profile
export NAMESRV_ADDR=localhost:9876
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
上一篇下一篇

猜你喜欢

热点阅读