92 lines
2.5 KiB
Markdown
92 lines
2.5 KiB
Markdown
|
# 启动 Docker 容器
|
|||
|
|
|||
|
1. **启动容器**
|
|||
|
|
|||
|
在根目录下执行以下命令以启动Docker容器:
|
|||
|
```bash
|
|||
|
docker-compose up -d
|
|||
|
```
|
|||
|
|
|||
|
2. **查看容器状态**
|
|||
|
|
|||
|
使用以下命令检查容器是否正常运行:
|
|||
|
```bash
|
|||
|
docker ps
|
|||
|
```
|
|||
|
|
|||
|
3. **配置 MySQL Binlog (仅适用于 windos)**
|
|||
|
|
|||
|
执行以下命令以确保MySQL配置文件权限正确:
|
|||
|
```bash
|
|||
|
chmod 644 /etc/mysql/conf.d/my.cnf
|
|||
|
```
|
|||
|
这一步是为了启用binlog功能。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
修改配置文件后,重启容器使更改生效:
|
|||
|
```bash
|
|||
|
docker-compose restart
|
|||
|
```
|
|||
|
|
|||
|
|
|||
|
4. **验证 Binlog 是否开启**
|
|||
|
进入MySQL容器并执行以下SQL语句来确认binlog是否已成功开启:
|
|||
|
```sql
|
|||
|
SHOW VARIABLES LIKE 'log_bin';
|
|||
|
```
|
|||
|
|
|||
|
如果显示 `ON` 则表示binlog已成功开启。
|
|||
|

|
|||
|
|
|||
|
可以看到我建的测试数据库demo(有表有数据)和数据同步(空表无数据)
|
|||
|

|
|||
|
|
|||
|
### 访问 Dinky 平台
|
|||
|
|
|||
|
打开浏览器访问 [http://localhost:8888/](http://localhost:8888/) 进入Dinky平台。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
#### 注册中心配置集群
|
|||
|
|
|||
|
在平台上进行注册中心的配置,设置集群信息。
|
|||
|
|
|||
|
#### 新建整库同步 Flink SQL 任务并运行
|
|||
|
|
|||
|
按照界面提示新建一个整库同步Flink SQL任务,并开始运行该任务。
|
|||
|
|
|||
|

|
|||
|
```sql
|
|||
|
-- 整库同步
|
|||
|
SET 'execution.checkpointing.interval' = '10s';
|
|||
|
SET 'execution.checkpointing.externalized-checkpoint-retention' = 'RETAIN_ON_CANCELLATION';
|
|||
|
|
|||
|
EXECUTE CDCSOURCE cdc_mysql WITH (
|
|||
|
'connector' = 'mysql-cdc',
|
|||
|
'hostname' = '10.23.0.209',
|
|||
|
'port' = '3336',
|
|||
|
'username' = 'root',
|
|||
|
'password' = 'mysql57',
|
|||
|
'checkpoint' = '3000',
|
|||
|
'scan.startup.mode' = 'initial',
|
|||
|
'parallelism' = '1',
|
|||
|
'server-time-zone' = 'Asia/Shanghai',
|
|||
|
'table-name' = 'demo\.admin_menu,demo\.admin_role',
|
|||
|
'sink.connector' = 'jdbc',
|
|||
|
'sink.url' = 'jdbc:mysql://10.23.0.209:3336/to_demo?characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai',
|
|||
|
'sink.username' = 'root',
|
|||
|
'sink.password' = 'mysql57',
|
|||
|
'sink.sink.db' = 'to_demo',
|
|||
|
'sink.table.prefix' = 'ods_',
|
|||
|
'sink.table.lower' = 'true',
|
|||
|
'sink.table-name' = '#{tableName}',
|
|||
|
'sink.driver' = 'com.mysql.jdbc.Driver',
|
|||
|
'sink.sink.buffer-flush.interval' = '2s',
|
|||
|
'sink.sink.buffer-flush.max-rows' = '100',
|
|||
|
'sink.sink.max-retries' = '5',
|
|||
|
'sink.auto.create' = 'true'
|
|||
|
);
|
|||
|
```
|
|||
|
|