背景:某客户Oracle 10g 的DG由于空间不足,之前将部分数据文件迁移到其他目录,如今原目录扩容成功,要将之前迁移的数据文件再次迁移回来。
环境:Oracle 10.2.0.5 DG 单机
首先想到的是10gDG是在mount模式下应用的,在测试环境可以很容易的模拟下这个需求实现的过程:
1.查询当前DG的状态
2.停止DG应用
3.备份copy副本到新目录并切换
4.删除之前的目录并开启应用
1.查询当前DG的状态
查询当前DG的状态:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name, database_role, open_mode from gv$database;
NAME DATABASE_ROLE OPEN_MODE
--------- ---------------- ----------
JY PHYSICAL STANDBY MOUNTED
SQL> select recovery_mode from v$archive_dest_status;
RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY
IDLE
IDLE
IDLE
IDLE
IDLE
IDLE
IDLE
IDLE
IDLE
IDLE
11 rows selected.
SQL> select * from v$dataguard_stats;
NAME VALUE UNIT TIME_COMPUTED
---------------------------------- ---------------------------------------------------------------- ------------------------------ ------------------------------
apply finish time +00 00:00:00.0 day(2) to second(1) interval 05-MAY-2018 10:04:20
apply lag +00 00:00:12 day(2) to second(0) interval 05-MAY-2018 10:04:20
estimated startup time 41 second 05-MAY-2018 10:04:20
standby has been open N 05-MAY-2018 10:04:20
transport lag +00 00:00:00 day(2) to second(0) interval 05-MAY-2018 10:04:20
可以看到DG处于正常应用状态。
2.停止DG应用
停止DG应用:
SQL> alter database recover managed standby database cancel;
Database altered.
3.备份copy副本到新目录并切换
3.1 确认需要迁移的数据文件
查看当前的数据文件,确认将9,10,11三个文件迁移回原来的目录:
SQL> select file#, name from v$datafile;
FILE# NAME
---------- -------------------------------------------------------
1 /oradata/jy/datafile/system.256.839673875
2 /oradata/jy/datafile/undotbs1.258.839673877
3 /oradata/jy/datafile/sysaux.257.839673877
4 /oradata/jy/datafile/users.259.839673877
5 /oradata/jy/datafile/example.267.839673961
6 /oradata/jy/datafile/undotbs2.268.839674103
7 /oradata/jy/datafile/dbs_d_school.276.840618437
8 /oradata/jy/datafile/dbs_cssf_gt.289.848228741
9 /datafile/dbs_data9.dbf
10 /datafile/dbs_data10.dbf
11 /datafile/dbs_data11.dbf
11 rows selected.