RockerMQ官网:RocketMQ · 官方网站 | RocketMQ
学习任何框架和技术,一定要参考相应的官网学习,一定要参考官网学习!!!
目录
1、拉取RockerMQ镜像
2、创建namesrv服务
3、构建namesrv容器
4、创建broker节点
4.1 创建broker数据数据卷
4.2 创建配置文件
4.3 构建broker容器
5. 创建rockermq-console服务
5.1 拉取rockermq-console镜像
5.2 构建rockermq-console容器
6. 启动mqnamesrv 和 mqbroker
6.1 启动mqnamesrv
6.2 启动mqbroker
7. 查看控制台信息
代码:
docker pull apache/rocketmq
实例:
[root@bogon howlong]# docker pull apache/rocketmq Using default tag: latest latest: Pulling from apache/rocketmq 2d473b07cdd5: Pull complete 81090e03adee: Pull complete 776d9e33cd10: Pull complete bed1c66caddc: Pull complete 85c17169ba0e: Pull complete 9a6e411d34e4: Pull complete 5f5a264462e1: Pull complete edc3f28f57c6: Pull complete 7ba72b0f5ce9: Pull complete 6079e84f1641: Pull complete Digest: sha256:79b41e2956de07c576949bedf8f9bc5eac9f1eeb72362b89ee2344219e5a46b1 Status: Downloaded newer image for apache/rocketmq:latest docker.io/apache/rocketmq:latest [root@bogon howlong]#
创建 namesrv 数据存储路径创建数据卷的目录,即宿主机的目录。这些目录最终要于容器 中的某些目录进 行 关联(挂载)代码:mkdir -p /usr/local/rocketmq/data/namesrv/logs /usr/local/rocketmq/data/namesrv/store
实例:
[root@bogon howlong]# mkdir -p /usr/local/rocketmq/data/namesrv/logs /usr/local/rocketmq/data/namesrv/store [root@bogon howlong]#
代码:
docker run -d \ --restart=always \ --name rmqnamesrv \ --privileged=true \ -p 9876:9876 \ -v /usr/local/rocketmq/data/namesrv/logs:/root/logs \ -v /usr/local/rocketmq/data/namesrv/store:/root/store \ -e "MAX_POSSIBLE_HEAP=100000000" \ -e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" \ apache/rocketmq \ sh mqnamesrv
实例:
[root@bogon howlong]# docker run -d \ --restart=always \ --name rmqnamesrv \ --privileged=true \ -p 9876:9876 \ -v /usr/local/rocketmq/data/namesrv/logs:/root/logs \ -v /usr/local/rocketmq/data/namesrv/store:/root/store \ -e "MAX_POSSIBLE_HEAP=100000000" \ -e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" \ apache/rocketmq \ sh mqnamesrv 627f93f60cc75f0a3d442bc0ddbd02def2c88298f74424893699ab3ee8dc1e56 [root@bogon howlong]#
4.1 创建broker数据数据卷
创建数据卷目录,便 于进 行 数据挂载。挂载的目录是方 便 我们在宿主机上进 行 数据的操作而无须进入到容 器 内部。代码:mkdir -p /usr/local/rocketmq/data/broker/logs /usr/local/rocketmq/data/broker/store /usr/local/rocketmq/conf
实例:
[root@bogon howlong]# mkdir -p /usr/local/rocketmq/data/broker/logs /usr/local/rocketmq/data/broker/store /usr/local/rocketmq/conf [root@bogon howlong]#
4.2 创建配置文件
代码:
vi /usr/local/rocketmq/conf/broker.conf
进入编辑模式,选择插入模式,进行文件配置
配置文件代码:
brokerClusterName = DefaultCluster brokerName = broker-a brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH brokerIP1 = 192.168.27.129 diskMaxUsedSpaceRatio=95
按Esc,:wq,保存退出,即可
4.3 构建broker容器
代码:
docker run -d \ --restart=always \ --name rmqbroker \ --link rmqnamesrv:namesrv \ --privileged=true \ -p 10911:10911 \ -p 10912:10912 \ -p 10909:10909 \ -v /usr/local/rocketmq/data/broker/logs:/root/logs \ -v /usr/local/rocketmq/data/broker/store:/root/store \ -v /usr/local/rocketmq/conf/broker.conf:/home/rocketmq/rocketmq-4.9.4/conf/broker.conf \ -e "NAMESRV_ADDR=namesrv:9876" \ -e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" \ -e "MAX_POSSIBLE_HEAP=200000000" \ apache/rocketmq \ sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf
实例:
[root@bogon conf]# docker run -d \ --restart=always \ --name rmqbroker \ --link rmqnamesrv:namesrv \ --privileged=true \ -p 10911:10911 \ -p 10912:10912 \ -p 10909:10909 \ -v /usr/local/rocketmq/data/broker/logs:/root/logs \ -v /usr/local/rocketmq/data/broker/store:/root/store \ -v /usr/local/rocketmq/conf/broker.conf:/home/rocketmq/rocketmq-4.9.4/conf/broker.conf \ -e "NAMESRV_ADDR=namesrv:9876" \ -e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" \ -e "MAX_POSSIBLE_HEAP=200000000" \ apache/rocketmq \ sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf d4b0dfa8160dcb5a72128ffd361d5edde664acf610fc5356ee94211b667f9a5a [root@bogon howlong]#
5.1 拉取rockermq-console镜像
代码:
docker pull styletang/rocketmq-console-ng
实例:
[root@bogon conf]# docker pull styletang/rocketmq-console-ng Using default tag: latest latest: Pulling from styletang/rocketmq-console-ng e12c678537ae: Pull complete 8d9ed335b7db: Pull complete 3318dd58ae60: Pull complete 624ba6156166: Pull complete c7a02d193df7: Pull complete 813b62320378: Pull complete 49e2d6393f32: Pull complete 0a2b7222259b: Pull complete 478657249124: Pull complete 5f8636e9fbb7: Pull complete Digest: sha256:96e99d10eda871640b9529b75da30fa6ca85fc15722661acb9660639e6904fc3 Status: Downloaded newer image for styletang/rocketmq-console-ng:latest docker.io/styletang/rocketmq-console-ng:latest [root@bogon howlong]#
5.2 构建rockermq-console容器
重点:JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.27.129 中的192.168.27.129是自己的虚拟机IP地址
代码:
docker run -d \ --restart=always \ --name rmqadmin \ -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.27.129:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" \ -p 8081:8080 \ --ulimit nofile=1024 \ styletang/rocketmq-console-ng:latest
实例:
[root@bogon conf]# docker run -d \ --restart=always \ --name rmqadmin \ -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.27.129:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" \ -p 8081:8080 \ --ulimit nofile=1024 \ styletang/rocketmq-console-ng:latest e5c2122ce4e17b30e25d6e99fc1454d041acd2d5e04c38a3fbfe2cd91769e93c [root@bogon howlong]#
6.1 启动mqnamesrv
代码:
docker start mqnamesrv
案例:
[root@bogon howlong]# docker start rmqnamesrv rmqnamesrv
6.2 启动mqbroker
代码:
docker start rmqbroker
案例:
[root@bogon howlong]# docker start rmqbroker rmqbroker
访问虚拟机IP+端口号
比如:192.168.27.129:8081