WillemJiang closed pull request #60: add how to deploy service center in 
cluster mode
URL: https://github.com/apache/incubator-servicecomb-website/pull/60
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/_users/cn/setup-environment.md b/_users/cn/setup-environment.md
index 11d9edb..749f5a5 100644
--- a/_users/cn/setup-environment.md
+++ b/_users/cn/setup-environment.md
@@ -4,7 +4,7 @@ lang: cn
 ref: setup-environment
 permalink: /cn/users/setup-environment/
 excerpt: "环境配置"
-last_modified_at: 2017-09-03T10:01:43-04:00
+last_modified_at: 2018-04-13T10:01:43-04:00
 ---
 
 {% include toc %}
@@ -19,8 +19,9 @@ last_modified_at: 2017-09-03T10:01:43-04:00
 
 * 安装IntelliJ Idea 
IDE,详情可参考[IntelliJ安装教程](https://www.jetbrains.com/help/idea/installing-and-launching.html){:target="_blank"}。
 
-## 运行*Service Center*
-运行Service Center有以下两种方式:
+## 运行 Service Center
+### 运行 Stand-alone Service Center
+运行Stand-alone Service Center有以下两种方式:
 
 1. 以可执行文件的方式运行
 
@@ -61,3 +62,126 @@ docker run -d -p 30100:30100 
servicecomb/service-center:latest
 **注意事项:** 服务注册中心运行后绑定的IP为:*http://127.0.0.1:30100*。  
 如使用Docker Toolbox,可通过 `docker-machine ip` 获取服务绑定IP地址。
 {: .notice--warning}
+
+### 运行 Service Center 集群
+Service Center是一个无状态的应用因此它很容易以集群的模式部署提供HA。
+
+它依赖[etcd](https://github.com/coreos/etcd)存储微服务的信息,etcd既支持standalone模式运行也支持[集群模式](https://coreos.com/etcd/docs/latest/op-guide/clustering.html)运行。
+
+提示:我们强烈推荐etcd以集群模式运行,这样才能从整体上保证Service 
Center的HA能力;另外在这篇[文档](https://coreos.com/etcd/docs/latest/op-guide/runtime-configuration.html)中我们可以了解到etcd需要部署至少三个节点才能够避免Majority
 Failure。
+
+
+部署了standalone或集群etcd后,你可以按下面的步骤部署Service Center集群,我们以在两台VM上各部署一个Service 
Center实例为例:
+
+| Name    | Address     |
+| :-----: | :---------: |
+| VM1     | 10.12.0.1   |
+| VM2     | 10.12.0.2   |
+
+我们假定你的etcd运行在http://10.12.0.4:2379 上:
+
+##### 第一步
+在所有的VM上从[ServiceComb官网](https://github.com/apache/incubator-servicecomb-service-center/releases)下载最新版本的Service
 Center并解压:
+
+```bash
+tar -xvf service-center-X.X.X-linux-amd64.tar.gz
+```
+
+提示:请不要按stand-alone提示的方式执行start-service-center.sh,因为这样会启动内置的etcd。
+
+##### 第二步
+编辑ServcieComb的配置文件,修改ip/port以及etcd地址:
+###### VM1
+```bash
+vi conf/app.conf
+```
+
+修改下面的配置 :
+```text
+httpaddr = 10.12.0.1
+manager_cluster = "10.12.0.4:2379"
+```
+
+然后启动Service Center :
+```bash
+./service-center
+```
+
+###### VM2
+```bash
+vi conf/app.conf
+```
+
+修改下面的配置 :
+```text
+httpaddr = 10.12.0.2
+manager_cluster = "10.12.0.4:2379"
+```
+
+然后启动Service Center :
+```bash
+./service-center
+```
+
+提示:在`manger_cluster`配置中你可以填写多个在etcd群集中的etcd实例地址:
+```
+manager_cluster= "10.12.0.4:2379,10.12.0.X:2379,10.12.0.X:2379"
+```
+
+##### 第三步
+验证你部署完毕的Service Center实例 :
+```bash
+curl http://10.12.0.1:30101/v4/default/registry/health
+```
+将会返回下面的内容 :
+```json
+{
+    "instances": [
+        {
+            "instanceId": "d6e9e976f9df11e7a72b286ed488ff9f",
+            "serviceId": "d6e99f4cf9df11e7a72b286ed488ff9f",
+            "endpoints": [
+                "rest://10.12.0.1:30100"
+            ],
+            "hostName": "service_center_10_12_0_1",
+            "status": "UP",
+            "healthCheck": {
+                "mode": "push",
+                "interval": 30,
+                "times": 3
+            },
+            "timestamp": "1516012543",
+            "modTimestamp": "1516012543"
+        },
+        {
+            "instanceId": "16d4cb35f9e011e7a58a286ed488ff9f",
+            "serviceId": "d6e99f4cf9df11e7a72b286ed488ff9f",
+            "endpoints": [
+                "rest://10.12.0.2:30100"
+            ],
+            "hostName": "service_center_10_12_0_2",
+            "status": "UP",
+            "healthCheck": {
+                "mode": "push",
+                "interval": 30,
+                "times": 3
+            },
+            "timestamp": "1516012650",
+            "modTimestamp": "1516012650"
+        }
+    ]
+}
+```
+
+
+我们可以看到Service Center能够自动发现所有正在集群中运行的实例,[Java-Chassis 
SDK](https://github.com/apache/incubator-servicecomb-java-chassis)将使用这个特性至少找到一个Service
 Center实例。
+
+在你的microservice.yaml中你可以填写一个或多个Service Center实例,如果[Java-Chassis 
SDK](https://github.com/apache/incubator-servicecomb-java-chassis)发现配置的第一个地址(实例)失败,它将会自动使用下一个地址(实例):
+```yaml
+cse:
+  service:
+    registry:
+      address: "http://10.12.0.1:30100,http://10.12.0.2:30100";
+      autodiscovery: true
+```
+上面的例子里包含了我们已经配置好的两个Service Center实例。
\ No newline at end of file
diff --git a/_users/setup-environment.md b/_users/setup-environment.md
index 9888da2..fdc8316 100644
--- a/_users/setup-environment.md
+++ b/_users/setup-environment.md
@@ -4,7 +4,7 @@ lang: en
 ref: setup-environment
 permalink: /users/setup-environment/
 excerpt: "Setup Environment"
-last_modified_at: 2017-09-03T10:01:43-04:00
+last_modified_at: 2018-04-13T10:01:43-04:00
 ---
 
 {% include toc %}
@@ -19,8 +19,9 @@ last_modified_at: 2017-09-03T10:01:43-04:00
 
 * Setup IntelliJ Idea IDE,Refer to [How to setup 
IntelliJ](https://www.jetbrains.com/help/idea/installing-and-launching.html){:target="_blank"}。
 
-## Starting Local *Service Center*
-There are two ways to start a service center service:
+## Starting Service Center
+### Starting Stand-alone Service Center
+There are two ways to start a stand-alone service center service:
 
 1. Start from installation package
 
@@ -35,7 +36,7 @@ There are two ways to start a service center service:
    2. Decompress the installation package into the installation directory.
    3. Start Local ServiceCenter from **start-service-center.bat** file
    </div>
-   <div id="linux" class="tab-pane fade" markdown="1">
+    <div id="linux" class="tab-pane fade" markdown="1">
    1. Download and Decompress command:
    ```bash
    wget 
http://apache.org/dyn/closer.cgi/incubator/servicecomb/incubator-servicecomb-service-center/1.0.0-m1/apache-servicecomb-incubating-service-center-1.0.0-m1-linux-amd64.tar.gz
@@ -47,7 +48,7 @@ There are two ways to start a service center service:
    ```
     </div>
    </div>
-
+   
    NOTE:The OS must be 64-bit.
    {: .notice--warning}
 
@@ -61,3 +62,125 @@ docker run -d -p 30100:30100 
servicecomb/service-center:latest
 **NOTE:** Running Service Center will bind on: *http://127.0.0.1:30100*。  
 If using Docker Toolbox,command `docker-machine ip` can be used to get binded 
IP address.
 {: .notice--warning}
+
+### Starting Clustered Service Center
+As Service-center is a stateless application so it can be seamlessly deployed 
in cluster mode to achieve HA.
+
+SC is dependent on the [etcd](https://github.com/coreos/etcd) to store the 
micro-services information so you can opt for running etcd standalone or in 
[cluster](https://coreos.com/etcd/docs/latest/op-guide/runtime-configuration.html)
 mode.
+
+Notice: We strongly recommend running etcd in cluster mode in order to get the 
perfect HA ability. In this 
[document](https://coreos.com/etcd/docs/latest/op-guide/runtime-configuration.html)
 we can know it is highly recommended to always have a cluster size greater 
than two in production in order to prevent Majority Failure.
+
+Once you are done with installing the etcd either in cluster or standalone 
mode then you can follow the below steps to run the Service-Center.
+
+Let's assume you want to install 2 instances of Service-Center on VM with 
following details  
+
+| Name    | Address     |
+| :-----: | :---------: |
+| VM1     | 10.12.0.1   |
+| VM2     | 10.12.0.2   |
+
+Here we assume your etcd is running on http://10.12.0.4:2379 (you can follow 
[this](https://github.com/coreos/etcd/blob/master/Documentation/op-guide/container.md)
 guide to install etcd in cluster mode.)
+
+##### Step 1
+Download the SC release from 
[here](https://github.com/apache/incubator-servicecomb-service-center/releases) 
on all the VM's.
+```bash
+tar -xvf service-center-X.X.X-linux-amd64.tar.gz
+```
+
+Note: Please don't run start-service-center.sh as it will also start the 
built-in etcd.
+
+##### Step 2
+Edit the configuration of the ip/port on which SC will run and etcd ip
+###### VM1
+```bash
+vi conf/app.conf
+```
+
+Replace the below values :
+```text
+httpaddr = 10.12.0.1
+manager_cluster = "10.12.0.4:2379"
+```
+
+Then start the Service-center :
+```bash
+./service-center
+```
+
+###### VM2
+```bash
+vi conf/app.conf
+```
+
+Replace the below values :
+```text
+httpaddr = 10.12.0.2
+manager_cluster = "10.12.0.4:2379"
+```
+
+Then start the Service-center :
+```bash
+./service-center
+```
+
+Note: In `manger_cluster` you can put the multiple instances of etcd in the 
cluster like :
+```
+manager_cluster= "10.12.0.4:2379,10.12.0.X:2379,10.12.0.X:2379"
+```
+
+##### Step 3
+Verify your instances via :
+```bash
+curl http://10.12.0.1:30101/v4/default/registry/health
+```
+Will return :
+```json
+{
+    "instances": [
+        {
+            "instanceId": "d6e9e976f9df11e7a72b286ed488ff9f",
+            "serviceId": "d6e99f4cf9df11e7a72b286ed488ff9f",
+            "endpoints": [
+                "rest://10.12.0.1:30100"
+            ],
+            "hostName": "service_center_10_12_0_1",
+            "status": "UP",
+            "healthCheck": {
+                "mode": "push",
+                "interval": 30,
+                "times": 3
+            },
+            "timestamp": "1516012543",
+            "modTimestamp": "1516012543"
+        },
+        {
+            "instanceId": "16d4cb35f9e011e7a58a286ed488ff9f",
+            "serviceId": "d6e99f4cf9df11e7a72b286ed488ff9f",
+            "endpoints": [
+                "rest://10.12.0.2:30100"
+            ],
+            "hostName": "service_center_10_12_0_2",
+            "status": "UP",
+            "healthCheck": {
+                "mode": "push",
+                "interval": 30,
+                "times": 3
+            },
+            "timestamp": "1516012650",
+            "modTimestamp": "1516012650"
+        }
+    ]
+}
+```
+
+As we can see here the Service-Center can auto-discover all the instances of 
the Service-Center running in cluster, this auto-discovery feature is used by 
the [Java-Chassis 
SDK](https://github.com/apache/incubator-servicecomb-java-chassis) to 
auto-discover all the instances of the Service-Center by knowing at least one 
IP of Service-Center running in cluster.
+
+In your microservice.yaml you can provide the SC IP of both the instance or 
any one instance, sdk can auto-discover other instances and use the other 
instances to get microservice details in case of failure of the first one.
+```yaml
+cse:
+  service:
+    registry:
+      address: "http://10.12.0.1:30100,http://10.12.0.2:30100";
+      autodiscovery: true
+```
+In this case sdk will be able to discover all the instances of SC in cluster.
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to