1、RocketMQ安装
下载地址:https://archive.apache.org/dist/rocketmq/4.3.2/rocketmq-all-4.3.2-bin-release.zip 在这里安装的是4.3.2版本的
1.1、非Docker安装
1.1.1、上传安装包
1.1.2、解压安装包
unzip rocketmq-all-4.3.2-bin-release.zip
1.1.3、启动nameserver 需要jdk环境(jdk安装)
bin/mqnamesrv
1.1.4、启动nameserver成功
1.1.5、启动broker
bin/mqbroker -n 192.168.10.100:9876
-n 指定nameserver地址和端口
1.1.6、启动broker出错
启动错误,是因为内存不够,导致启动失败,原因:RocketMQ的配置默认是生产环境的配置,设置的jvm的内存大小值比较大,对于学习而言没有必要设置这么大,测试环境的内存往往都不是很大,所以需要调整默认值。
1.1.6.1、修改runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
1.1.6.2、修改runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms128M -Xmx128M -Xmn128M"
1.1.7、启动broker成功
1.1.8、测试
export NAMESRV_ADDR=127.0.0.1:9876
cd bin
sh tools.sh org.apache.rocketmq.example.quickstart.Producer
发送消息成功
sh tools.sh org.apache.rocketmq.example.quickstart.Consumer
消费消息成功
1.2、Docker安装
1.2.1、拉取镜像
sudo docker pull foxiswho/rocketmq:server-4.3.2
sudo docker pull foxiswho/rocketmq:broker-4.3.2
1.2.2、创建nameserver容器
sudo docker create -p 9876:9876 --name rmqserver -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" -e "JAVA_OPTS=-Duser.home=/opt" -v /opt/model/rocketmq-4.3.2/bin/logs:/opt/logs -v /opt/model/rocketmq-4.3.2/bin/store:/opt/store foxiswho/rocketmq:server-4.3.2
1.2.3、创建broker容器
/opt/model/rocketmq-4.3.2/bin/conf/broker.conf的配置
brokerIP1=192.168.10.100
namesrvAddr=192.168.10.100:9876
brokerName=broker_song_im
sudo docker create -p 10911:10911 -p 10909:10909 --name rmqbroker -e "JAVA_OPTS=-Duser.home=/opt" -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" -v /opt/model/rocketmq-4.3.2/bin/conf/broker.conf:/etc/rocketmq/broker.conf -v /opt/model/rocketmq-4.3.2/bin/logs:/opt/logs -v //opt/model/rocketmq-4.3.2/bin/store:/opt/store foxiswho/rocketmq:broker-4.3.2
1.2.4、启动容器
sudo docker start rmqserver rmqbroker
1.2.5、停止删除容器
sudo docker stop rmqbroker rmqserver
sudo docker rm rmqbroker rmqserver
1.2.6、docker安装Rocketmq的管理工具
1.2.6.1 拉取镜像
sudo docker pull styletang/rocketmq-console-ng:1.0.0
1.2.6.2 创建并启动容器
sudo docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.10.100:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t styletang/rocketmq-console-ng:1.0.0
1.2.6.3 页面查看
http://192.168.10.100:8082/
|