diff --git a/.travis.yml b/.travis.yml index ab6e5b0a..e76d282e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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} \ No newline at end of file + - docker push moiot/gravity:${TRAVIS_TAG} + - docker tag moiot/gravity:${TRAVIS_TAG} moiot/gravity:latest + - docker push moiot/gravity:latest \ No newline at end of file diff --git a/Dockerfile.gravity b/Dockerfile.gravity index 145ef744..8359f120 100644 --- a/Dockerfile.gravity +++ b/Dockerfile.gravity @@ -6,4 +6,6 @@ RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" WORKDIR / -COPY bin/gravity-linux-amd64 /gravity \ No newline at end of file +COPY bin/gravity-linux-amd64 /gravity + +CMD /gravity -config=/etc/gravity/config.toml \ No newline at end of file diff --git a/docs/2.0/01-quick-start-en.md b/docs/2.0/01-quick-start-en.md index 47f62687..5b012250 100644 --- a/docs/2.0/01-quick-start-en.md +++ b/docs/2.0/01-quick-start-en.md @@ -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: @@ -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) @@ -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 @@ -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. \ No newline at end of file +## 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 +``` \ No newline at end of file diff --git a/docs/2.0/01-quick-start.md b/docs/2.0/01-quick-start.md index 8d5e40ca..2414213f 100644 --- a/docs/2.0/01-quick-start.md +++ b/docs/2.0/01-quick-start.md @@ -19,7 +19,7 @@ CREATE TABLE `test`.`test_target_table` ( ``` -#### 编译 (TODO: 开源后直接从 github 下载 binary) +#### 编译(可选,可以直接用 docker) 首先,[配置好 Go 语言环境](https://golang.org/doc/install) 并编译 @@ -36,7 +36,7 @@ cd gravity && make #### MySQL 到 MySQL 同步 -创建如下配置文件 `mysql2mysql.toml` +创建如下配置文件 `config.toml` ```toml # name 必填 @@ -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" @@ -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。 \ No newline at end of file +从 docker +```bash +docker run -v ${PWD}/config.toml:/etc/gravity/config.toml -d --net=host moiot/gravity:latest +``` \ No newline at end of file