This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 034d7389b [ISSUE #4788] Improvement controller quick_start.md file 
(#4790)
034d7389b is described below

commit 034d7389ba32d4f95cff471e8aa2eb27c31202d1
Author: mxsm <[email protected]>
AuthorDate: Sun Aug 7 10:45:09 2022 +0800

    [ISSUE #4788] Improvement controller quick_start.md file (#4790)
---
 .../controller/fast-try-independent-deployment.sh  |  76 +++++++++++
 docs/cn/controller/quick_start.md                  | 150 ++++++++++++++++++---
 2 files changed, 210 insertions(+), 16 deletions(-)

diff --git a/distribution/bin/controller/fast-try-independent-deployment.sh 
b/distribution/bin/controller/fast-try-independent-deployment.sh
new file mode 100644
index 000000000..7aa52d519
--- /dev/null
+++ b/distribution/bin/controller/fast-try-independent-deployment.sh
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+
+# 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.
+
+## Revise the base dir
+CURRENT_DIR="$(cd "$(dirname "$0")"; pwd)"
+RMQ_DIR=$CURRENT_DIR/../..
+cd $RMQ_DIR
+
+startController() {
+    export JAVA_OPT_EXT=" -Xms512m -Xmx512m  "
+    conf_name=$1
+    nohup bin/mqcontroller -c $conf_name &
+}
+
+stopController() {
+    PIDS=$(ps -ef|grep java|grep ControllerStartup|grep -v grep|awk '{print 
$2}')
+    if [ ! -z "$PIDS" ]; then
+        kill -s TERM $PIDS
+    fi
+}
+
+stopAll() {
+    stopController
+}
+
+startAll() {
+    startController ./conf/controller/cluster-3n-independent/controller-n0.conf
+    startController ./conf/controller/cluster-3n-independent/controller-n1.conf
+    startController ./conf/controller/cluster-3n-independent/controller-n2.conf
+}
+
+checkConf() {
+    if [ ! -f ./conf/controller/cluster-3n-independent/controller-n0.conf -o ! 
-f ./conf/controller/cluster-3n-independent/controller-n1.conf -o ! -f 
./conf/controller/cluster-3n-independent/controller-n2.conf ]; then
+        echo "Make sure the 
./conf/controller/cluster-3n-independent/controller-n0.conf, 
./conf/controller/cluster-3n-independent/controller-n1.conf, 
./conf/controller/cluster-3n-independent/controller-n2.conf exists"
+        exit 1
+    fi
+}
+
+
+
+## Main
+if [ $# -lt 1 ]; then
+    echo "Usage: sh $0 start|stop"
+    exit 1
+fi
+action=$1
+checkConf
+case $action in
+    "start")
+        startAll
+        exit
+        ;;
+    "stop")
+        stopAll
+        exit
+        ;;
+    *)
+        echo "Usage: sh $0 start|stop"
+        exit
+        ;;
+esac
+
diff --git a/docs/cn/controller/quick_start.md 
b/docs/cn/controller/quick_start.md
index 770d1f649..db36d241b 100644
--- a/docs/cn/controller/quick_start.md
+++ b/docs/cn/controller/quick_start.md
@@ -12,35 +12,50 @@
 
 ## 编译 RocketMQ 源码
 
-`git clone https://github.com/apache/rocketmq.git`
+```shell
+$ git clone https://github.com/apache/rocketmq.git
 
-`cd rocketmq`
+$ cd rocketmq
 
-`      mvn -Prelease-all -DskipTests clean install -U`
+$ mvn -Prelease-all -DskipTests clean install -U
+```
 
 ## 快速部署
 
 在构建成功后
 
-`cd distribution/target/apache-rocketmq`
+```shell
+#{rocketmq-version} replase replace with rocketmq actual version. example: 
5.0.0-SNAPSHOT
+$ cd 
distribution/target/rocketmq-{rocketmq-version}/rocketmq-{rocketmq-version}/
+
+$ sh bin/controller/fast-try.sh start
+```
 
-`sh bin/controller/fast-try.sh start`
+如果上面的步骤执行成功,可以通过运维命令查看Controller状态。
 
-如果上面的步骤执行成功,可以通过运维命令查看集群状态。
+```shell
+$ sh bin/mqadmin getControllerMetaData -a localhost:9878
+```
+
+-a代表集群中任意一个Controller的地址
 
 至此, 启动成功,现在可以向集群收发消息,并进行切换测试了。
 
 如果需要关闭快速集群,可以执行:
 
-`sh bin/controller/fast-try.sh stop`
+```shell
+$ sh bin/controller/fast-try.sh stop
+```
 
-对于快速部署,默认配置在 conf/controller里面,默认的存储路径在 /tmp/rmqstore, 且会开启一个 Controller (嵌入在 
Namesrv) 和两个 Broker。
+对于快速部署,默认配置在 conf/controller/quick-start里面,默认的存储路径在 /tmp/rmqstore, 且会开启一个 
Controller (嵌入在 Namesrv) 和两个 Broker。
 
 ### 查看 SyncStateSet
 
 可以通过运维工具查看 SyncStateSet:
 
-`sh bin/mqadmin getSyncStateSet -a localhost:9878 -b broker-a`
+```shell
+$ sh bin/mqadmin getSyncStateSet -a localhost:9878 -b broker-a
+```
 
 -a 代表的是任意一个 Controller 的地址
 
@@ -52,7 +67,9 @@
 
 可以通过运维工具查看 BrokerEpochEntry:
 
-`sh bin/mqadmin getBrokerEpoch -n localhost:9876 -b broker-a`
+```shell
+$ sh bin/mqadmin getBrokerEpoch -n localhost:9876 -b broker-a
+```
 
 -n 代表的是任意一个 Namesrv 的地址
 
@@ -66,17 +83,118 @@
 
 首先, kill 掉原 Master 的进程, 在上文的例子中, 就是使用端口 30911 的进程:
 
-```
-查找端口:
-ps -ef|grep java|grep BrokerStartup|grep 
./conf/controller/quick-start/broker-n0.conf|grep -v grep|awk '{print $2}'
-杀掉 master:
-kill -9 PID
+```shell
+#查找端口:
+$ ps -ef|grep java|grep BrokerStartup|grep 
./conf/controller/quick-start/broker-n0.conf|grep -v grep|awk '{print $2}'
+#杀掉 master:
+$ kill -9 PID
 ```
 
 接着, 用 SyncStateSet admin 脚本查看:
 
-`sh bin/mqadmin getSyncStateSet -a localhost:9878 -b broker-a`
+```shell
+$ sh bin/mqadmin getSyncStateSet -a localhost:9878 -b broker-a
+```
 
 可以发现 Master 已经发生了切换。
 
 ![image-20220605211244128](../image/controller/quick-start/changemaster.png)
+
+
+
+## Controller内嵌Namesvr集群部署
+
+Controller以插件方式内嵌Namesvr集群(3个Node组成)部署,快速启动:
+
+```shell
+$ sh bin/controller/fast-try-namesrv-plugin.sh start
+```
+
+或者通过命令单独启动:
+
+```shell
+$ nohup bin/mqnamesrv -c 
./conf/controller/cluster-3n-namesrv-plugin/namesrv-n0.conf &
+$ nohup bin/mqnamesrv -c 
./conf/controller/cluster-3n-namesrv-plugin/namesrv-n1.conf &
+$ nohup bin/mqnamesrv -c 
./conf/controller/cluster-3n-namesrv-plugin/namesrv-n2.conf &
+```
+
+如果上面的步骤执行成功,可以通过运维命令查看Controller集群状态。
+
+```shell
+$ sh bin/mqadmin getControllerMetaData -a localhost:9878
+```
+
+-a代表的是任意一个 Controller 的地址
+
+如果controller启动成功可以看到以下内容:
+
+```
+#ControllerGroup        group1
+#ControllerLeaderId     n0
+#ControllerLeaderAddress        127.0.0.1:9878
+#Peer:  n0:127.0.0.1:9878
+#Peer:  n1:127.0.0.1:9868
+#Peer:  n2:127.0.0.1:9858
+```
+
+启动成功后Broker Controller模式部署就能使用Controller集群。
+
+如果需要快速停止集群:
+
+```shell
+$ sh bin/controller/fast-try-namesrv-plugin.sh stop
+```
+
+使用 fast-try-namesrv-plugin.sh 脚本快速部署,默认配置在 
conf/controller/cluster-3n-namesrv-plugin里面并且会启动3个Namesvr和3个Controller(内嵌Namesrv)。
+
+## Controller独立集群部署
+
+Controller独立集群(3个Node组成)部署,快速启动:
+
+```shell
+$ sh bin/controller/fast-try-independent-deployment.sh start
+```
+
+或者通过命令单独启动:
+
+```shell
+$ nohup bin/mqnamesrv -c 
./conf/controller/cluster-3n-independent/controller-n0.conf &
+$ nohup bin/mqnamesrv -c 
./conf/controller/cluster-3n-independent/controller-n1.conf &
+$ nohup bin/mqnamesrv -c 
./conf/controller/cluster-3n-independent/controller-n2.conf &
+```
+
+如果上面的步骤执行成功,可以通过运维命令查看Controller集群状态。
+
+```shell
+$ sh bin/mqadmin getControllerMetaData -a localhost:9878
+```
+
+-a代表的是任意一个 Controller 的地址
+
+如果Controller启动成功可以看到以下内容:
+
+```
+#ControllerGroup        group1
+#ControllerLeaderId     n1
+#ControllerLeaderAddress        127.0.0.1:9868
+#Peer:  n0:127.0.0.1:9878
+#Peer:  n1:127.0.0.1:9868
+#Peer:  n2:127.0.0.1:9858
+```
+
+启动成功后Broker Controller模式部署就能使用Controller集群。
+
+如果需要快速停止集群:
+
+```shell
+$ sh bin/controller/fast-try-independent-deployment.sh stop
+```
+
+使用fast-try-independent-deployment.sh 脚本快速部署,默认配置在 
conf/controller/cluster-3n-independent里面并且会启动3个Controller(独立部署)组成一个集群。
+
+
+
+## 注意说明
+
+- 若需要保证Controller具备容错能力,Controller部署需要三副本及以上(遵循Raft的多数派协议)
+- Controller部署配置文件中配置参数`controllerDLegerPeers` 
中的IP地址配置成其他节点能够访问的IP,在多机器部署的时候尤为重要。例子仅供参考需要根据实际情况进行修改调整。

Reply via email to