Skip to content

Commit

Permalink
chore: add dynamic_routing.md and update dockerfile (apache#224)
Browse files Browse the repository at this point in the history
* docs: add dynamic_routing.md

* refactor by CR

* refactor by CR
  • Loading branch information
chunshao90 authored Sep 1, 2022
1 parent 3ee4d3f commit 295a25d
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 27 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/docker-build-image.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Test Docker image build

on:
pull_request:
paths:
- '.github/workflows/docker-build-image.yml'
- 'Dockerfile'
- 'docker/**'
push:
paths:
- '.github/workflows/docker-build-image.yml'
Expand All @@ -23,4 +28,11 @@ jobs:
run: >-
docker run -p ${CERESDB_ADDR}:${CERESDB_PORT}:${CERESDB_PORT} -d ceresdb-server &&
sleep 10 &&
bash ./docker/basic.sh
bash ./docker/basic.sh &&
docker rm -f ceresdb-server
- name: Test the Built Image With Config
run: >-
docker run -p ${CERESDB_ADDR}:${CERESDB_PORT}:${CERESDB_PORT} -v `pwd`/docs/minimal.toml:/etc/ceresdb/ceresdb.toml -d ceresdb-server &&
sleep 10 &&
bash ./docker/basic.sh &&
docker rm -f ceresdb-server
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ COPY --from=build /ceresdb/target/release/ceresdb-server /usr/bin/ceresdb-server
RUN chmod +x /usr/bin/ceresdb-server

COPY ./docker/entrypoint.sh /entrypoint.sh
COPY ./configs/ceresdb.toml /etc/ceresdb/ceresdb.toml
COPY ./docs/minimal.toml /etc/ceresdb/ceresdb.toml

COPY ./docker/tini /tini
RUN chmod +x /tini
Expand Down
18 changes: 0 additions & 18 deletions configs/ceresdb.toml

This file was deleted.

30 changes: 30 additions & 0 deletions docs/example-cluster-0.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
bind_addr = "0.0.0.0"
http_port = 5440
grpc_port = 8831
mysql_port = 3307
log_level = "info"
deploy_mode = "Cluster"

[analytic]
wal_path = "/tmp/ceresdb"
sst_data_cache_cap = 10000
sst_meta_cache_cap = 10000

[analytic.storage]
type = "Local"
data_path = "/tmp/ceresdb"

[cluster]
cmd_channel_buffer_size = 10

[cluster.node]
addr = "127.0.0.1"
port = 8831

[cluster.meta_client]
# Only support "defaultCluster" currently.
cluster_name = "defaultCluster"
meta_addr = "{meta_addr}:2379"
lease = "10s"
timeout = "5s"

30 changes: 30 additions & 0 deletions docs/example-cluster-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
bind_addr = "0.0.0.0"
http_port = 5441
grpc_port = 8832
mysql_port = 13307
log_level = "info"
deploy_mode = "Cluster"

[analytic]
wal_path = "/tmp/ceresdb2"
sst_data_cache_cap = 10000
sst_meta_cache_cap = 10000

[analytic.storage]
type = "Local"
data_path = "/tmp/ceresdb2"

[cluster]
cmd_channel_buffer_size = 10

[cluster.node]
addr = "127.0.0.1"
port = 8832

[cluster.meta_client]
# Only support "defaultCluster" currently.
cluster_name = "defaultCluster"
meta_addr = "{meta_addr}:2379"
lease = "10s"
timeout = "5s"

99 changes: 99 additions & 0 deletions docs/guides/src/deploy/dynamic_routing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Dynamic Routing
This guide shows how to deploy a CeresDB cluster with CeresMeta.

## Target
First, let's assume that our target is to deploy a cluster consisting of two CeresDB instances on the same machine. And a large cluster of more CeresDB instances can deploy according to the two-instances example.

## Start CeresDBs
You can use the following command to create a CeresDB cluster with two instances.
1. Start CeresMeta first
Refer to [CeresMeta](https://github.com/CeresDB/ceresmeta)

2. Prepare config of CeresDB
* Replace `{meta_addr}` with the actual address of CeresMeta in config file

```toml
# {project_path}/docs/example-cluster-0.toml
bind_addr = "0.0.0.0"
http_port = 5440
grpc_port = 8831
mysql_port = 3307
log_level = "info"
deploy_mode = "Cluster"

[analytic]
wal_path = "/tmp/ceresdb"
sst_data_cache_cap = 10000
sst_meta_cache_cap = 10000

[analytic.storage]
type = "Local"
data_path = "/tmp/ceresdb"

[cluster]
cmd_channel_buffer_size = 10

[cluster.node]
addr = "127.0.0.1"
port = 8831

[cluster.meta_client]
# Only support "defaultCluster" currently.
cluster_name = "defaultCluster"
meta_addr = "{meta_addr}:2379"
lease = "10s"
timeout = "5s"
```

```toml
# {project_path}/docs/example-cluster-1.toml
bind_addr = "0.0.0.0"
http_port = 5441
grpc_port = 8832
mysql_port = 13307
log_level = "info"
deploy_mode = "Cluster"

[analytic]
wal_path = "/tmp/ceresdb2"
sst_data_cache_cap = 10000
sst_meta_cache_cap = 10000

[analytic.storage]
type = "Local"
data_path = "/tmp/ceresdb2"

[cluster]
cmd_channel_buffer_size = 10

[cluster.node]
addr = "127.0.0.1"
port = 8832

[cluster.meta_client]
# Only support "defaultCluster" currently.
cluster_name = "defaultCluster"
meta_addr = "{meta_addr}:2379"
lease = "10s"
timeout = "5s"
```

3. Start CeresDB instances
* You need to replace `{project_path}` with the actual project path

```bash
# Update address of CeresMeta in CeresDB config.
docker run -d --name ceresdb-server \
-p 8831:8831 \
-p 3307:3307 \
-p 5440:5440 \
-v {project_path}/docs/example-cluster-0.toml:/etc/ceresdb/ceresdb.toml \
ceresdb/ceresdb-server:v0.3.1

docker run -d --name ceresdb-server2 \
-p 8832:8832 \
-p 13307:13307 \
-p 5441:5441 \
-v {project_path}/docs/example-cluster-1.toml:/etc/ceresdb/ceresdb.toml \
ceresdb/ceresdb-server:v0.3.1
```
4 changes: 2 additions & 2 deletions docs/guides/src/deploy/static_routing.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Static Routing
This guide shows how to deloy a CeresDB cluster with static, rule-based routing.
This guide shows how to deploy a CeresDB cluster with static, rule-based routing.

The crucial point here is that CeresDB server provides configurable routing function on table name so what we need is just a valid config containing routing rules which will be shipped to every CeresDB instance in the cluster.

## Target
First of all, let's assume that our target is to deploy a cluster consisting of two CeresDB instances on the same machine. And a large cluster of more CeresDB instances can deployed according to the two-instances example.
First, let's assume that our target is to deploy a cluster consisting of two CeresDB instances on the same machine. And a large cluster of more CeresDB instances can deploy according to the two-instances example.

## Prepare Config
### Basic
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/src/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ This page shows you how to get started with CeresDB quickly. You'll start a stan

## Start server

[CeresDB docker image](https://hub.docker.com/r/ceresdb/ceresdb-server) is the easiest way to get started, if you haven't install Docker, go [there](https://www.docker.com/products/docker-desktop/) to install it first.
[CeresDB docker image](https://hub.docker.com/r/ceresdb/ceresdb-server) is the easiest way to get started, if you haven't installed Docker, go [there](https://www.docker.com/products/docker-desktop/) to install it first.

You can use command below to start a standalone server
```bash
docker run -d --name ceresdb-server \
-p 8831:8831 \
-p 3307:3307 \
-p 5440:5440 \
ceresdb/ceresdb-server:v0.2.0
ceresdb/ceresdb-server:v0.3.1
```

CeresDB will listen three ports when start:
Expand Down
6 changes: 3 additions & 3 deletions configs/minimal.toml → docs/minimal.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ wal_path = "/tmp/ceresdb"
sst_data_cache_cap = 10000
sst_meta_cache_cap = 10000

[[meta_client.cluster_view.schema_shards]]
[[static_route.topology.schema_shards]]
schema = 'public'
auto_create_tables = true

[[meta_client.cluster_view.schema_shards.shard_views]]
[[static_route.topology.schema_shards.shard_views]]
shard_id = 0

[meta_client.cluster_view.schema_shards.shard_views.node]
[static_route.topology.schema_shards.shard_views.endpoint]
addr = "127.0.0.1"
port = 8831

0 comments on commit 295a25d

Please sign in to comment.