Unverified Commit 8153fe2f authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Optimization-1631][script] Optimize auto.sh and remove useless files (#1633)

parent 336496a1
......@@ -18,63 +18,56 @@ Its main feature are as follows:
- Immersive Flink SQL Data Development: Automatic prompt completion, syntax highlighting, statement beautification, online debugging, syntax verification, execution plan, MetaStore, lineage, version comparison, etc.
- Support FlinkSQL multi-version development and execution modes: Local,Standalone,Yarn/Kubernetes Session,Yarn Per-Job,Yarn/Kubernetes Application.
- Support Apache Flink ecology: Connector,FlinkCDC,Table Store,etc.
- Support FlinkSQL syntax enhancement: Table-valued aggregate functions, global variables, execution environments, statement merging, database synchronization, shared sessions, etc.
- Support FlinkSQL syntax enhancement: Database synchronization, execution environments, global variables, statement merging, table-valued aggregate functions, etc.
- Supports real-time warehousing and lake entry of the entire FlinkCDC database, multi-database output, and automatic table creation.
- Support SQL job development: ClickHouse,Doris,Hive,Mysql,Oracle,Phoenix,PostgreSql,SqlServer,StarRocks,etc.
- Support SQL job development: ClickHouse, Doris, Hive, Mysql, Oracle, Phoenix, PostgreSql, Presto, SqlServer, StarRocks, etc.
- Support real-time online debugging preview Table, ChangeLog, statistical chart and UDF.
- Support Flink Catalog, data source metadata online query and management.
- Support real-time task operation and maintenance: Online and offline, job information, cluster information, job snapshot, exception information, data map, data exploration, historical version, alarm record, etc.
- Support as multi-version FlinkSQL Server and OpenApi capability.
- Support real-time job alarm and alarm group: DingTalk, WeChat, Feishu, E-mail, etc.
- Support automatically managed SavePoint/CheckPoint recovery and triggering mechanisms: latest, earliest, specified, etc.
- Support resource management: Cluster instance, cluster configuration, Jar, data source, alarm group, alarm instance, document, user, system configuration, etc.
- Support resource management: Cluster instance, cluster configuration, jar, data source, alarm group, alarm instance, document, global variable, system configuration, etc.
- Support enterprise-level management: multi-tenant, user, role, project space.
- More hidden features are waiting for friends to explore.
## Principle
![dinky_principle](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/main/dinky_principle.png)
![dinky_principle](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/main/dinky_principle.png)
## Run the Screenshot
> FlinkSQL Studio
![datastudio](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/datastudio.png)
![datastudio](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/datastudio.png)
> Grammar Check
![checksql](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/checksql.png)
![checksql](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/checksql.png)
> Version Management
![versiondiff](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/versiondiff.png)
![versiondiff](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/versiondiff.png)
> lineage
![lineage](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/lineage.png)
![lineage](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/lineage.png)
> BI Charts
![charts](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/charts.png)
![charts](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/charts.png)
> Metadata Query
![metadata](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/metadata.png)
![metadata](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/metadata.png)
> Task Monitoring
![monitor](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/monitor.png)
![monitor](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/monitor.png)
> Job Information
![jobinfo](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/jobinfo.png)
## Near-term Plans
- [ ] Multi-tenancy and Namespaces
- [ ] Global lineage and influence analysis
- [ ] Unified Metadata Management
- [x] Flink Metadata Store
- [x] Real-time warehouse entry into the lake
![jobinfo](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/jobinfo.png)
## Participate in Contributions
......@@ -82,6 +75,10 @@ Welcome to join the community, build a win-win situation, please refer to the co
## How to Deploy
- The dev branch is the 0.8 reconstructed version, which is still unstable.
- The 0.7 branch is the current stable version. Please use this branch for compilation and debugging.
See [source code compilation](https://github.com/DataLinkDC/dinky/blob/dev/docs/docs/build_deploy/build.md) and [installation and deployment](https://github.com/DataLinkDC/dinky/blob/dev/docs/docs/build_deploy/deploy.md) for details.
## How to Upgrade
......@@ -122,19 +119,19 @@ A partial list of acknowledgements follows:
[SpringBoot]()
Thanks to [JetBrains](https://www.jetbrains.com/?from=dinky) for sponsoring a free open source license.
Thanks to [JetBrains](https://www.jetbrains.com/?from=dlink) for sponsoring a free open source license.
[![JetBrains](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/main/jetbrains.svg)](https://www.jetbrains.com/?from=dinky)
[![JetBrains](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/main/jetbrains.svg)](https://www.jetbrains.com/?from=dlink)
## Get Help
1.Submit an issue.
1.Create an issue and describe it clearly.
2.Visit the [official website](http://www.dinky.top/#/) website to read the latest documentation manual.
2.Visit the [official website](http://www.dlink.top/#/) website to read the latest documentation manual.
3.It is recommended to scan the code to enter the DingTalk group.
<img src="https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/main/dinkydingding.jpg" alt="dinkydingding" style="zoom:30%;" />
<img src="https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/main/dinkydingding.jpg" alt="dinkydingding" style="zoom:30%;" />
4.Enter the WeChat user community group (recommended, add WeChat `wenmo_ai` to invite into the group) and QQ user community group (**543709668**) to communicate, and apply for the remarks "Dinky + company name + position".
......
......@@ -18,63 +18,56 @@ Dinky 是一个 `开箱即用` 、`易扩展` ,以 `Apache Flink` 为基础,
- 沉浸式 FlinkSQL 数据开发:自动提示补全、语法高亮、语句美化、在线调试、语法校验、执行计划、MetaStore、血缘分析、版本对比等
- 支持 FlinkSQL 多版本开发及多种执行模式:Local、Standalone、Yarn/Kubernetes Session、Yarn Per-Job、Yarn/Kubernetes Application
- 支持 Apache Flink 生态:Connector、FlinkCDC、Table Store 等
- 支持 FlinkSQL 语法增强:表值聚合函数、全局变量、执行环境、语句合并、整库同步、共享会话等
- 支持 FlinkSQL 语法增强:整库同步、执行环境、全局变量、语句合并、表值聚合函数等
- 支持 FlinkCDC 整库实时入仓入湖、多库输出、自动建表
- 支持 SQL 作业开发:ClickHouse、Doris、Hive、Mysql、Oracle、Phoenix、PostgreSql、SqlServer、StarRocks 等
- 支持实时在线调试预览 Table、 ChangeLog、统计图和 UDF
- 支持 SQL 作业开发:ClickHouse、Doris、Hive、Mysql、Oracle、Phoenix、PostgreSql、Presto、SqlServer、StarRocks 等
- 支持实时在线调试预览 Table、 ChangeLog、Charts 和 UDF
- 支持 Flink Catalog、数据源元数据在线查询及管理
- 支持实时任务运维:上线下线、作业信息、集群信息、作业快照、异常信息、数据地图、数据探查、历史版本、报警记录等
- 支持作为多版本 FlinkSQL Server 以及 OpenApi 的能力
- 支持实时作业报警及报警组:钉钉、微信企业号、飞书、邮箱等
- 支持自动托管的 SavePoint/CheckPoint 恢复及触发机制:最近一次、最早一次、指定一次等
- 支持多种资源管理:集群实例、集群配置、Jar、数据源、报警组、报警实例、文档、用户、系统配置等
- 支持多种资源管理:集群实例、集群配置、Jar、数据源、报警组、报警实例、文档、全局变量、系统配置等
- 支持企业级管理:多租户、用户、角色、项目空间
- 更多隐藏功能等待小伙伴们探索
## 原理
![dinky_principle](https://raw.githubusercontent.com/DataLinkDC/dinky/main/dinky-doc/images/main/dinky_principle.png)
![dinky_principle](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/main/dinky_principle.png)
## 运行效果
> FlinkSQL Studio
![datastudio](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/datastudio.png)
![datastudio](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/datastudio.png)
> 语法检查
![checksql](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/checksql.png)
![checksql](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/checksql.png)
> 版本管理
![versiondiff](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/versiondiff.png)
![versiondiff](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/versiondiff.png)
> 血缘分析
![lineage](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/lineage.png)
![lineage](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/lineage.png)
> BI 图表
![charts](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/charts.png)
![charts](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/charts.png)
> 元数据查询
![metadata](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/metadata.png)
![metadata](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/metadata.png)
> 任务监控
![monitor](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/monitor.png)
![monitor](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/monitor.png)
> 作业信息
![jobinfo](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/070/jobinfo.png)
## 近期计划
- [ ] 多租户及命名空间
- [ ] 全局血缘与影响分析
- [ ] 统一元数据管理
- [x] Flink 元数据持久化
- [x] 整库实时入仓入湖
![jobinfo](https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/070/jobinfo.png)
## 参与贡献
......@@ -82,6 +75,9 @@ Dinky 是一个 `开箱即用` 、`易扩展` ,以 `Apache Flink` 为基础,
## 如何部署
- dev 分支为 0.8 重构版,尚不稳定
- 0.7 分支为当前稳定版,编译调试请使用该分支
详见 [源码编译](https://github.com/DataLinkDC/dinky/blob/dev/docs/docs/build_deploy/build.md) 和 [安装部署](https://github.com/DataLinkDC/dinky/blob/dev/docs/docs/build_deploy/deploy.md) 。
## 如何升级
......@@ -122,21 +118,21 @@ Dinky 是一个 `开箱即用` 、`易扩展` ,以 `Apache Flink` 为基础,
[SpringBoot]()
感谢 [JetBrains](https://www.jetbrains.com/?from=dinky) 提供的免费开源 License 赞助。
感谢 [JetBrains](https://www.jetbrains.com/?from=dlink) 提供的免费开源 License 赞助。
[![JetBrains](https://raw.githubusercontent.com/DataLinkDC/dinky/main/dinky-doc/images/main/jetbrains.svg)](https://www.jetbrains.com/?from=dinky)
[![JetBrains](https://raw.githubusercontent.com/DataLinkDC/dinky/main/images/main/jetbrains.svg)](https://www.jetbrains.com/?from=dlink)
## 获得帮助
1.提交 issue
1.创建 issue,并描述清晰
2.访问 [官网](http://www.dinky.top/#/) 网址,阅读最新文档手册
2.访问 [官网](http://www.dlink.top/#/) 网址,阅读最新文档手册
3.推荐扫码进入钉钉群
<img src="https://raw.githubusercontent.com/DataLinkDC/dinky/dev/dinky-doc/images/main/dinkydingding.jpg" alt="dinkydingding" style="zoom:30%;" />
<img src="https://raw.githubusercontent.com/DataLinkDC/dinky/dev/images/main/dinkydingding.jpg" alt="dinkydingding" style="zoom:30%;" />
4.进入微信用户社区群(推荐,添加微信号 `wenmo_ai` 邀请进群)和QQ用户社区群(**543709668**)交流,申请备注 “ Dinky + 企业名 + 职位”
4.进入微信用户社区群(推荐,添加微信号 `wenmo_ai` 邀请进群)和 QQ 用户社区群(**543709668**)交流,必须申请备注 “ Dinky + 企业名 + 职位”,
5.关注微信公众号获取官方最新文章:[Dinky 开源](https://mmbiz.qpic.cn/mmbiz_jpg/dyicwnSlTFTp6w4PuJruFaLV6uShCJDkzqwtnbQJrQ90yKDuuIC8tyMU5DK69XZibibx7EPPBRQ3ic81se5UQYs21g/0?wx_fmt=jpeg)
......@@ -144,4 +140,4 @@ Dinky 是一个 `开箱即用` 、`易扩展` ,以 `Apache Flink` 为基础,
## 版权
请参考 [LICENSE](https://github.com/DataLinkDC/dinky/blob/main/LICENSE) 文件。
\ No newline at end of file
请参考 [LICENSE](https://github.com/DataLinkDC/dinky/blob/dev/LICENSE) 文件。
\ No newline at end of file
......@@ -129,8 +129,8 @@ public class ClusterConfigurationServiceImpl
.ifPresent(v -> flinkConfigMap.put("kubernetes.container.image", v));
String fileDir =
FileUtil.isDirectory(PathConstant.WORK_DIR + "/dinky-doc")
? PathConstant.WORK_DIR + "/dinky-doc"
FileUtil.isDirectory(PathConstant.WORK_DIR + "/docker")
? PathConstant.WORK_DIR + "/docker"
: PathConstant.WORK_DIR;
File dockerFile;
try {
......
......@@ -25,7 +25,7 @@
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.parent.basedir}/dinky-doc/bin</directory>
<directory>${project.parent.basedir}/script/bin</directory>
<outputDirectory>./</outputDirectory>
<lineEnding>unix</lineEnding>
<fileMode>0755</fileMode>
......@@ -51,7 +51,7 @@
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/dinky-doc/sql</directory>
<directory>${project.parent.basedir}/script/sql</directory>
<outputDirectory>sql</outputDirectory>
<includes>
<include>dinky.sql</include>
......@@ -71,6 +71,7 @@
<outputDirectory>plugins/flink1.12</outputDirectory>
<includes>
<include>dinky-client-1.12-${project.version}.jar</include>
<include>dinky-connector-jdbc-1.12-${project.version}.jar</include>
</includes>
</fileSet>
<fileSet>
......@@ -79,6 +80,7 @@
<includes>
<include>dinky-catalog-mysql-1.13-${project.version}.jar</include>
<include>dinky-client-1.13-${project.version}.jar</include>
<include>dinky-connector-jdbc-1.13-${project.version}.jar</include>
</includes>
</fileSet>
<fileSet>
......@@ -87,6 +89,7 @@
<includes>
<include>dinky-catalog-mysql-1.14-${project.version}.jar</include>
<include>dinky-client-1.14-${project.version}.jar</include>
<include>dinky-connector-jdbc-1.14-${project.version}.jar</include>
</includes>
</fileSet>
<fileSet>
......@@ -233,7 +236,7 @@
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/dinky-doc/extends</directory>
<directory>${project.parent.basedir}/docker/app</directory>
<outputDirectory>jar</outputDirectory>
<includes>
<include>Dockerfile</include>
......
FROM flink:1.14.5 as production-stage
USER root
COPY ./auto.sh /opt/dinky/
COPY ./lib /opt/dinky/lib/
COPY ./plugins /opt/dinky/plugins/
COPY ./config /opt/dinky/config/
COPY ./jar /opt/dinky/jar/
WORKDIR /opt/dinky/
RUN cp /opt/flink/lib/*.jar /opt/dinky/plugins/
RUN mkdir -p /opt/dinky/run
RUN mkdir -p /opt/dinky/logs
RUN touch /opt/dinky/logs/dinky.log
RUN chmod -R 777 /opt/dinky/
EXPOSE 8888
CMD ./auto.sh restart && tail -f /opt/dinky/logs/dinky.log
\ No newline at end of file
FROM mysql:5.7 as production-stage
ENV MYSQL_ROOT_PASSWORD=dinky
ENV MYSQL_DATABASE=dinky
ENV MYSQL_USER=dinky
ENV MYSQL_PASSWORD=dinky
COPY ./sql/dinky.sql /docker-entrypoint-initdb.d/01-dinky.sql
\ No newline at end of file
spring:
datasource:
url: jdbc:mysql://192.168.24.1:3306/dinky?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: dinky
password: dinky
driver-class-name: com.mysql.cj.jdbc.Driver
application:
name: dinky
server:
port: 8888
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: org.dinky.model
global-config:
db-config:
id-type: auto
configuration:
##### mybatis-plus打印完整sql(只适用于开发环境)
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
dinky:
##### 登录用户配置
login:
username: admin
password: admin
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
# Dlink 在 Flink-mysql-cdc 到 Doris 的实践
## 背景
Apache Doris是一个现代化的MPP分析型数据库产品。仅需亚秒级响应时间即可获得查询结果,有效地支持实时数据分析。例如固定历史报表,实时数据分析,交互式数据分析和探索式数据分析等。
目前 Doris 的生态正在建设中,本文将分享如何基于 Dlink 实现 Mysql 变动数据通过 Flink 实时入库 Doris。
## 准备
老规矩,列清各组件版本:
| 组件 | 版本 |
| :-------------: | :----------: |
| Flink | 1.13.3 |
| Flink-mysql-cdc | 2.1.0 |
| Doris | 0.15.1-rc09 |
| doris-flink | 1.0-SNAPSHOT |
| Mysql | 8.0.13 |
| Dlink | 0.4.0 |
需要注意的是,本文的 Doris 是基于 OracleJDK1.8 和 Scala 2.11 通过源码进行编译打包的,所以所有组件的 scala 均为 2.11,此处和 Doris 社区略有不同。
## 部署
本文的 Flink 和 Doris 的部署不做描述,详情请查阅官网。
[Doris]: https://doris.apache.org/master/zh-CN/extending-doris/flink-doris-connector.html#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95 "Doris"
本文在 Dlink 部署成功的基础上进行,如需查看具体部署步骤,请阅读《flink sql 知其所以然(十六):flink sql 开发企业级利器之 Dlink》。
Dlink 的 plugins 下添加 `doris-flink-1.0-SNAPSHOT.jar` 和 `flink-sql-connector-mysql-cdc-2.1.0.jar` 。重启 Dlink。
```java
plugins/ -- Flink 相关扩展
|- doris-flink-1.0-SNAPSHOT.jar
|- flink-csv-1.13.3.jar
|- flink-dist_2.11-1.13.3.jar
|- flink-format-changelog-json-2.1.0.jar
|- flink-json-1.13.3.jar
|- flink-shaded-zookeeper-3.4.14.jar
|- flink-sql-connector-mysql-cdc-2.1.0.jar
|- flink-table_2.11-1.13.3.jar
|- flink-table-blink_2.11-1.13.3.jar
```
当然,如果您想直接使用 FLINK_HOME 的话,可以在 `auto.sh` 文件中 `SETTING` 变量添加`$FLINK_HOME/lib` 。
## 数据表
### 学生表 (student)
```sql
-- Mysql
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`sid` int(11) NOT NULL,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`sid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
INSERT INTO `student` VALUES (1, '小红');
INSERT INTO `student` VALUES (2, '小黑');
INSERT INTO `student` VALUES (3, '小黄');
```
### 成绩表(score)
```sql
-- Mysql
DROP TABLE IF EXISTS `score`;
CREATE TABLE `score` (
`cid` int(11) NOT NULL,
`sid` int(11) NULL DEFAULT NULL,
`cls` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`score` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`cid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
INSERT INTO `score` VALUES (1, 1, 'chinese', 90);
INSERT INTO `score` VALUES (2, 1, 'math', 95);
INSERT INTO `score` VALUES (3, 1, 'english', 93);
INSERT INTO `score` VALUES (4, 2, 'chinese', 92);
INSERT INTO `score` VALUES (5, 2, 'math', 75);
INSERT INTO `score` VALUES (6, 2, 'english', 80);
INSERT INTO `score` VALUES (7, 3, 'chinese', 100);
INSERT INTO `score` VALUES (8, 3, 'math', 60);
```
### 学生成绩宽表(scoreinfo)
```sql
-- Doris
CREATE TABLE scoreinfo
(
cid INT,
sid INT,
name VARCHAR(32),
cls VARCHAR(32),
score INT
)
UNIQUE KEY(cid)
DISTRIBUTED BY HASH(cid) BUCKETS 10
PROPERTIES("replication_num" = "1");
```
## FlinkSQL
```sql
CREATE TABLE student (
sid INT,
name STRING,
PRIMARY KEY (sid) NOT ENFORCED
) WITH (
'connector' = 'mysql-cdc',
'hostname' = '127.0.0.1',
'port' = '3306',
'username' = 'test',
'password' = '123456',
'database-name' = 'test',
'table-name' = 'student');
CREATE TABLE score (
cid INT,
sid INT,
cls STRING,
score INT,
PRIMARY KEY (cid) NOT ENFORCED
) WITH (
'connector' = 'mysql-cdc',
'hostname' = '127.0.0.1',
'port' = '3306',
'username' = 'test',
'password' = '123456',
'database-name' = 'test',
'table-name' = 'score');
CREATE TABLE scoreinfo (
cid INT,
sid INT,
name STRING,
cls STRING,
score INT,
PRIMARY KEY (cid) NOT ENFORCED
) WITH (
'connector' = 'doris',
'fenodes' = '127.0.0.1:8030' ,
'table.identifier' = 'test.scoreinfo',
'username' = 'root',
'password'=''
);
insert into scoreinfo
select
a.cid,a.sid,b.name,a.cls,a.score
from score a
left join student b on a.sid = b.sid
```
## 调试
### 在 Dlink 中提交
本示例采用了 yarn-session 的方式进行提交。
![image-20211218134246511](https://mmbiz.qpic.cn/mmbiz_png/dyicwnSlTFTp0RDozicic8lrYycianYsUN9ibG3QjNqVbMk7L41wHykKnkV0YxDCVSYj68HlFWylpYckkXicgnTDU7uQ/0?wx_fmt=png)
### FlinkWebUI
![image-20211218134439699](https://mmbiz.qpic.cn/mmbiz_png/dyicwnSlTFTp0RDozicic8lrYycianYsUN9ibn1jXbvKznaF8Tm4AxxvYYDI0fEtXbGm0XUeXhGp44KMlPdoOzjvtHQ/0?wx_fmt=png)
上图可见,流任务已经成功被 Dlink 提交的远程集群了。
### Doris 查询
![image-20211218135404787](https://mmbiz.qpic.cn/mmbiz_png/dyicwnSlTFTp0RDozicic8lrYycianYsUN9iblKTY6o9fWZxFDQYC19wKVFRGDuUBgNOZxm14sWjyr8tUY7RDeUiaEUw/0?wx_fmt=png)
上图可见,Doris 已经被写入了历史全量数据。
### 增量测试
在 Mysql 中执行新增语句:
```sql
INSERT INTO `score` VALUES (9, 3, 'english', 100);
```
Doris 成功被追加:
![image-20211218135545742](https://mmbiz.qpic.cn/mmbiz_png/dyicwnSlTFTp0RDozicic8lrYycianYsUN9ibvE4qyQ9ttf2kNZ3raEgabvh442HfiaIfm2l5dhdFmWoGiaHMlvcQmocw/0?wx_fmt=png)
### 变动测试
在 Mysql 中执行新增语句:
```sql
update score set score = 100 where cid = 1
```
Doris 成功被修改:
![image-20211218135949764](https://mmbiz.qpic.cn/mmbiz_png/dyicwnSlTFTp0RDozicic8lrYycianYsUN9ib3liaIvXQcCSboO4IoeJhtTRa38ukNogtFzwg31mNEFwRcJ1wGNIhQkQ/0?wx_fmt=png)
# Dlink 读写 Hive 的实践
## 前言
最近有很多小伙伴问,dlink 如何连接 Hive 进行数据开发?
关于 dlink 连接 Hive 的步骤同 Flink 的 `sql-client ` ,只不过它没有默认加载的配置文件。下文将详细讲述对 Hive 操作的全过程。
## 准备工作
由于搭建 Hive 的开发环境会涉及到重多组件和插件,那其版本对应问题也是至关重要,它能帮我们避免很多不必要的问题,当然小版本号之间具备一定的兼容性。
我们先来梳理下本教程的各个组件版本:
| 组件 | 版本 |
| :----: | :----: |
| Dlink | 0.3.2 |
| Flink | 1.12.4 |
| Hadoop | 2.7.7 |
| Hive | 2.3.6 |
| Mysql | 8.0.15 |
再来梳理下本教程的各个插件版本:
| 所属组件 | 插件 | 版本 |
| :-----------: | :------------------------: | :-------------------: |
| Dlink | dlink-client | 1.12 |
| Dlink & Flink | flink-sql-connector-hive | 2.3.6_2.11-1.12.3 |
| Dlink & Flink | flink-shaded-hadoop-3-uber | 3.1.1.7.2.8.0-224-9.0 |
## 部署扩展
部署扩展的工作非常简单(前提是 Dlink 部署完成并成功连接 Flink 集群,相关部署步骤请查看《Dlink实时计算平台——部署篇》),只需要把 `flink-sql-connector-hive-2.3.6_2.11-1.12.3.jar` 和 `flink-shaded-hadoop-3-uber-3.1.1.7.2.8.0-224-9.0.jar` 两个插件分别加入到 Dlink 的 plugins 目录与 Flink 的 lib 目录下即可,然后重启二者。当然,还需要放置 `hive-site.xml`,位置自定义,Dlink 可以访问到即可。
## 创建 Hive Catalog
已知,Hive 已经新建了一个数据库实例 `hdb` ,创建了一张表 `htest`,列为 `name` 和 `age`,存储位置默认为 `hdfs:///usr/local/hadoop/hive-2.3.9/warehouse/hdb.db` 。(此处为何 2.3.9 呢,因为 `flink-sql-connector-hive-2.3.6_2.11-1.12.3.jar` 只支持到最高版本 2.3.6,小编先装了个 2.3.9 后装了个 2.3.6,尴尬 > _ < ~)
```sql
CREATE CATALOG myhive WITH (
'type' = 'hive',
'default-database' = 'hdb',
'hive-conf-dir' = '/usr/local/dlink/hive-conf'
);
-- set the HiveCatalog as the current catalog of the session
USE CATALOG myhive;
select * from htest
```
在 Dlink 编辑器中输入以上 sql ,创建 Hive Catalog,并查询一张表。
其中,`hive-conf-dir` 需要指定 `hive-site.xml` 的路径,其他同 Flink 官方解释。
![image-20211030150744871](D:\DataCenter\worknote\公众号\插图\hive篇\hive创建catalog.png)
执行查询后(记得选中执行配置的预览结果),可以从查询结果中查看到 htest 表中只有一条数据。(这是正确的,因为小编太懒了,只随手模拟了一条数据)
此时可以使用 FlinkSQL 愉快地操作 Hive 的数据了。
## 使用 Hive Dialect
很熟悉 Hive 的语法以及需要对 Hive 执行其自身特性的语句怎么办?
同 Flink 官方解释一样,只需要使用 `SET table.sql-dialect=hive` 来启用方言即可。注意有两种方言 `default` 和 `hive` ,它们的使用可以随意切换哦~
```sql
CREATE CATALOG myhive WITH (
'type' = 'hive',
'default-database' = 'hdb',
'hive-conf-dir' = '/usr/local/dlink/hive-conf'
);
-- set the HiveCatalog as the current catalog of the session
USE CATALOG myhive;
-- set hive dialect
SET table.sql-dialect=hive;
-- alter table location
alter table htest set location 'hdfs:///usr/htest';
-- set default dialect
SET table.sql-dialect=default;
select * from htest;
```
上述 sql 中添加了 Hive Dialect 的使用,FlinkSQL 本身不支持 `alter table .. set location ..` 的语法,使用 Hive Dialect 则可以实现语法的切换。本 sql 内容对 htest 表进行存储位置的改变,将其更改为一个新的路径,然后再执行查询。
![image-20211030151433858](D:\DataCenter\worknote\公众号\插图\hive篇\hivedialect.png)
由上图可见,被更改过 location 的 htest 此时查询没有数据,是正确的。
然后将 location 更改为之前的路径,再执行查询,则可见原来的那条数据,如下图所示。
![image-20211030151532520](D:\DataCenter\worknote\公众号\插图\hive篇\hivesetlocation.png)
## 总结
由上所知,Dlink 以更加友好的交互方式展现了 Flink 集成 Hive 的部分功能,当然其他更多的 Hive 功能需要您自己在使用的过程中去体验与挖掘。
目前,Dlink 支持 Flink 绝大多数特性与功能,集成与拓展方式与 Flink 官方文档描述一致,只需要在 Dlink 的 plugins 目录下添加依赖即可。
需要注意的是,由于 Dlink 是一个基于 SpringBoot 的 B/S 应用,难免存在依赖冲突问题,可以通过 Nginx 前后端分离部署来避免一部分问题;而对于 mysql-cdc 等包,由于内部依赖冲突问题,会导致 Dlink 自身无法正常启动,(da lao 可以自行排查依赖冲突问题并重新打包)该问题目前有相应的解决方案,需要等待后续版本的发布。
This diff is collapsed.
......@@ -5,4 +5,4 @@ ENV MYSQL_DATABASE=dinky
ENV MYSQL_USER=dinky
ENV MYSQL_PASSWORD=dinky
COPY ../dinky-doc/sql/dinky.sql /docker-entrypoint-initdb.d/01-dinky.sql
\ No newline at end of file
COPY ../script/sql/dinky.sql /docker-entrypoint-initdb.d/01-dinky.sql
\ No newline at end of file
FROM centos:7
MAINTAINER dinky
ADD flink-1.14.0-bin-scala_2.11.tgz /root
ADD flink-1.14.6-bin-scala_2.11.tgz /root
ADD jdk-8u261-linux-x64.tar.gz /root
ADD dinky-app.jar /root
ARG FLINK_VERSION=1.14.0
ARG FLINK_VERSION=1.14.6
ARG SCALA_VERSION=2.11
ENV FLINK_HOME=/root/flink-1.14.0
ENV FLINK_HOME=/root/flink-1.14.6
ENV PATH=$FLINK_HOME/bin:$PATH
ENV JAVA_HOME=/root/jdk1.8.0_261
ENV PATH=$JAVA_HOME/bin:$PATH
RUN cd $FLINK_HOME \
&& echo "env.java.home: /root/jdk1.8.0_261" >> $FLINK_HOME/conf/flink-conf.yaml \
&& echo "FLINK_HOME=/root/flink-1.14.0" >> /etc/profile \
&& echo "FLINK_HOME=/root/flink-1.14.6" >> /etc/profile \
&& echo "PATH=$FLINK_HOME/bin:$PATH" >> /etc/profile \
&& echo "JAVA_HOME=/root/jdk1.8.0_261" >> /etc/profile \
&& echo "PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile \
......
FROM mysql:5.7 as production-stage
COPY ./dinky-doc/sql/dinky.sql /docker-entrypoint-initdb.d/01-dinky.sql
COPY ./dinky-doc/sql/dinky_history.sql /docker-entrypoint-initdb.d/02-dinky_history.sql
COPY ./script/sql/dinky.sql /docker-entrypoint-initdb.d/01-dinky.sql
COPY ./script/sql/dinky_history.sql /docker-entrypoint-initdb.d/02-dinky_history.sql
#!/bin/bash
FLINK_VERSION=${2:-1.14}
# 定义变量
# 要运行的jar包路径,加不加引号都行。 注意:等号两边不能有空格,否则会提示command找不到
JAR_NAME="dinky-admin"
# 如果需要将 FLINK 依赖直接加入启动脚本,在 CLASS_PATH 中末尾追加 :$FLINK_HOME/lib/*
CLASS_PATH="./lib/*:config:html:./plugins/*:./plugins/flink${FLINK_VERSION}/*"
#if [ ! -d ${HADOOP_HOME} ]; then
# echo 'WARNING!!!...not find HADOOP_HOME for CLASSPATH.'
#else
# export HADOOP_HOME="${HADOOP_HOME}"
#fi
PIDFILE="dinky.pid"
#JMX路径
JAR_NAME="dlink-admin"
# Use FLINK_HOME:
# CLASS_PATH="./lib/*:./plugins/*:./plugins/flink${FLINK_VERSION}/*:$FLINK_HOME/lib/*"
CLASS_PATH="./lib/*:./plugins/*:./plugins/flink${FLINK_VERSION}/*"
PID_FILE="dinky.pid"
# JMX path
APP_HOME="$(cd `dirname $0`; pwd)"
JMX="-javaagent:$APP_HOME/lib/jmx_prometheus_javaagent-0.16.1.jar=10087:$APP_HOME/config/jmx/jmx_exporter_config.yaml"
#检查PID path 是否存在
PIDPATH="$(cd "$(dirname "$0")";pwd)/run"
if [ -d ${PIDPATH} ];then
echo "${PIDPATH} is already exist" >> /dev/null
else
#echo "create ${PIDPATH}"
mkdir -p ${PIDPATH}
fi
#检查PID File 是否存在
if [ -f "${PIDPATH}/${PIDFILE}" ];then
echo "${PIDPATH}/${PIDFILE} is already exist" >> /dev/null
# Check whether the pid path exists
PID_PATH="$(cd "$(dirname "$0")";pwd)/run"
if [ -d ${PID_PATH} ];then
echo "${PID_PATH} is already exist." >> /dev/null
else
touch ${PIDPATH}/${PIDFILE}
mkdir -p ${PID_PATH}
fi
# 首次启动时候自动创建plugins文件夹和引用flink\lib包!
if [ ! -d "./plugins" ]; then
echo 'mkdir plugins now'
mkdir plugins
# cd plugins
# if [ ! -d ${FLINK_HOME} ]; then
# echo 'WARNING!!!...没有找到FLINK_HOME环境变量,无法引用Flink/lib到plugins,请手动引用或复制Flink jar到plugins文件夹'
# echo 'WARNING!!!...not find FLINK_HOME environment variable to reference Flink/lib to plugins, please reference or copy Flink jar to the plugins folder manually!!'
# else
# ln -s ${FLINK_HOME}/lib
# cd ..
# fi
# Check whether the pid file exists
if [ -f "${PID_PATH}/${PID_FILE}" ];then
echo "${PID_PATH}/${PID_FILE} is already exist." >> /dev/null
else
touch ${PID_PATH}/${PID_FILE}
fi
# 如果输入格式不对,给出提示!
tips() {
echo ""
echo "WARNING!!!......Tips, please use command: sh auto.sh [start|startWithJmx|stop|restart|status]. For example: sh auto.sh start "
......@@ -54,53 +37,43 @@ tips() {
exit 1
}
# 启动方法
start() {
pid=$(cat ${PIDPATH}/${PIDFILE})
pid=$(cat ${PID_PATH}/${PID_FILE})
if [ -z $pid ]; then
nohup java -Ddruid.mysql.usePingMethod=false -Xms512M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=1024M -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -cp ${CLASS_PATH} org.dinky.Dinky >/dev/null 2>&1 &
echo $! >${PIDPATH}/${PIDFILE}
nohup java -Ddruid.mysql.usePingMethod=false -Xms512M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=1024M -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -cp ${CLASS_PATH} com.dlink.Dlink >/dev/null 2>&1 &
echo $! >${PID_PATH}/${PID_FILE}
echo "FLINK VERSION : $FLINK_VERSION"
echo "........................................Start Dinky Successfully........................................"
else
echo "Dinky pid $pid is in ${PIDPATH}/${PIDFILE}, Please stop first !!!"
echo "Dinky pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!"
fi
}
# 启动方法(含jmx启动)
startWithJmx() {
pid=$(cat ${PIDPATH}/${PIDFILE})
pid=$(cat ${PID_PATH}/${PID_FILE})
if [ -z $pid ]; then
nohup java -Ddruid.mysql.usePingMethod=false -Xms512M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=1024M -XX:+HeapDumpOnOutOfMemoryError -Xverify:none ${JMX} -cp ${CLASS_PATH} org.dinky.Dinky >/dev/null 2>&1 &
echo $! >${PIDPATH}/${PIDFILE}
echo "........................................Start Dinky Successfully........................................"
nohup java -Ddruid.mysql.usePingMethod=false -Xms512M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=1024M -XX:+HeapDumpOnOutOfMemoryError -Xverify:none ${JMX} -cp ${CLASS_PATH} com.dlink.Dlink >/dev/null 2>&1 &
echo $! >${PID_PATH}/${PID_FILE}
echo "........................................Start Dlink Successfully........................................"
else
echo "Dinky pid $pid is in ${PIDPATH}/${PIDFILE}, Please stop first !!!"
echo "Dlink pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!"
fi
}
# 停止方法
stop() {
pid=$(cat ${PIDPATH}/${PIDFILE})
pid=$(cat ${PID_PATH}/${PID_FILE})
if [ -z $pid ]; then
echo "Dinky pid is not exist in ${PIDPATH}/${PIDFILE}"
echo "Dinky pid is not exist in ${PID_PATH}/${PID_FILE}"
else
kill -9 $pid
sleep 1
echo "........................................Stop Dinky Successfully....................................."
echo " " >${PIDPATH}/${PIDFILE}
echo " " >${PID_PATH}/${PID_FILE}
fi
}
# 输出运行状态方法
status() {
# 重新获取一下pid,因为其它操作如stop、restart、start等会导致pid的状态更新
pid=$(cat ${PIDPATH}/${PIDFILE})
pid=$(cat ${PID_PATH}/${PID_FILE})
if [ -z $pid ]; then
echo ""
echo "Service ${JAR_NAME} is not running!"
......@@ -113,7 +86,6 @@ status() {
fi
}
# 重启方法
restart() {
echo ""
stop
......@@ -121,7 +93,6 @@ restart() {
echo "........................................Restart Successfully........................................"
}
# 根据输入参数执行对应方法,不输入则执行tips提示方法
case "$1" in
"start")
start
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment