Skip to content

Commit

Permalink
[doc]fix build and contribute chapter doc errors (vesoft-inc#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
amber-moe authored and dangleptr committed Nov 7, 2019
1 parent 90ee9d7 commit 857b990
Show file tree
Hide file tree
Showing 24 changed files with 111 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
### 编译器
# 使用源码编译

## 编译器要求

Nebula 基于 C++ 14 开发,因此它需要一个支持 C++ 14 的编译器。

### 支持系统版本

- Fedora 29, 30
- CentOS 6.5, CentOS 7.0 ~ 7.6
- Ubuntu 16.04, 18.04
Expand All @@ -12,6 +15,7 @@ Nebula 基于 C++ 14 开发,因此它需要一个支持 C++ 14 的编译器。
当编译类型为 **Debug** 的时候,最好预留 **30G** 磁盘空间

### 本地构建

#### 步骤 1: 克隆代码

```bash
Expand Down Expand Up @@ -58,7 +62,7 @@ bash> git clone https://github.com/vesoft-inc/nebula.git
bash> source ~/.bashrc
```

#### 步骤 4: 构建Debug版本
#### 步骤 4: 构建 Debug 版本

```bash
bash> mkdir build && cd build
Expand All @@ -67,7 +71,7 @@ bash> make
bash> sudo make install
```

#### 构建Release版本,重新生成makefile
#### 构建 Release 版本,重新生成 makefile

```bash
bash> cmake -DCMAKE_BUILD_TYPE=Release ..
Expand All @@ -82,6 +86,7 @@ bash> sudo make install
```text
[100%] Built target ....
```

**编译成功!**

- 在安装目录 **/usr/local/nebula** 下有如下四个子目录 **etc/**, **bin/**, **scripts/** **share/**
Expand All @@ -90,6 +95,7 @@ bash> sudo make install
[root@centos 7.5 nebula]# ls /usr/local/nebula/
bin etc scripts share
```

**现在可以开始运行 Nebula**

<!-- ### 使用 docker 容器构建
Expand Down Expand Up @@ -155,13 +161,13 @@ nebula> SHOW HOSTS;

**步骤 1**: 在 **~/.bashrc** 末添加如下行

```
```bash
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH
```

**步骤 2**: 应用 **~/.bashrc** 修改

```
```bash
bash> source ~/.bashrc
```

Expand All @@ -173,20 +179,21 @@ nebula> SHOW HOSTS;

**Ubuntu**

```
```bash
sudo apt-get -y install openjdk-8-jdk
```

**CentOS**

```
```bash
sudo yum -y install java-1.8.0-openjdk
```

3) 在 **~/.bashrc** 末添加

**Ubuntu**
```

```bash
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
Expand All @@ -195,7 +202,7 @@ nebula> SHOW HOSTS;

**CentOS**

```
```bash
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
Expand All @@ -210,13 +217,13 @@ nebula> SHOW HOSTS;

步骤 1: 下载第三方库的源码包

```
```bash
bash> wget https://nebula-graph.oss-accelerate.aliyuncs.com/third-party/nebula-3rdparty.tar.gz
```

步骤 2: 解压并编译third-party

```
```bash
bash> tar xf nebula-3rdparty.tar.gz && cd nebula-3rdparty
bash> ./install_deps.sh
bash> cmake ./
Expand All @@ -225,7 +232,7 @@ nebula> SHOW HOSTS;

步骤 3: 配置项目的环境变量和其他依赖

```
```bash
bash> cd nebula && ./build_dep.sh N
bash> source ~/.bashrc
bash> mkdir build && cd build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 通过 Docker 构建

>**TODO(yee)** docker-compose
> **TODO(yee)** docker-compose
Nebula 提供整个编译环境的 docker 镜像[[vesoft/nebula-dev](https://hub.docker.com/r/vesoft/nebula-dev),支持在本地更改源代码,构建并在容器中调试。执行以下步骤以开始快速开发:

Expand Down Expand Up @@ -39,15 +39,15 @@ docker> make install
docker> cd /usr/local/nebula
```

重全名 nebula 服务
重命名 nebula 服务的配置文件

```bash
docker> cp etc/nebula-graphd.conf.default etc/nebula-graphd.conf
docker> cp etc/nebula-metad.conf.default etc/nebula-metad.conf
docker> cp etc/nebula-storaged.conf.default etc/nebula-storaged.conf
```

启动 服务
启动服务

```bash
docker> ./scripts/nebula.service start all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ nebula storage 提供 key-value 接口,用户可以通过 StorageClient 进行
下面结合示例说明 kv 接口的使用方法:
```cpp
// Put接口
// Put 接口
std::vector<nebula::cpp2::Pair> pairs;
for (int32_t i = 0; i < 1000; i ++) {
auto key = std::to_string(folly::Random::rand32(1000000000));
Expand All @@ -30,20 +30,20 @@ for (int32_t i = 0; i < 1000; i ++) {
std::move(key), std::move(value));
}
// 通过StorageClient发送请求,相应的参数为spaceId,以及写入的key-value pairs
// 通过 StorageClient 发送请求,相应的参数为 spaceId,以及写入的键值对
auto future = storageClient->put(spaceId, std::move(pairs));
// 获取结果
auto resp = std::move(future).get();
```

```cpp
// Get接口
// Get 接口
std::vector<std::string> keys;
for (auto& pair : pairs) {
keys.emplace_back(pair.first);
}

// 通过StorageClient发送请求,相应的参数为spaceId,以及要获取的keys
// 通过 StorageClient 发送请求,相应的参数为 spaceId,以及要获取的 keys
auto future = storageClient->get(spaceId, std::move(keys));
// 获取结果
auto resp = std::move(future).get()
Expand All @@ -62,7 +62,7 @@ if (!resp.succeeded()) {
return;
}
// 失败的Partition以及相应的错误码
// 失败的 Partition 以及相应的错误码
if (!resp.failedParts().empty()) {
for (const auto& partEntry : resp.failedParts()) {
LOG(ERROR) << "Operation Failed in " << partEntry.first << ", Code: "
Expand All @@ -77,12 +77,12 @@ if (!resp.failedParts().empty()) {
对于 Get 接口,用户需要一些操作来获取相应的返回值。Nebula storage 是基于 Raft 的多副本,所有读写操作只能发送给对应 partition 的 leader。当一个 rpc 请求包含了多个跨 partition 的 get 时,Storage Client 会给访问这些 key 所对应的 Partition leader。每个 rpc 返回都单独保存在一个 unordered_map 中,目前还需要用户在这些 unordered_map 中遍历查找 key 是否存在。示例如下:

```cpp
// 查找key对应的value是否在返回结果中,如果存在,则保存在value中
// 查找 key 对应的 value 是否在返回结果中,如果存在,则保存在 value 中
bool found = false;
std::string value;
// resp.responses()中是多个storage server返回的结果
// resp.responses()中是多个 storage server 返回的结果
for (const auto& result : resp.responses()) {
// result.values即为某个storage server返回的key-value paris
// result.values 即为某个 storage server 返回的 key-value paris
auto iter = result.values.find(key);
if (iter != result.values.end()) {
value = iter->second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@ $ docker inspect 591e2f6f48e2 | grep IPAddress
"IPAddress": "172.17.0.2",
```

因此本文将在 3 台主机上按如下的方式部署 Nebula 的集群

因此本文将在3台主机上按如下的方式部署 Nebula 的集群

```
```plain
172.17.0.2 # cluster-2: metad/storaged/graphd
172.17.0.3 # cluster-3: metad/storaged/graphd
172.17.0.4 # cluster-4: metad/storaged/graphd
```

**_注意_** 由于 Nebula 的服务之间通信需要开放一些端口,所以可以临时关掉所有机器上的防火墙,具体使用端口见 `/usr/local/nebula/etc/ `下面的配置文件。也可根据实际情况灵活选取部署方式,此处仅做测试用。
**_注意_** 由于 Nebula 的服务之间通信需要开放一些端口,所以可以临时关掉所有机器上的防火墙,具体使用端口见 `/usr/local/nebula/etc/` 下面的配置文件。也可根据实际情况灵活选取部署方式,此处仅做测试用。

## 配置

Expand All @@ -89,7 +88,7 @@ Nebula 的所有配置文件都位于 `/usr/local/nebula/etc` 目录下,并

metad 通过 raft 协议保证高可用,需要为每个 metad 的 service 都配置该服务部署的机器 ip 和端口。主要涉及 meta_server_addrs 和 local_ip 两个字段,其他使用默认配置。cluster-2 上的两项配置示例如下所示

```
```plain
# Peers
--meta_server_addrs=172.17.0.2:45500,172.17.0.3:45500,172.17.0.4:45500
# Local ip
Expand All @@ -104,7 +103,7 @@ metad 通过 raft 协议保证高可用,需要为每个 metad 的 service 都

graphd 运行时需要从 metad 中获取 Schema 数据,所以在配置中必须显示指定集群中 metad 的 ip 地址和端口选项 meta_server_addrs ,其他使用默认配置。cluster-2 上的 graphd 配置如下

```
```plain
# Meta Server Address
--meta_server_addrs=172.17.0.2:45500,172.17.0.3:45500,172.17.0.4:45500
```
Expand All @@ -115,7 +114,7 @@ graphd 运行时需要从 metad 中获取 Schema 数据,所以在配置中必

storaged 也使用 raft 协议保证高可用,在数据迁移时会与 metad 通信,所以需要配置 metad 的地址和端口 `meta_server_addrs` 和本机地址 `local_ip` ,其 peers 可以通过 metad 获得。cluster-2 上的部分配置选项如下

```
```plain
# Meta server address
--meta_server_addrs=172.17.0.2:45500,172.17.0.3:45500,172.17.0.4:45500
# Local ip
Expand Down Expand Up @@ -178,7 +177,7 @@ Welcome to Nebula Graph (Version 5f656b5)

表明三台集群已部署成功,插入[数据](https://github.com/vesoft-inc/nebula/blob/master/docs/manual-CN/get-started.md#%E5%88%9B%E5%BB%BA%E5%9B%BE%E6%95%B0%E6%8D%AE)进行测试。

```
```ngql
$a=GO FROM 201 OVER like yield like._dst as id; GO FROM $a.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade
=============================
Expand Down Expand Up @@ -207,7 +206,7 @@ $ /usr/local/nebula/scripts/nebula.service status storaged

登录 cluster-2,使用 `SHOW HOSTS` 查看

```
```ngql
> SHOW HOSTS
=============================================================================================
Expand All @@ -227,7 +226,7 @@ $ /usr/local/nebula/scripts/nebula.service status storaged

测试数据是否可读

```
```ngql
$a=GO FROM 201 OVER like yield like._dst as id; GO FROM $a.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade
=============================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# 集群部署

---

本节介绍 `Nebula` 的部署
---

## 下载并安装包

Expand All @@ -13,13 +10,13 @@

`CentOS` 系统:

```
```bash
rpm -ivh nebula-{VERSION}.{SYSTEM_VERSION}.x86_64.rpm
```

`Ubuntu` 系统:

```
```bash
dpkg -i nebula-{VERSION}.{SYSTEM_VERSION}.amd64.deb
```

Expand All @@ -28,21 +25,29 @@ dpkg -i nebula-{VERSION}.{SYSTEM_VERSION}.amd64.deb
启动多副本 Meta 服务需将多个地址配置到 `meta_server_addrs`,地址间需使用逗号分隔。

使用 `data_path` 设置 `Meta` 的底层存储路径。
***

### 启动 Nebula 集群

目前,nebula 集群由 `scripts/services.sh` 运维,可使用此脚本 `start``stop``restart` 重启集群。

示例命令如下:

```
```bash
scripts/services.sh <start|stop|restart|status|kill>
```

metas, storages 和 graphs 包含其自身的 hosts。

---
### 连接 Nebula Graph

```bash
> bin/nebula -u=user -p=password --addr={graphd IP address} --port={graphd listening port}
```

* -u 用来设置用户名称,默认值为 `user`
* -p 用来设置密码,用户 `user` 的密码为 `password`
* --addr 为 graphd IP 地址
* --port 为 graphd 服务端口,默认值为 `3699`

#### 配置引用

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CONFIG 语法

Nebula使用`gflags`进行运行时配置。
Nebula使用 `gflags` 进行运行时配置。

相关的 `gflags` 参数有三个,分别为 rocksdb_db_options,rocksdb_column_family_options,rocksdb_block_based_table_options。
三个参数均为 json 格式,其中每个参数 key 和 value 均为 string 格式。例如可以在 storage 的 conf 文件中做如下设置
Expand Down Expand Up @@ -48,7 +48,7 @@ UPDATE CONFIGS storage:rocksdb_column_family_options =
## 显示变量

```ngql
SHOW CONFIG graph|meta|storage
SHOW CONFIGS graph|meta|storage
```

例如
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Nebula 提供了 `Spark-SSTFile-Generator` 工具。

SST 文件名格式为 `{TYPE}-${FIRST_KEY_IN_THIS_FILE}.sst`,其中 `TYPE` 表示数据类型,`FIRST_KEY_IN_THIS_FILE` 为文件中的起始 key。(如果你想自己写工具生成 SST 文件,需要保证每个 `SST` 文件中的 key 是有序的。)

请确认所有 server 已安装 `Hadoop`,并且 `HADOOP_HOME ` 已设置。
请确认所有 server 已安装 `Hadoop`,并且 `HADOOP_HOME` 已设置。

运行 nebula console,执行 Download 命令:

Expand All @@ -38,7 +38,7 @@ nebula > DOWNLOAD HDFS "hdfs://${HADOOP_HOST}:${HADOOP_PORT}/${HADOOP_PATH}"
- HADOOP_PORT 指定 Hadoop NameNode 端口号
- HADOOP_PATH 指定 Hadoop 数据存放目录

如果 `download` 过程出现错误,请删除 `data/download` 目录下相应的数据文件,并尝试重新下载。如果遇到多次失败,请在 [GitHub](https://github.com/vesoft-inc/nebula/issues) 给提 issue。
如果 `download` 过程出现错误,请删除 `data/download` 目录下相应的数据文件,并尝试重新下载。如果遇到多次失败,请在 [GitHub](https://github.com/vesoft-inc/nebula/issues) issue。

数据下载完毕后,重新执行该命令不会发生任何操作。

Expand All @@ -52,4 +52,4 @@ nebula > INGEST

该命令将加载 `download` 目录中的 `SST` 文件。

**注意:**数据量较大时 `ingest` 会阻塞 `RocksDB`,请避免在请求高峰执行该命令。
**注意:** 数据量较大时 `ingest` 会阻塞 `RocksDB`,请避免在请求高峰执行该命令。
Loading

0 comments on commit 857b990

Please sign in to comment.