Skip to content

Commit

Permalink
update swarm (#93)
Browse files Browse the repository at this point in the history
* fix comments

* fix dan
  • Loading branch information
Amber1990Zhang committed Oct 12, 2020
1 parent 58c7368 commit 02c8291
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 前提条件

部署集群前,请确保所有机器已安装 Nebula Graph、Docker 和 Docker Compose。如果需要自定义负载均衡和高可用,请安装 HAProxy 和 Keepalived。
部署集群前,请确保所有机器已 Docker 和 Docker Compose。如果需要自定义负载均衡和高可用,请安装 HAProxy 和 Keepalived。

机器准备:

Expand Down Expand Up @@ -38,7 +38,7 @@ To add a manager to this swarm, run 'docker swarm join-token manager' and follow

### 创建集群工作节点

根据 `docker swarm init` 命令的提示内容,创建 Swarm 集群的工作节点,在机器 `192.168.1.167``192.168.1.168` 上分别执行以下命令
根据 `docker swarm init` 命令的提示内容,创建 Swarm 集群的工作节点,分别在机器 `192.168.1.167``192.168.1.168` 上执行以下命令

```bash
$ docker swarm join \
Expand All @@ -54,7 +54,7 @@ This node joined a swarm as a worker.

### 验证集群

在管理节点上执行以下命令列出 Docker Swarm 节点信息:
在 manager 节点上执行以下命令列出 Docker Swarm 节点信息:

```bash
$ docker node ls
Expand All @@ -71,15 +71,15 @@ h1iql1uvm7123h3gon9so69dy KF2-DATA-168 Ready Active

### 配置 Docker Stack

在管理节点上执行以下命令添加 Docker Stack 配置文件:
在 manager 节点上执行以下命令添加 Docker Stack 配置文件:

```bash
$ vi docker-stack.yml
```

请根据您的 IP 地址与端口号进行配置。示例配置文件参考[这里](docker-stack.yml)
请根据您的 IP 地址与端口号进行配置。示例配置文件参考 [docker-stack.yml](docker-stack.yml)

在管理节点上执行以下命令添加 `nebula.env` 配置文件:
在 manager 节点上执行以下命令添加 `nebula.env` 配置文件:

```bash
$ vi nebula.env
Expand All @@ -94,12 +94,35 @@ USER=root

### 启动集群

在管理节点上执行以下命令启动 Nebula Graph 集群:
在 manager 节点上执行以下命令启动 Nebula Graph 集群:

```bash
$ docker stack deploy nebula -c docker-stack.yml
```

### 查看集群服务

在 manager 节点上执行以下命令查看服务状态:

```bash
$ docker service ls
```

返回以下信息:

```bash
ID NAME MODE REPLICAS IMAGE PORTS
43abplqq0h2z nebula_graphd1 replicated 1/1 vesoft/nebula-graphd:nightly
jkmnyzy2772s nebula_graphd2 replicated 1/1 vesoft/nebula-graphd:nightly
uo79ebcp41uw nebula_graphd3 replicated 1/1 vesoft/nebula-graphd:nightly
p50k0l1pvth0 nebula_metad0 replicated 1/1 vesoft/nebula-metad:nightly
oafq5jph8e65 nebula_metad1 replicated 1/1 vesoft/nebula-metad:nightly
qr4t5a8u5vjv nebula_metad2 replicated 1/1 vesoft/nebula-metad:nightly
ivs5i0o69505 nebula_storaged0 replicated 1/1 vesoft/nebula-storaged:nightly
y1xlsym8q90s nebula_storaged1 replicated 1/1 vesoft/nebula-storaged:nightly
xwgu2sfi2qso nebula_storaged2 replicated 1/1 vesoft/nebula-storaged:nightly
```

## 集群负载均衡及高可用配置(可选)

目前,Nebula Graph 的客户端(1.X)未提供负载均衡,而是随机选一个 `graphd` 服务连接。因此生产使用时需自行配置负载均衡和高可用。文档中的负载均衡和高可用仅为示例方案,您可以根据需要添加其他的第三方方案。
Expand Down Expand Up @@ -157,7 +180,7 @@ defaults
timeout server 50000ms
timeout http-request 20000ms
# custom your own frontends && backends && listen conf
# customize your own frontends && backends && listen conf
#CUSTOM
listen graphd-cluster
Expand Down Expand Up @@ -195,20 +218,9 @@ apt-get update && apt-get upgrade && apt-get install keepalived -y

#### 配置 Keepalived

更改 Keepalived 配置文件 `/etc/keepalived/keepalived.conf`(三台机器中 priority 必须设置成不同值以确定优先级)。示例配置文件参考[这里](keepalived.conf)

**注意**:配置 Keepalived 需预先准备好虚拟 IP,在以下配置中 `192.168.1.99` 即为虚拟 IP。
更改 Keepalived 配置文件 `/etc/keepalived/keepalived.conf`(三台机器中 `priority` 必须设置成不同值以确定优先级)。示例配置文件参考 [keepalived.conf](keepalived.conf)

Keepalived 常见命令:

```bash
# 启动keepalived
systemctl start keepalived
# 使keepalived开机自启
systemctl enable keeplived
# 重启keepalived
systemctl restart keepalived
```
> **注意**:配置 Keepalived 需预先准备好虚拟 IP,在以下配置中 `192.168.1.99` 即为虚拟 IP。
## FAQ

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ vrrp_instance VI_1 {
auth_pass amber1
}
virtual_ipaddress {
# 虚拟 IP 为 192.168.1.99/24;绑定接口为 ens160;别名ens160:1,主备相同
# 虚拟 IP 为 192.168.1.99/24;绑定接口为 ens160;别名 ens160:1,主备相同
192.168.1.99/24 dev ens160 label ens160:1
}
track_script {
Expand Down Expand Up @@ -86,7 +86,7 @@ vrrp_instance VI_1 {
auth_pass amber1
}
virtual_ipaddress {
# 虚拟 IP 为 192.168.1.99/24;绑定接口为 ens160;别名ens160:1,主备相同
# 虚拟 IP 为 192.168.1.99/24;绑定接口为 ens160;别名 ens160:1,主备相同
192.168.1.99/24 dev ens160 label ens160:1
}
track_script {
Expand Down

0 comments on commit 02c8291

Please sign in to comment.