Oracle 转 PostgreSQL, ora2pg docker compose 简单实践版

背景:

Oracle 授权费用高, 故转PostgreSQL , 找了一下解决方案, 连AI 都推荐用 ora2pg, 但是看起来环境搭建略显复杂, 并且只是一次性的工作, 比较适合使用 docker

步骤:

  1. 拉取镜像: georgmoser/ora2pg

  2. 准备编排文件 /data/ora2pg/docker-compose.yml

    version: "3.9"

    services:
    ora2pg:
    image: georgmoser/ora2pg:latest
    container_name: ora2pg
    restart: "no"
    environment:
    CONFIG_LOCATION: "/config/ora2pg.conf"
    OUTPUT_LOCATION: "/data"
    ORA_HOST: "dbi:Oracle:host=xxxxx;service_name=ORCLPDB1;port=1521"
    ORA_USER: "user"
    ORA_PWD: "pwd"
    volumes:
    - '/data/ora2pg/config:/config' # 挂载配置文件目录
    - '/data/ora2pg/data:/data' # 挂载输出目录
    command: >
    ora2pg -c /config/ora2pg.conf

  3. 准备配置文件 /data/ora2pg/config/ora2pg.conf

    Oracle

    ORACLE_DSN dbi:Oracle:host=172.16.xxx.xxx;service_name=ORCLPDB1;port=1521
    ORACLE_USER USER
    ORACLE_PWD PWD

    Postgres

    PG_DSN dbi:Pg:dbname=IWMS;host=172.16.xxx.xxx;port=5432
    PG_USER user
    PG_PWD password
    PG_VERSION 16

    Schema

    SCHEMA db1

    OUTPUT_DIR /data

    导出控制

    EXPORT_SCHEMA 1
    EXPORT_DATA 1
    DATA_EXPORT_MODE COPY

  4. docker compose up 启动完成后会自动退出, 如果想单独使用容器中的环境, 可以用这个命令启动后直接打开一个终端

    docker compose run --rm ora2pg bash

然后在容器中执行命令, 例如:

复制代码
ora2pg -c /config/ora2pg.conf > /data/db1.sql

更多 ora2pg 使用方法见: https://ora2pg.darold.net/documentation.html#Oracle-schema-to-export

相关推荐
我不是疯子是傻子2 小时前
Qt CAN通信周期发送抖动?实测定时器精度校准与时间戳补偿方案
开发语言·数据库·qt
这个DBA有点耶2 小时前
数据库迁移怎么做到“零翻车“:金仓 KDMS/KDTS/KFS 工具链实测
数据库·架构·dba
2501_937860943 小时前
MySQL联合查询(多表查询)
数据库·mysql
名字还没想好☜4 小时前
Next.js 用 Server Components 直连数据库:去掉 API 层的边界,和三条别踩的安全红线
前端·javascript·数据库·安全·react·next.js
迷迭香yy4 小时前
行业板块轮动因子实战从板块资金到因子建模的本地化Python全流程
数据库·人工智能·python
SelectDB5 小时前
抖音集团 实时数据仓库:Apache Doris / SelectDB 的技术能力与实践
数据库
SelectDB5 小时前
网易 日志与时序数据分析:Apache Doris / SelectDB 的技术能力与实践
数据库
weixin_539446785 小时前
Navicat Premium 17报缺少ODBC驱动
数据库
哦虎!5 小时前
【数据库】事务
java·数据库·mysql
倔强的石头_6 小时前
时序数据库的难题不只在写入速度
数据库