feat: 华为opengauss支持

This commit is contained in:
dhb52 2024-06-05 23:05:58 +08:00
parent a6bee12fbc
commit a5081b94f5
7 changed files with 4777 additions and 8 deletions

File diff suppressed because it is too large Load Diff

View File

@ -81,11 +81,19 @@ docker load -i x86_64/kdb_x86_64_V009R001C001B0025.tar
```Bash ```Bash
docker compose up -d kingbase docker compose up -d kingbase
# 注意:启动完 dm 后,需要手动再执行如下命令,因为 dm 不支持初始化脚本 # 注意:启动完 dm 后,需要手动再执行如下命令,因为 dm 不支持初始化脚本
docker compose exec kingbase bash -c "exec ksql -Uroot -d test -f /tmp/schema.sql" docker compose exec kingbase bash -c 'ksql -U $DB_USER -d test -f /tmp/schema.sql'
``` ```
**注意**: MyBatis, MyBatis Plus 目前不兼容人大金仓推荐直接使用PostgreSQL JDBC 驱动,已经 url 配置方式连接数据库。 **注意**: MyBatis, MyBatis Plus 目前不兼容人大金仓推荐直接使用PostgreSQL JDBC 驱动,已经 url 配置方式连接数据库。
### 1.7 华为 OpenGauss
```Bash
docker compose up -d opengauss
# 注意:启动完 opengauss 后,需要手动再执行如下命令
docker compose exec opengauss bash -c '/usr/local/opengauss/bin/gsql -U $GS_USERNAME -W $GS_PASSWORD -d postgres -f /tmp/schema.sql'
```
## 1.X 容器的销毁重建 ## 1.X 容器的销毁重建
开发测试过程中,有时候需要创建全新干净的数据库。由于测试数据 Docker 容器采用数据卷 Volume 挂载数据库实例的数据目录,因此销毁数据需要停止容器后,删除数据卷,然后再重新创建容器。 开发测试过程中,有时候需要创建全新干净的数据库。由于测试数据 Docker 容器采用数据卷 Volume 挂载数据库实例的数据目录,因此销毁数据需要停止容器后,删除数据卷,然后再重新创建容器。

View File

@ -804,13 +804,19 @@ CREATE TABLE {table_name} (
return script return script
class OpengaussConvertor(KingbaseConvertor):
def __init__(self, src):
super().__init__(src)
self.db_type = "OpenGauss"
def main(): def main():
parser = argparse.ArgumentParser(description="芋道系统数据库转换工具") parser = argparse.ArgumentParser(description="芋道系统数据库转换工具")
parser.add_argument( parser.add_argument(
"type", "type",
type=str, type=str,
help="目标数据库类型", help="目标数据库类型",
choices=["postgres", "oracle", "sqlserver", "dm8", "kingbase"], choices=["postgres", "oracle", "sqlserver", "dm8", "kingbase", "opengauss"],
) )
args = parser.parse_args() args = parser.parse_args()
@ -826,6 +832,8 @@ def main():
convertor = DM8Convertor(sql_file) convertor = DM8Convertor(sql_file)
elif args.type == "kingbase": elif args.type == "kingbase":
convertor = KingbaseConvertor(sql_file) convertor = KingbaseConvertor(sql_file)
elif args.type == "opengauss":
convertor = OpengaussConvertor(sql_file)
else: else:
raise NotImplementedError(f"不支持目标数据库类型: {args.type}") raise NotImplementedError(f"不支持目标数据库类型: {args.type}")

View File

@ -6,6 +6,7 @@ volumes:
sqlserver: { } sqlserver: { }
dm8: { } dm8: { }
kingbase: { } kingbase: { }
opengauss: { }
services: services:
mysql: mysql:
@ -106,6 +107,20 @@ services:
ports: ports:
- "54321:54321" - "54321:54321"
volumes: volumes:
- kingbase:/home/kingbase/userdata/ - kingbase:/home/kingbase/userdata
- ../kingbase/ruoyi-vue-pro.sql:/tmp/schema.sql:ro - ../kingbase/ruoyi-vue-pro.sql:/tmp/schema.sql:ro
# docker compose exec kingbase bash -c "exec ksql -Uroot -d test -f /tmp/schema.sql" # docker compose exec kingbase bash -c 'ksql -U $DB_USER -d test -f /tmp/schema.sql'
opengauss:
image: opengauss/opengauss:5.0.0
restart: unless-stopped
environment:
GS_USERNAME: root
GS_PASSWORD: Yudao@2024
LD_LIBRARY_PATH: /usr/local/opengauss/lib:/usr/lib
ports:
- "5432:5432"
volumes:
- opengauss:/var/lib/opengauss
- ../opengauss/ruoyi-vue-pro.sql:/tmp/schema.sql:ro
# docker compose exec opengauss bash -c '/usr/local/opengauss/bin/gsql -U $GS_USERNAME -W $GS_PASSWORD -d postgres -f /tmp/schema.sql'

View File

@ -30,6 +30,7 @@
<easy-trans.version>2.2.11</easy-trans.version> <easy-trans.version>2.2.11</easy-trans.version>
<redisson.version>3.26.0</redisson.version> <redisson.version>3.26.0</redisson.version>
<dm8.jdbc.version>8.1.3.62</dm8.jdbc.version> <dm8.jdbc.version>8.1.3.62</dm8.jdbc.version>
<opengauss.jdbc.version>5.0.2</opengauss.jdbc.version>
<!-- 消息队列 --> <!-- 消息队列 -->
<rocketmq-spring.version>2.3.0</rocketmq-spring.version> <rocketmq-spring.version>2.3.0</rocketmq-spring.version>
<!-- 服务保障相关 --> <!-- 服务保障相关 -->
@ -242,6 +243,12 @@
<version>${dm8.jdbc.version}</version> <version>${dm8.jdbc.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.opengauss</groupId>
<artifactId>opengauss-jdbc</artifactId>
<version>${opengauss.jdbc.version}</version>
</dependency>
<!-- Job 定时任务相关 --> <!-- Job 定时任务相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>

View File

@ -53,6 +53,11 @@
<artifactId>DmJdbcDriver18</artifactId> <artifactId>DmJdbcDriver18</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>org.opengauss</groupId>
<artifactId>opengauss-jdbc</artifactId>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>

View File

@ -53,12 +53,15 @@ spring:
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true;useUnicode=true;characterEncoding=utf-8 # SQLServer 连接的示例 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true;useUnicode=true;characterEncoding=utf-8 # SQLServer 连接的示例
# url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 # url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例
# url: jdbc:postgresql://127.0.0.1:54321/test # KingbaseES 人大金仓 连接的示例, MyBatis不兼容官方驱动 # url: jdbc:postgresql://127.0.0.1:54321/test # KingbaseES 人大金仓 连接的示例, MyBatis不兼容官方驱动
# url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例
username: root username: root
password: 123456 password: 123456
# username: sa # SQL Server 连接的示例 # username: sa # SQL Server 连接的示例
# password: Yudao@2024 # SQL Server 连接的示例 # password: Yudao@2024 # SQL Server 连接的示例
# username: SYSDBA # DM 连接的示例 # username: SYSDBA # DM 连接的示例
# password: SYSDBA001 # DM 连接的示例 # password: SYSDBA001 # DM 连接的示例
# username: root # OpenGauss 连接的示例
# password: Yudao@2024 # OpenGauss 连接的示例
slave: # 模拟从库,可根据自己需要修改 slave: # 模拟从库,可根据自己需要修改
lazy: true # 开启懒加载,保证启动速度 lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true