Skip to content

Commit

Permalink
[skip ci] chore: add docker run to quick start, push latest tag in ci (
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-Git authored and ming535 committed Jul 19, 2019
1 parent 7369fa9 commit 909a1ce
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 37 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ jobs:
- make build-linux
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker build -t moiot/gravity:${TRAVIS_TAG} -f Dockerfile.gravity .
- docker push moiot/gravity:${TRAVIS_TAG}
- docker push moiot/gravity:${TRAVIS_TAG}
- docker tag moiot/gravity:${TRAVIS_TAG} moiot/gravity:latest
- docker push moiot/gravity:latest
4 changes: 3 additions & 1 deletion Dockerfile.gravity
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai"

WORKDIR /

COPY bin/gravity-linux-amd64 /gravity
COPY bin/gravity-linux-amd64 /gravity

CMD /gravity -config=/etc/gravity/config.toml
32 changes: 13 additions & 19 deletions docs/2.0/01-quick-start-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This document takes synchronizing the data of the local MySQL instance and data
) ENGINE=InnoDB DEFAULT CHARSET=utf8
```

## Step 2: Compile (TODO: Download binary from GitHub after it is open sourced)
## Step 2: Compile (optional, docker image is ready for use)

[Configure the Go environment](https://golang.org/doc/install) and compile:

Expand All @@ -38,13 +38,13 @@ cd gravity && make
```

## Step 3: Synchronize data
## Step 3: Write config file

You can choose to synchronize data between two MySQL clusters or from MySQL to Kafka.

- Synchronize data between two MySQL clusters

1. Create the configuration file, as shown in the following file `mysql2mysql.toml`:
Create the configuration file, as shown in the following file `config.toml`:

```toml
# name (required)
Expand Down Expand Up @@ -89,17 +89,9 @@ You can choose to synchronize data between two MySQL clusters or from MySQL to K
target-table = "test_target_table"
```

2. Enable `gravity`.

```bash
bin/gravity -config mysql2mysql.toml
```

3. After the incremental synchronization between `test_source_table` and `test_target_table` begins, you can insert data in the source cluster and then you will see the change in the target cluster.

- Synchronize data from MySQL to Kafka

1. Create the configuration file, as shown in the following file `mysql2kafka.toml`:
Create the configuration file, as shown in the following file `config.toml`:

```toml
Expand Down Expand Up @@ -134,10 +126,12 @@ You can choose to synchronize data between two MySQL clusters or from MySQL to K
dml-topic = "test"
```

2. Enable `gravity`:

```bash
bin/gravity -config mysql2kafka.toml
```

3. The data mutation of `test`.`test_source_table` table in the MySQL cluster is sent to `test` of Kafka.
## Step 4: Start Gravity
From binary
```bash
bin/gravity -config mysql2mysql.toml
```
or docker
```bash
docker run -v ${PWD}/config.toml:/etc/gravity/config.toml -d --net=host moiot/gravity:latest
```
26 changes: 10 additions & 16 deletions docs/2.0/01-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CREATE TABLE `test`.`test_target_table` (
```


#### 编译 (TODO: 开源后直接从 github 下载 binary)
#### 编译(可选,可以直接用 docker)

首先,[配置好 Go 语言环境](https://golang.org/doc/install) 并编译

Expand All @@ -36,7 +36,7 @@ cd gravity && make

#### MySQL 到 MySQL 同步

创建如下配置文件 `mysql2mysql.toml`
创建如下配置文件 `config.toml`

```toml
# name 必填
Expand Down Expand Up @@ -76,17 +76,9 @@ target-schema = "test"
target-table = "test_target_table"
```

启动 `gravity`

```bash
bin/gravity -config mysql2mysql.toml
```

`test_source_table``test_target_table` 之间的同步已经开始,现在可以在源端插入数据,然后在目标端会看到相应的变化。

#### MySQL 到 Kafka

创建如下配置文件 `mysql2kafka.toml`
创建如下配置文件 `config.toml`

```toml
name = "mysql2kafkaDemo"
Expand Down Expand Up @@ -119,10 +111,12 @@ match-table = "test_source_table"
dml-topic = "test"
```

启动 `gravity`

## 启动 gravity
从编译完的程序
```bash
bin/gravity -config mysql2kafka.toml
bin/gravity -config mysql2mysql.toml
```

MySQL 源库的 `test`.`test_source_table` 这个表的数据变更会发送到 Kafka 的 `test` 这个 topic。
从 docker
```bash
docker run -v ${PWD}/config.toml:/etc/gravity/config.toml -d --net=host moiot/gravity:latest
```

0 comments on commit 909a1ce

Please sign in to comment.