rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vongosl...@apache.org
Subject [rocketmq-docker] branch master updated: CP a583e2c2c015bc07862831b874b5f4d356871787
Date Mon, 03 Jun 2019 09:17:54 GMT
This is an automated email from the ASF dual-hosted git repository.

vongosling pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-docker.git


The following commit(s) were added to refs/heads/master by this push:
     new 9982d22  CP a583e2c2c015bc07862831b874b5f4d356871787
9982d22 is described below

commit 9982d22671a7309a954fa57ac6f816d587c22923
Author: Kevin Wang <wiseking.wq@gmail.com>
AuthorDate: Fri May 31 17:38:09 2019 +0800

    CP a583e2c2c015bc07862831b874b5f4d356871787
---
 rocketmq-docker/README.md              | 223 +++++++++++++++++++++++++++++++++
 rocketmq-docker/image-build/Dockerfile |   4 +-
 rocketmq-docker/product/README.md      |  84 +++++++------
 3 files changed, 268 insertions(+), 43 deletions(-)

diff --git a/rocketmq-docker/README.md b/rocketmq-docker/README.md
new file mode 100644
index 0000000..b9fb8e5
--- /dev/null
+++ b/rocketmq-docker/README.md
@@ -0,0 +1,223 @@
+# RocketMQ-Docker
+
+This is the Git repo of the Docker Image for Apache RocketMQ. You could run it through the
following ways: 
+
+1. Generate a RocketMQ Docker image
+2. Run the docker image with the below modes:
+   1. Single Node.
+   2. Cluster with docker-compose.
+   3. Cluster on Kubernetes.
+
+
+## Prerequisites
+
+The Docker images in this repository should support Docker version 1.12+, and Kubernetes
version 1.9+.
+
+
+## Quick start
+
+### A. Generate a RocketMQ docker image
+
+Note: This is an experimented code to allow users to build docker image locally according
to a given RocketMQ version. Actually the formal images have been generated by RocketMQ official
maintainer and stored in docker hub. Suggest common users to use these remote images directly.
+
+```
+cd image-build
+sh build-image.sh RMQ-VERSION
+```
+
+Tip: The supported RMQ-VERSIONs can be obtained from [here](https://dist.apache.org/repos/dist/release/rocketmq/)
+
+### B. Stage a specific version
+
+Users can generate a runtime (stage) directory based on a specific version and docker style
operate the RocketMQ cluster/server/nameserver beneath the directory.
+
+``` 
+sh stage.sh RMQ-VERSION
+```
+
+After executing the above shell script, (e.g.  sh stage.sh 4.5.0), it will generate a stage
directory (./stages/4.5.0).  User can do the following works under the directory, assuming
the RMQ-version is defined with 4.5.0.
+
+#### 1. Single Node
+
+Run: 
+
+```
+cd stages/4.5.0 
+
+./play-docker.sh
+
+```
+
+#### 2. Cluster with docker-compose
+
+Run:
+
+```
+cd stages/4.5.0 
+
+./play-docker-compose.sh
+
+```
+
+
+#### 3. Cluster on Kubernetes
+
+Run:
+
+```
+cd stages/4.5.0 
+
+./play-kubernetes.sh
+
+```
+
+#### 4. Cluster of Deledger storage 
+
+Run: (Note: This feature needs RMQ version is 4.4.0 or above)
+
+```
+cd stages/4.5.0 
+
+./play-docker-deledger.sh
+
+```
+
+## 
+
+### To use specified heap size for JVM
+
+1. Use the environment variable MAX_POSSIBLE_HEAP to specify the max heap which JVM could
use. Meanwhile, the max direct memory is the same size as MAX_POSSIBLE_HEAP.
+
+2. To verify the usage:
+
+Run:
+
+```
+
+docker run -d -p 9876:9876 -v `pwd`/data/namesrv/logs:/root/logs -v `pwd`/data/namesrv/store:/root/store
--name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.4.0 sh mqnamesrv
+
+docker run -d -p 10911:10911 -p 10909:10909 -v `pwd`/data/broker/logs:/root/logs -v `pwd`/data/broker/store:/root/store
--name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000"
rocketmqinc/rocketmq:4.4.0 sh mqbroker
+
+```
+
+### How to verify RocketMQ works well
+
+#### Verify with Docker and docker-compose
+
+1. Use `docker ps|grep rmqbroker` to find your RocketMQ broker container id.
+
+2. Use `docker exec -it {container_id} ./mqadmin clusterList -n {nameserver_ip}:9876` to
verify if RocketMQ broker works, for example:
+```
+root$ docker exec -it 63950574b491 ./mqadmin clusterList -n 192.168.43.56:9876
+OpenJDK 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
+OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in
8.0
+#Cluster Name     #Broker Name            #BID  #Addr                  #Version         
      #InTPS(LOAD)       #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
+DefaultCluster    63950574b491            0     172.17.0.3:10911       V4_3_0           
       0.00(0,0ms)         0.00(0,0ms)          0 429398.92 -1.0000
+
+```
+
+#### Verify with Kubernetes
+
+1. Use `kubectl get pods|grep rocketmq` to find your RocketMQ broker Pod id, for example:
+```
+[root@k8s-master rocketmq]# kubectl get pods |grep rocketmq
+rocketmq-7697d9d574-b5z7g             2/2       Running       0          2d
+```
+
+2. Use `kubectl -n {namespace} exec -it {pod_id} -c broker bash` to login the broker pod,
for example:
+```
+[root@k8s-master rocketmq]# kubectl -n default exec -it  rocketmq-7697d9d574-b5z7g -c broker
bash
+[root@rocketmq-7697d9d574-b5z7g bin]# 
+```
+
+3. Use `mqadmin clusterList -n {nameserver_ip}:9876` to verify if RocketMQ broker works,
for example:
+```
+[root@rocketmq-7697d9d574-b5z7g bin]# ./mqadmin clusterList -n localhost:9876
+OpenJDK 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
+OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in
8.0
+#Cluster Name     #Broker Name            #BID  #Addr                  #Version         
      #InTPS(LOAD)       #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
+DefaultCluster    rocketmq-7697d9d574-b5z7g  0     192.168.196.14:10911   V4_3_0        
          0.00(0,0ms)         0.00(0,0ms)          0 429399.44 -1.0000
+
+```
+
+So you will find it works, enjoy !
+
+### C. Product level configuration
+
+The project also provides a usage reference for product level cluster docker configuration
and startup. Please see the [README.md](product/README.md) details in /product directory.
+
+
+## FAQ
+
+#### 1. If I want the broker container to load my customized configuration file (which means
`broker.conf`) when it starts, how can I achieve this? 
+
+First, create the customized `broker.conf`, like below:
+```
+brokerClusterName = DefaultCluster
+brokerName = broker-a
+brokerId = 0
+deleteWhen = 04
+fileReservedTime = 48
+brokerRole = ASYNC_MASTER
+flushDiskType = ASYNC_FLUSH
+#set `brokerIP1` if you want to set physical IP as broker IP.
+brokerIP1=10.10.101.80 #change you own physical IP Address
+```
+
+And put the customized `broker.conf` file at a specific path, like "`pwd`/data/broker/conf/broker.conf".

+
+Then we can modify the `play-docker.sh` and volume this file to the broker container when
it starts. For example: 
+
+```
+docker run -d -p 10911:10911 -p 10909:10909 -v `pwd`/data/broker/logs:/root/logs -v `pwd`/data/broker/store:/root/store
-v `pwd`/data/broker/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf --name rmqbroker
--link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" rocketmqinc/rocketmq:4.4
+.0 sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
+
+```
+
+Finally we can find the customized `broker.conf` has been used in the broker container. For
example:
+
+```
+huandeMacBook-Pro:4.4.0 huan$ docker ps |grep mqbroker
+a32c67aed6dd        rocketmqinc/rocketmq:4.4.0   "sh mqbroker"       20 minutes ago     
Up 20 minutes       0.0.0.0:10909->10909/tcp, 9876/tcp, 0.0.0.0:10911->10911/tcp   rmqbroker
+huandeMacBook-Pro:4.4.0 huan$ docker exec -it a32c67aed6dd cat /opt/rocketmq-4.4.0/conf/broker.conf
+brokerClusterName = DefaultCluster
+brokerName = broker-a
+brokerId = 0
+deleteWhen = 04
+fileReservedTime = 48
+brokerRole = ASYNC_MASTER
+flushDiskType = ASYNC_FLUSH
+#set `brokerIP1` if you want to set physical IP as broker IP.
+brokerIP1=10.10.101.80 #change you own physical IP Address
+
+```
+
+In the case of docker-compose, change the docker-compose.yml like following:
+```
+version: '2'
+services:
+  namesrv:
+    image: rocketmqinc/rocketmq:4.4.0
+    container_name: rmqnamesrv
+    ports:
+      - 9876:9876
+    volumes:
+      - ./data/namesrv/logs:/home/rocketmq/logs
+      - ./data/namesrv/store:/home/rocketmq/store
+    command: sh mqnamesrv
+  broker:
+    image: rocketmqinc/rocketmq:4.4.0
+    container_name: rmqbroker
+    ports:
+      - 10909:10909
+      - 10911:10911
+    volumes:
+      - ./data/broker/logs:/home/rocketmq/logs
+      - ./data/broker/store:/home/rocketmq/store
+      - ./data/broker/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf
+    #command: sh mqbroker -n namesrv:9876
+    command: sh mqbroker -n namesrv:9876 -c ../conf/broker.conf
+    depends_on:
+      - namesrv
+
+```
\ No newline at end of file
diff --git a/rocketmq-docker/image-build/Dockerfile b/rocketmq-docker/image-build/Dockerfile
index e2101e1..d890715 100644
--- a/rocketmq-docker/image-build/Dockerfile
+++ b/rocketmq-docker/image-build/Dockerfile
@@ -42,7 +42,7 @@ ARG version
 ENV ROCKETMQ_VERSION ${version}
 
 # Rocketmq home
-ENV ROCKETMQ_HOME  /opt/rocketmq-${ROCKETMQ_VERSION}
+ENV ROCKETMQ_HOME  /home/rocketmq/rocketmq-${ROCKETMQ_VERSION}
 
 # Java home
 ENV JAVA_HOME  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
@@ -65,7 +65,7 @@ RUN set -eux; \
 # add scripts
 COPY scripts/ ${ROCKETMQ_HOME}/bin/
 
-RUN chown -R ${uid}:${gid} ${ROCKETMQ_HOME}/bin/
+RUN chown -R ${uid}:${gid} ${ROCKETMQ_HOME}
 
 # expose namesrv port
 EXPOSE 9876
diff --git a/rocketmq-docker/product/README.md b/rocketmq-docker/product/README.md
index 446f890..11282ac 100644
--- a/rocketmq-docker/product/README.md
+++ b/rocketmq-docker/product/README.md
@@ -1,88 +1,90 @@
-# 生产级可用的RocketMQ Docker部署
+# Config Reference of RocketMQ Docker in production
 
-## 背景
+## Background
 
-这是一个简单的使用说明,旨在说明如何在生产环境中使用可持久的存储和配置信息,在不同的网络节点下部署NameServer集群和主从模式的Broker集群。注意:这里只包含配置及启动容器,没有提及容器的监控和管理,容器机器的DNS配置,消息的分布和可靠性存储等细节。这一部分需要结合Kubernetes的功能实现RocketMQ-Operator相关的高级部署功能。
+This is a simple instructions for how to use a persistent storage and configuration information
in a production environment to deploy a NameServer cluster and a master-slave broker cluster
under distributed network nodes. 
 
-## 部署和运行容器的步骤
+Note: Here only contains the configuration and startup Docker containers, without mentioning
the container's monitoring and management, the container machine's DNS configuration, message
distribution and reliability storage details. This part needs to depend on the advanced deployment
capabilities related to RocketMQ-Operator in conjunction with the capabilities of Kubernetes.
 
-1. 确定要部署的宿主机(物理或虚拟机)的IP和DNS信息,宿主机的存储文件路径,确保相关的端口(9876,
10911, 10912, 10909)未被占用
-2. 准备broker启动的配置文件,根据Cluster的要求,选择参考的配置文件,并对必要属性参数进行修改
-3. 调用docker容器启动脚本,设置参数,启动容器 (从[这里](<https://hub.docker.com/apache/rocketmq>)查找RocketMQ镜像版本)
-4. 验证容器启动状态
+## Steps to deploy and run docker containers
 
-## 目录结构
+1. Determine the IP and DNS information of the host (physical or virtual machine) to be deployed
with NameServer or Broker, the storage file location in the hosted node, and ensure that the
relevant ports (9876, 10911, 10912, 10909) are not occupied.
+2. Prepare the configuration file used by the broker, select the reference configuration
file according to the requirements of the Cluster, and modify the necessary attribute parameters
in the file.
+3. Call the docker container startup script, set the docker parameters, and start the container
(look for the RocketMQ image version from [here]())
+4. Verify the container startup status
+
+## Directory Structure
 
 product /
 
-​    | -  conf / 几种典型的集群的配置 
+​    | -  conf /   (Several typical cluster configuration references )
+
+​    | - start-ns.sh (Shell script for starting a name-server container, which is called
once for each name-server container on different node)
 
-​    | - start-ns.sh 启动name-server容器的脚本,每个name-server容器调用一次该脚本
+​    | - start-broker.sh (Shell script for starting a broker container, which is called
once for creating different broker cluster member on different node)
 
-​    | - start-broker.sh 启动broker容器的脚本,在不同的容器宿主机上执行该脚本,创建不同的broker集群成员
+   | - README.md 
 
-   | - REAMD.md 说明文件
+   | - README_cn.md
 
-## 一个具体的使用案例
+## Use Case 
 
-配置一个2m-2s-async的集群
+How to config a 2m-2s-async cluster in Docker style.
 
-### 启动nameserver集群 
+### Startup nameserver cluster 
 
-注意:可以跳过此步骤,如果使用已经存在的nameserver集群
+Note: You can skip this step if you use an existing nameserver cluster
 
-1. 确认要部署nameserver的宿主机,确定需要映射容器持久化的目录(DATA_HOME)和RocketMQ镜像版本(ROCKETMQ_VERSION)
+1. Confirm the host machine where the nameserver is to be deployed and copy the product directory
into the host. Determine the directory (DATA_HOME) where the container persistences content
(logs/storage) on the host,  as well as the RocketMQ image version (ROCKETMQ_VERSION)
 
-2. 运行脚本 start-ns.sh, 例如:
+2. Run the script start-ns.sh, for example:
 
    ```
    sh start-ns.sh /home/nameserver/data 4.5.0
    ```
 
-3. 如果有多个nameserver要启动,重复上述步骤。
+3. Repeat above steps if there are multiple nameservers in the cluster.
 
-### 启动broker集群
+### Startup broker cluster
 
-1. 确定要连接的NameServer集群的地址
+1. Confirm the NameServer Cluster address. (fomart e.g. "ns1:9876;ns2:9876;...")
 
-2. 确认要部署broker-a master的宿主机,确定需要映射容器持久化的目录(DATA_HOME),例如,确定宿主机的DATA_HOME目录为
/home/broker/data/; 则需要把参考的conf/2m-2s-async/broker-a.properties 文件复制到
/home/broker/data/conf/2m-2s-async/broker-a.properties
+2. Confirm the host machine where the broker-a master is to be deployed,determine the directory
(DATA_HOME) where the container persistences content (logs/storage) on the host, e.g. DATA_HOME
is set as /home/broker/data/;  then you need to copy the reference config file conf/2m-2s-async/broker-a.properties
as /home/broker/data/conf/2m-2s-async/broker-a.properties in the  host.
 
-   修改broker-a.properties文件的brokerIP1配置为宿主机的dns-hostname(注 #3)
+   Change file broker-a.properties and make the property 'brokerIP1' value as the dns-hostname(Precautions
#3) of the host.
 
-3. 确定ROCKETMQ_VERSION, 运行脚本 start-broker.sh, 例如:
+3. Confirm the ROCKETMQ_VERSION (e.g. 4.5.0), start broker with shell script start-broker.sh
through  the following command:
 
    ```
    sh start-broker.sh /home/broker/data 4.5.0 "ns1:9876;ns2:9876" conf/2m-2s-async/broker-a.properties
    ```
 
-4. 确定broker容器正确启动 (注意: 宿主机目录DATA_HOME要对容器rocketmq用户开放读取权限)
+4. Check if the broker container is start up correctly (Note:The dir DATA_HOME in host
needs to open read/write permissions  for the rocketmq user in the container, Precautions
#1)
 
-5. 确认要部署broker-a slave的宿主机,确定需要映射容器持久化的目录(DATA_HOME),例如,确定宿主机的DATA_HOME目录为
/home/broker/data/; 则需要把参考的conf/2m-2s-async/broker-a-s.properties 文件复制到
/home/broker/data/conf/2m-2s-async/broker-a-s.properties
+5. Confirm the host machine where the broker-a slave is to be deployed,determine the directory
(DATA_HOME) where the container persistences content (logs/storage) on the host, e.g. DATA_HOME
is set as /home/broker/data/;  then you need to copy the reference config file conf/2m-2s-async/broker-a-s.properties
as /home/broker/data/conf/2m-2s-async/broker-a-s.properties in the  host.
 
-   修改broker-a.properties文件的brokerIP1配置为宿主机的dns-hostname, brokerIP2为master所在的宿主机dns-hostname
+   Change file broker-a-s.properties and the proeprty 'brokerIP1' valueas the dns-hostname
of the host.
 
-6. 确定ROCKETMQ_VERSION, 运行脚本 start-broker.sh, 例如:
+6. Confirm the ROCKETMQ_VERSION,start slave broker with shell script start-broker.sh:
 
    ```
    sh start-broker.sh /home/broker/data 4.5.0 "ns1:9876;ns2:9876" conf/2m-2s-async/broker-a-s.properties
    ```
 
-7. 确定broker容器正确启动 (注意: 宿主机目录DATA_HOME要对容器rocketmq用户开放读取权限)
-
-8. 重复上述步骤,创建broker-b的主从broker容器
-
-## 注意事项
+7. Check if the broker container is start up correctly.
 
-1. 保证宿主机存储目录的权限
+8. Repeat above steps to create master and slave broker docker conatiners.
 
-   由于broker容器需要在宿主机的DATA_HOME目录下要写如需要持久化的数据,如,操作日志和消息存储文件,所以要求开放DATA_HOME目录下的权限,确保broker启动和运行时能够写入相关的文件。
+## Precautions
 
-   一个案例: 当启动broker后,一段时间时间后broker自动退出,没有任何日志写入,这个可能就是由于容器没有写入DATA_HOME/logs目录权限导致。
+1. Ensure the DATA_HOME directory r/w permissions
 
-2. 在脚本中(start-broker.sh, start-ns.sh)中声明外部映射端口
+   The broker container needs to write data that needs to be persisted in the DATA_HOME directory
of the host, these data include operation logs and message storage files. It is required to
open the permissions in the DATA_HOME directory to ensure that the relevant files can be written
when the broker is started and running. 
+      A case: After starting the broker, the broker automatically quits after a period of
time, without any log writes, this may be due to the container does not write DATA_HOME /
logs directory permissions.
 
-   在相关的脚本中已经定义了相关的默认映射端口,如果用户有特别需求(如端口已经被其它应用占用),则需要修改shell脚本,定义新的端口映射。
+2. Declare the external map port in the script (start-broker.sh, start-ns.sh)
+   The default mapping ports have been defined in the relevant script. If the user has special
requirements (such as a port is already occupied by other applications), you need to modify
the shell script to define a new port mapping.
 
-3. 建议使用DNS配置broker和name-server地址
+3. Recommended to use DNS to configure the broker and name-server address.
 
-   运行在docker容器中的broker使用brokerIP1来指定所在的宿主机的地址,并将这个地址注册到NameServer中,以便RocketMQ客户端通过NameServer取得可以外部可用的broker地址,但是一个好的实践是使用dns-hostname,来定义相关的ip地址,这样在大规模broker进行变化或者ip地址迁移时,不会对已经部署的容器有影响。
\ No newline at end of file
+   The broker running in the docker container uses the property brokerIP1 to specify the
address of the host it is on, and register/publish this address in the NameServer so that
the RocketMQ client can obtain externally available broker addresses through the NameServer.
When specifying the brokerIP1 property value, a good practice is to use dns- Hostname (instead
of the direct IP address), so that when a large-scale broker changes or ip address migration,
it will not affect the deployed [...]
\ No newline at end of file


Mime
View raw message