You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by vo...@apache.org on 2019/08/08 07:07:35 UTC

[rocketmq-docker] 22/28: Docs(): update README of product

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

commit d84993dd8af65ebc5bc1c5c247209c3d269a311f
Author: liuruiyiyang <24...@qq.com>
AuthorDate: Wed Aug 7 17:41:32 2019 +0800

    Docs(): update README of product
---
 product/README.md       | 14 +++++++-------
 product/start-broker.sh | 32 +++++++++++++++++++++++++-------
 product/start-ns.sh     | 32 +++++++++++++++++++++++++-------
 stage.sh                | 17 ++---------------
 4 files changed, 59 insertions(+), 36 deletions(-)

diff --git a/product/README.md b/product/README.md
index 11282ac..fe28d3c 100644
--- a/product/README.md
+++ b/product/README.md
@@ -35,12 +35,12 @@ How to config a 2m-2s-async cluster in Docker style.
 
 Note: You can skip this step if you use an existing nameserver cluster
 
-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)
+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) and base image alpine or centos (BASE_IMAGE)
 
 2. Run the script start-ns.sh, for example:
 
    ```
-   sh start-ns.sh /home/nameserver/data 4.5.0
+   sh start-ns.sh /home/nameserver/data 4.5.0 alpine
    ```
 
 3. Repeat above steps if there are multiple nameservers in the cluster.
@@ -49,14 +49,14 @@ Note: You can skip this step if you use an existing nameserver cluster
 
 1. Confirm the NameServer Cluster address. (fomart e.g. "ns1:9876;ns2:9876;...")
 
-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.
+2. Confirm the host machine where the broker-a master is to be deployed,determine the directory (DATA_HOME) where the container persistence content (logs/storage) exists 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.
 
    Change file broker-a.properties and make the property 'brokerIP1' value as the dns-hostname(Precautions #3) of the host.
 
-3. Confirm the ROCKETMQ_VERSION (e.g. 4.5.0), start broker with shell script start-broker.sh through  the following command:
+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
+   sh start-broker.sh /home/broker/data 4.5.0 "ns1:9876;ns2:9876" conf/2m-2s-async/broker-a.properties alpine
    ```
 
 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)
@@ -68,12 +68,12 @@ Note: You can skip this step if you use an existing nameserver cluster
 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
+   sh start-broker.sh /home/broker/data 4.5.0 "ns1:9876;ns2:9876" conf/2m-2s-async/broker-a-s.properties alpine
    ```
 
 7. Check if the broker container is start up correctly.
 
-8. Repeat above steps to create master and slave broker docker conatiners.
+8. Repeat above steps to create master and slave broker docker containers.
 
 ## Precautions
 
diff --git a/product/start-broker.sh b/product/start-broker.sh
index c7b4e93..2c70f5f 100644
--- a/product/start-broker.sh
+++ b/product/start-broker.sh
@@ -25,6 +25,7 @@ DATA_HOME=$1
 ROCKETMQ_VERSION=$2
 NAMESRV_ADDR=$3
 CONF_FILE=$4
+BASE_IMAGE=$5
 
 ## Show Env Setting
 echo "ENV Setting: "
@@ -40,10 +41,27 @@ fi
 
 
 # Start Broker
-docker run -d  -v ${DATA_HOME}/logs:/home/rocketmq/logs -v ${DATA_HOME}/store:/home/rocketmq/store \
-  -v ${DATA_HOME}/conf:/home/rocketmq/conf \
-  --name rmqbroker \
-  -e "NAMESRV_ADDR=${NAMESRV_ADDR}" \
-  -p 10911:10911 -p 10912:10912 -p 10909:10909 \
-  rocketmqinc/rocketmq:${ROCKETMQ_VERSION} \
-  sh mqbroker -c /home/rocketmq/conf/${CONF_FILE}
+start_broker()
+{
+    TAG_SUFFIX=$1
+    docker run -d  -v ${DATA_HOME}/logs:/home/rocketmq/logs -v ${DATA_HOME}/store:/home/rocketmq/store \
+      -v ${DATA_HOME}/conf:/home/rocketmq/conf \
+      --name rmqbroker \
+      -e "NAMESRV_ADDR=${NAMESRV_ADDR}" \
+      -p 10911:10911 -p 10912:10912 -p 10909:10909 \
+      rocketmqinc/rocketmq:${ROCKETMQ_VERSION}${TAG_SUFFIX} \
+      sh mqbroker -c /home/rocketmq/conf/${CONF_FILE}
+}
+
+case "${BASE_IMAGE}" in
+    alpine)
+        start_broker -alpine
+    ;;
+    centos)
+        start_broker
+    ;;
+    *)
+        echo "${BASE_IMAGE} is not supported, supported base images: centos, alpine"
+        exit -1
+    ;;
+esac
\ No newline at end of file
diff --git a/product/start-ns.sh b/product/start-ns.sh
index 5d33ca2..e09eaca 100644
--- a/product/start-ns.sh
+++ b/product/start-ns.sh
@@ -17,21 +17,39 @@
 
 
 ## Main
-if [ $# -lt 2 ]; then
-    echo "Usage: sh $0 DATA_HOME ROCKETMQ_VERSION"
+if [ $# -lt 3 ]; then
+    echo "Usage: sh $0 DATA_HOME ROCKETMQ_VERSION BASE_IMAGE"
     exit -1
 fi
 
 DATA_HOME=$1
 ROCKETMQ_VERSION=$2
+BASE_IMAGE=$3
 
 ## Show Env Setting
 echo "ENV Setting: "
 echo "DATA_HOME=${DATA_HOME} ROCKETMQ_VERSION=${ROCKETMQ_VERSION}"
 
 # Start nameserver
-docker run -d -v ${DATA_HOME}/logs:/home/rocketmq/logs \
-  --name rmqnamesrv \
-  -p 9876:9876 \
-  rocketmqinc/rocketmq:${ROCKETMQ_VERSION} \
-  sh mqnamesrv
\ No newline at end of file
+start_namesrv()
+{
+    TAG_SUFFIX=$1
+    docker run -d -v ${DATA_HOME}/logs:/home/rocketmq/logs \
+      --name rmqnamesrv \
+      -p 9876:9876 \
+      rocketmqinc/rocketmq:${ROCKETMQ_VERSION}${TAG_SUFFIX} \
+      sh mqnamesrv
+}
+
+case "${BASE_IMAGE}" in
+    alpine)
+        start_namesrv -alpine
+    ;;
+    centos)
+        start_namesrv
+    ;;
+    *)
+        echo "${BASE_IMAGE} is not supported, supported base images: centos, alpine"
+        exit -1
+    ;;
+esac
\ No newline at end of file
diff --git a/stage.sh b/stage.sh
index 652d160..cb7898f 100644
--- a/stage.sh
+++ b/stage.sh
@@ -50,18 +50,5 @@ cp -rf "$CURRENT_DIR/templates/" "$STAGE_DIR/$version"
 
 echo "staged templates into folder $STAGE_DIR/$version"
 
-# Replace ROCKETMQ_VERSION with real version string in all files under $STAGE_DIR/$version
-replace_version()
-{
-    case "`uname`" in
-        Darwin)
-            find "$STAGE_DIR/$version" -type f | xargs perl -pi -e "s/ROCKETMQ_VERSION/${version}/g"
-        ;;
-        *)
-            #sed -i "s/ROCKETMQ_VERSION/${version}/g"  `grep ROCKETMQ_VERSION -rl $STAGE_DIR/$version/template`
-            find "$STAGE_DIR/$version/template" -type f | xargs perl -pi -e "s/ROCKETMQ_VERSION/${version}/g"
-        ;;
-    esac
-}
-
-replace_version
\ No newline at end of file
+# Replace string "ROCKETMQ_VERSION" with real version in all files under $STAGE_DIR/$version
+find "$STAGE_DIR/$version" -type f | xargs perl -pi -e "s/ROCKETMQ_VERSION/${version}/g"
\ No newline at end of file