docker 搭建 RocketMQ docker搭建RocketMQ 可視化界面 ,開啟控制台密碼和acl密碼


1、拉取鏡像

docker pull foxiswho/rocketmq:4.8.0

 

2、創建數據目錄

mkdir -p /home/dockerdata/rocketmq/namesrv/logs
mkdir -p /home/dockerdata/rocketmq/broker/store
mkdir -p /home/dockerdata/rocketmq/broker/logs mkdir -p /home/dockerdata/rocketmq/broker/conf

mkdir -p /home/dockerdata/rocketmq/console/data

cd /home/dockerdata/rocketmq
chmod 777 -R namesrv
chmod 777 -R broker
chmod 777 -R console

3、運行nameServer容器

docker run -d \
--restart=always \ -v /home/dockerdata/rocketmq/namesrv/logs:/home/rocketmq/logs \ --name rmqnamesrv \ -e "JAVA_OPT_EXT=-Xms128M -Xmx512M -Xmn128m" \ -p 9876:9876 \ foxiswho/rocketmq:4.8.0 \ sh mqnamesrv

5、創建配置文件/home/dockerdata/rocketmq/broker/conf/broker.conf  注意綠色文字

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #所屬集群名字 brokerClusterName=DefaultCluster #broker名字,注意此處不同的配置文件填寫的不一樣,如果在broker-a.properties使用:broker-a, #在broker-b.properties使用:broker-b brokerName=broker-a #0 表示Master,>0 表示Slave brokerId=0 #nameServer地址,分號分割 #namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876 namesrvAddr=172.168.1.xxx:9876 #啟動IP,如果 docker 報 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed # 解決方式1 加上一句producer.setVipChannelEnabled(false);,解決方式2 brokerIP1 設置宿主機IP,不要使用docker 內部IP
brokerIP1=172.168.1.xxx
#在發送消息時,自動創建服務器不存在的topic,默認創建的隊列數 defaultTopicQueueNums=4 #是否允許 Broker 自動創建Topic,建議線下開啟,線上關閉 !!!這里仔細看是false,false,false #原因下篇博客見~ 哈哈哈哈 autoCreateTopicEnable=true #是否允許 Broker 自動創建訂閱組,建議線下開啟,線上關閉 autoCreateSubscriptionGroup=true

#此參數控制是否開啟密碼
#aclEnable=true
#Broker 對外服務的監聽端口 listenPort=10911 #刪除文件時間點,默認凌晨4點 deleteWhen=04 #文件保留時間,默認48小時 fileReservedTime=120 #commitLog每個文件的大小默認1G mapedFileSizeCommitLog=1073741824 #ConsumeQueue每個文件默認存30W條,根據業務情況調整 mapedFileSizeConsumeQueue=300000 #destroyMapedFileIntervalForcibly=120000 #redeleteHangedFileInterval=120000 #檢測物理文件磁盤空間 diskMaxUsedSpaceRatio=88 #存儲路徑 #storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store #commitLog 存儲路徑 #storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog #消費隊列存儲 #storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue #消息索引存儲路徑 #storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index #checkpoint 文件存儲路徑 #storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint #abort 文件存儲路徑 #abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort #限制的消息大小 maxMessageSize=65536 #flushCommitLogLeastPages=4 #flushConsumeQueueLeastPages=2 #flushCommitLogThoroughInterval=10000 #flushConsumeQueueThoroughInterval=60000 #Broker 的角色 #- ASYNC_MASTER 異步復制Master #- SYNC_MASTER 同步雙寫Master #- SLAVE brokerRole=ASYNC_MASTER #刷盤方式 #- ASYNC_FLUSH 異步刷盤 #- SYNC_FLUSH 同步刷盤 flushDiskType=ASYNC_FLUSH #發消息線程池數量 #sendMessageThreadPoolNums=128 #拉消息線程池數量 #pullMessageThreadPoolNums=128

6、創建acl文件,用於開啟用戶名密碼,不用用戶密碼可以忽略此步驟 /home/dockerdata/rocketmq/broker/conf/plain_acl.yml

springboot 服務的ip如果在globalWhiteRemoteAddresses白名單中,不會走acl鑒權

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. globalWhiteRemoteAddresses: - 10.10.103.* - 172.168.1.* accounts: - accessKey: RocketMQ secretKey: 12345678 whiteRemoteAddress: admin: false defaultTopicPerm: DENY defaultGroupPerm: SUB topicPerms: - topicA=DENY - topicB=PUB|SUB - topicC=SUB groupPerms: # the group should convert to retry topic - groupA=DENY - groupB=PUB|SUB - groupC=SUB - accessKey: rocketmq2 secretKey: 12345678 whiteRemoteAddress: 172.168.1.* # if it is admin, it could access all resources admin: true

 

7、運行broker,如果報錯,試試把/home/dockerdata/rocketmq/broker/conf/broker.conf 配置文件中的brokerIP1=172.168.1.xxx這個啟用,IP 地址填寫 你docker 所在 宿主機的IP

docker run -d  \
--restart=always \ -v /home/dockerdata/rocketmq/broker/logs:/home/rocketmq/logs \ -v /home/dockerdata/rocketmq/broker/store:/home/rocketmq/store \ -v /home/dockerdata/rocketmq/broker/conf/broker.conf:/home/rocketmq/rocketmq-4.8.0/conf/broker.conf \
-v /home/dockerdata/rocketmq/broker/conf/plain_acl.yml:/home/rocketmq/rocketmq-4.8.0/conf/plain_acl.yml \ --name rmqbroker \ -e "NAMESRV_ADDR=172.168.1.xxx:9876" \ -e "JAVA_OPT_EXT=-Xms128M -Xmx1024M -Xmn128m" \ -p 10911:10911 \ -p 10912:10912 \ -p 10909:10909 \ foxiswho/rocketmq:4.8.0 \ sh mqbroker -c /home/rocketmq/rocketmq-4.8.0/conf/broker.conf 

7、設置管理界面賬號密碼 /home/dockerdata/rocketmq/console/data/users.properties 

# This file supports hot change, any change will be auto-reloaded without Console restarting.
# Format: a user per line, username=password[,N] #N is optional, 0 (Normal User); 1 (Admin) # Define Admin # =============用戶名和密碼規則「用戶名=密碼,權限」,這里的權限為1表示管理員,為0表示普通用戶============= # 例如:admin=admin123,1 admin=123456,1 # Define Users # =============屏蔽下邊兩個賬戶============= #user1=user1 #user2=user2

 

8、運行管理界面(可視化界面)

docker run -d --restart=always --name rmqconsole \
-v /home/dockerdata/rocketmq/console/data:/tmp/rocketmq-console/data \
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.168.1.xxx:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false -Drocketmq.config.loginRequired=true -Drocketmq.config.aclEnabled=true -Drocketmq.config.accessKey=rocketmq2 -Drocketmq.config.secretKey=12345678" \
-p 18180:8080 -t iamverygood/rocketmq-console:4.7.1

rocketmq.config.loginRequired:開啟控制台訪問密碼
rocketmq.config.aclEnabled: broker acl開啟
rocketmq.config.accessKey: broker acl賬號
rocketmq.config.secretKey: broker acl密碼

 

 

 

9、瀏覽器訪問,http://ip:18180,輸入admin/123456登錄訪問


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM