!985 feat: 华为opengauss支持

Merge pull request !985 from dhb52/feature/db
This commit is contained in:
芋道源码 2024-06-15 09:52:49 +00:00 committed by Gitee
commit b4a86d14a6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 4791 additions and 11 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
docker compose up -d kingbase
# 注意:启动完 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 配置方式连接数据库。
### 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 容器的销毁重建
开发测试过程中,有时候需要创建全新干净的数据库。由于测试数据 Docker 容器采用数据卷 Volume 挂载数据库实例的数据目录,因此销毁数据需要停止容器后,删除数据卷,然后再重新创建容器。

View File

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

View File

@ -6,6 +6,7 @@ volumes:
sqlserver: { }
dm8: { }
kingbase: { }
opengauss: { }
services:
mysql:
@ -106,6 +107,20 @@ services:
ports:
- "54321:54321"
volumes:
- kingbase:/home/kingbase/userdata/
- kingbase:/home/kingbase/userdata
- ../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,8 @@
<easy-trans.version>2.2.11</easy-trans.version>
<redisson.version>3.26.0</redisson.version>
<dm8.jdbc.version>8.1.3.62</dm8.jdbc.version>
<kingbase.jdbc.version>8.6.0</kingbase.jdbc.version>
<opengauss.jdbc.version>5.0.2</opengauss.jdbc.version>
<!-- 消息队列 -->
<rocketmq-spring.version>2.3.0</rocketmq-spring.version>
<!-- 服务保障相关 -->
@ -242,6 +244,18 @@
<version>${dm8.jdbc.version}</version>
</dependency>
<dependency>
<groupId>org.opengauss</groupId>
<artifactId>opengauss-jdbc</artifactId>
<version>${opengauss.jdbc.version}</version>
</dependency>
<dependency>
<groupId>cn.com.kingbase</groupId>
<artifactId>kingbase8</artifactId>
<version>${kingbase.jdbc.version}</version>
</dependency>
<!-- Job 定时任务相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>

View File

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

View File

@ -35,8 +35,7 @@ public class JdbcUtils {
* @return DB 类型
*/
public static DbType getDbType(String url) {
String name = com.alibaba.druid.util.JdbcUtils.getDbType(url, null);
return DbType.getDbType(name);
return com.baomidou.mybatisplus.extension.toolkit.JdbcUtils.getDbType(url);
}
}

View File

@ -52,13 +52,16 @@ spring:
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# 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:postgresql://127.0.0.1:54321/test # KingbaseES 人大金仓 连接的示例, MyBatis不兼容官方驱动
# url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例
username: root
password: 123456
# username: sa # SQL Server 连接的示例
# password: Yudao@2024 # SQL Server 连接的示例
# username: SYSDBA # DM 连接的示例
# password: SYSDBA001 # DM 连接的示例
# username: sa # SQL Server 连接的示例
# password: Yudao@2024 # SQL Server 连接的示例
# username: SYSDBA # DM 连接的示例
# password: SYSDBA001 # DM 连接的示例
# username: root # OpenGauss 连接的示例
# password: Yudao@2024 # OpenGauss 连接的示例
slave: # 模拟从库,可根据自己需要修改
lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true