Skip to content

Commit

Permalink
fix dgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
chendelin1982 authored Dec 16, 2023
1 parent 28a2098 commit 7dc392e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 69 deletions.
20 changes: 16 additions & 4 deletions apps/dgraph/.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
DB_DGRAPH_VERSION=latest
W9_REPO=dgraph/standalone
W9_REPO=dgraph/dgraph
W9_DIST=community
W9_VERSION=latest
W9_POWER_PASSWORD=UGz0IARz117ssO%

#### -- Not allowed to edit below environments when recreate app based on existing data -- ####
W9_ID=dgraph
W9_DGRAPH_GraphQL_PORT_SET=5080
W9_DGRAPH_gRPC2_PORT_SET=6080

W9_Alpha_HTTP_PORT_SET=8080
W9_Zero_HTTP_PORT_SET=6080

W9_Alpha_gRPC_PORT_SET=9080
W9_Zero_gRPC_PORT_SET=5080

W9_HTTP_PORT=8000
W9_HTTP_PORT_SET=8000

W9_URL=appname.example.com
# acl control is function of Enterprise edition
W9_LOGIN_ServerURL=http://${W9_URL}:{W9_Alpha_HTTP_PORT_SET}
W9_LOGIN_Auth_Token=$W9_POWER_PASSWORD

W9_NETWORK=websoft9
#### --------------------------------------------------------------------------------------- ####
#### --------------------------------------------------------------------------------------- ####

# Dgraph environments: https://dgraph.io/docs/deploy/config/
DGRAPH_ALPHA_SECURITY="whitelist=0.0.0.0/0;token=${W9_POWER_PASSWORD}"
2 changes: 0 additions & 2 deletions apps/dgraph/.env-cluster

This file was deleted.

65 changes: 59 additions & 6 deletions apps/dgraph/Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,68 @@ Dgraph 是一个分布式图数据库。
* dgraph/standalone
* dgraph/dgraph

dgraph/standalone 是用于单机使用的,dgraph/dgraph 是用于分布式的。
dgraph/standalone 是用于单机使用的(默认已经启动 zero 和 alpha 两个服务),dgraph/dgraph 是用于分布式的。

分布式包括:zero(集群协调器),alpha(数据库节点),metal(图形化) 三个组件
分布式包括三个组件:

- zero(集群协调器)
- alpha(数据库节点)
- metal(图形化)

## 配置
## Ratel 使用说明

目前 http://ip:8000 访问UI,输入 http://8.142.3.195:8080 连接
### 测试公开的实例

## To do
1. Metal 可以先连接到官方公开的实例 https://play.dgraph.io 上,用于测试。
2. 连接成功后运行,便可以运行得到关系图
```
{
user(func: eq(name, "Alice")) {
name
friend {
name
age
}
}
}
```

- account
### 测试 Dgraph alpha

1. 连接到 http://InternetIP:8080 (这个 URL 不支持容器名称)
2. 无需密码即可登录

> groot 密码设置是企业版功能(ACL)

### 端口说明

在 Dgraph 中,每个 Alpha 和 Zero 节点都开放了几个不同的端口,以支持不同的通信和服务。这些端口包括:

1. **gRPC 端口**:这是 Dgraph 的主要通信端口,用于处理来自客户端的 gRPC 请求。对于 Alpha 节点,默认的 gRPC 端口是 9080。对于 Zero 节点,默认的 gRPC 端口是 5080。

2. **HTTP 端口**:这个端口用于处理来自客户端的 HTTP 请求,包括查询和突变。对于 Alpha 节点,默认的 HTTP 端口是 8080。对于 Zero 节点,默认的 HTTP 端口是 6080。

3. **内部端口**:这是用于集群内部通信的端口。这个端口是 `--my` 参数设置的端口。对于 Alpha 节点,默认的内部端口是 7080。对于 Zero 节点,默认的内部端口是 5080。

这些默认的端口可以根据需要进行更改,但你需要确保所有的 Dgraph Alpha 和 Dgraph Zero 节点都使用正确的端口,以便它们可以在集群中正确地找到并通信。

当你在浏览器中打开 Ratel 时,它会要求你输入 Dgraph Alpha 的 HTTP 端口的 URL。

### 账号

只有企业版才有 ACL 功能

## FAQ

#### Ratal 加载不完整?

应用自身包含一些外部 js 导致

#### Ratal 无密码即可访问?

是的,需要通过 Nginx 进行密码控制

#### whitelist and token 是用来控制?

控制对数据库的管理操作,例如:建表。但是无法控制查询,即任何外部连接都可以查询。
49 changes: 0 additions & 49 deletions apps/dgraph/docker-compose-cluster.yml

This file was deleted.

31 changes: 23 additions & 8 deletions apps/dgraph/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file only running single dgraph and web-base gui ratel
# image: https://hub.docker.com/r/dgraph/standalone
# docs: https://dgraph.io/docs/deploy/installation/single-host-setup
# image: https://hub.docker.com/r/dgraph/dgraph/
# docs: https://dgraph.io/docs/deploy/installation
# compose: https://github.com/dgraph-io/dgraph/blob/main/contrib/config/docker/docker-compose.yml
# config: https://dgraph.io/docs/deploy/config/

version: '3.8'

Expand All @@ -12,20 +13,34 @@ services:
- ${W9_HTTP_PORT_SET}:8000
env_file: .env

dgraph:
zero:
image: $W9_REPO:${W9_VERSION}
container_name: ${W9_ID}-dgraph
container_name: ${W9_ID}-zero
volumes:
- dgraph:/dgraph
ports:
- ${W9_DGRAPH_GraphQL_PORT_SET}:8080
- ${W9_DGRAPH_gRPC2_PORT_SET}:9080
- ${W9_Zero_HTTP_PORT_SET}:6080
- ${W9_Zero_gRPC_PORT_SET}:5080
restart: on-failure
command: dgraph zero --my=${W9_ID}-zero:5080
env_file: .env

alpha:
image: $W9_REPO:${W9_VERSION}
container_name: ${W9_ID}-alpha
volumes:
- dgraph:/dgraph
ports:
- ${W9_Alpha_HTTP_PORT_SET}:8080
- ${W9_Alpha_gRPC_PORT_SET}:9080
restart: on-failure
env_file: .env
command: dgraph alpha --my=${W9_ID}-alpha:7080 --zero=${W9_ID}-zero:5080

networks:
default:
name: ${W9_NETWORK}
external: true

volumes:
dgraph:
dgraph:

0 comments on commit 7dc392e

Please sign in to comment.