# huaweicloud-solution-migrating-oracle-databases-to-the-cloud-with-dataguard **Repository Path**: HuaweiCloudDeveloper/huaweicloud-solution-migrating-oracle-databases-to-the-cloud-with-dataguard ## Basic Information - **Project Name**: huaweicloud-solution-migrating-oracle-databases-to-the-cloud-with-dataguard - **Description**: 利用dataguard架构快速迁移oracle数据库 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master-dev - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-11-20 - **Last Updated**: 2025-06-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [TOC] **解决方案介绍** =============== 该方案基于华为云弹性云服务器ECS,利用Oracle数据库的DataGuard架构,搭建客户端和华为云ECS之间的链路,帮助用户实现业务数据快速迁移。适用于有数据容灾需求的客户和业务场景,当客户端宕机或者数据库出现故障时,可以切换华为云ECS为主库,保证业务正常运行。 解决方案实践详情页面地址:https://www.huaweicloud.com/solution/implementations/migrating-oracle-db-with-dataguard.html **架构图** --------------- ![方案架构](./document/architecture.png) **架构描述** --------------- 该方案涉及的架构均为已有资源,无需创建新资源。客户端架构为包含Oracle数据库的服务器,华为云ECS也需安装Oracle数据库。Oracle源端与目标端数据库需要保持网络互通。 **组织结构** --------------- ``` lua huaweicloud-solution-migrating-oracle-databases-to-the-cloud-with-dataguard ├── dataguard-build ├── oracle_dataguard_source.sh -- 源端部署脚本 ├── oracle_dataguard_target.sh -- 目标端部署脚本 ``` **脚本执行** --------------- 源端和目标端的部署脚本在`dataguard-build`目录下。两个脚本均提供可自定义的部署参数,部署参数中空缺的参数需要补全,提供默认值的参数可根据实际配置进行修改。部署参数示例如下图所示: ![脚本部署参数](./document/script-deployment-parameters.png) 脚本执行说明: * oracle_dataguard_source.sh:源端(客户端)搭建DataGuard链路,在oracle用户(su - oracle)和对应目录下(/home/oracle)执行该脚本。 ```shell sh oracle_dataguard_source.sh ``` * oracle_dataguard_target.sh:目标端(华为云ecs)搭建DataGuard链路,在oracle用户(su - oracle)和对应目录下(/home/oracle)执行该脚本。 ```shell sh oracle_dataguard_target.sh ``` **开始使用** --------------- #### DataGuard日常维护 ##### 开启主备库实时同步 主库对应源端,备库对应目标端。 1. 备库开启至open状态,主库开启至open状态(先备再主,防止有未同步的归档日志) 2. 主备库开启监听 ```shell lsnrctl start ``` 3. 备库sql执行同步指令 ```shell alter database recover managed standby database using current logfile disconnect from session; ``` !!!warn **须知**:主库在进行增删改查等操作后,需要commit提交事务,否则主备库无法完成同步。 ##### 关闭主备库实时同步 1. 备库sql执行中止同步指令 ```shell alter database recover managed standby database cancel; ``` #### 常见问题 使用过程中的常见问题及解决方法。 **Q1**:目标端rman连接源端, 出现RMAN-04005和ORA-12541报错。 图1 ORA-12541报错 ![问题1](./document/question-1.png) **A1**:源端监听器未开启,开启源端监听器,执行"lsnrctl start"。 **Q2**:备库rman复制主库时,出现RMAN-05500报错。 图2 RMAN-05500报错 ![问题1](./document/question-2.png) **A2**:备库需要开启为nomount状态,重启oracle数据库至nomount状态。 ```shell sqlplus / as sysdba << end shutdown immediate; startup nomount; end ```