数据库管理-第五十八期 倒腾PDB(20230226)

数据库管理 2023-02-26

  • 第五十八期 倒腾PDB
    • 1 克隆本地PDB
    • 2 没开归档
    • 总结

第五十八期 倒腾PDB

其实本周过的不大好,连着两天熬夜,一次是割接一次是处理ADG备库的异常,其实本周有些内容是以前处理过的问题,到了周末还肚子痛。哎…

1 克隆本地PDB

这周一个朋友说他克隆了一个本地PDB,然后同时想把部分数据文件换个地方,然后把ADG搞挂了。首先说一下迁移数据库文件的问题,他用很传统的rename的方式做的迁移,其实从12.2开始可以用下面的语句来在线迁移数据文件的:

alter database move '/old/path/to/file' to '/new/path/';

而造成ADG异常的问题其实主要还是源自于源库本地克隆PDB,这个操作会造成备库无法正确获取克隆的数据文件,这里涉及一个Bug 25350791 - ORACLE12.2 ORA-01274 IN ADG WHEN CLONING LOCAL PDB IN PRIMARY,而解决方案则是PDB which has to be cloned on primary should be placed in read only mode for the duration of cloning on primary and physical standby should be in active data guard before performing the cloning.将需要克隆的PDB先至于read only状态则可以避免出现这个问题。当然如果已经整出异常了则需要通过一下操作进行恢复:

-- At STANDBY
$ sqlplus / as sysdba
SQL> shutdown immediate
SQL> startup nomount;

$ rman target /
RMAN> RESTORE STANDBY CONTROLFILE FROM SERVICE primarydb;
RMAN> ALTER DATABASE MOUNT;

4. Restore the PDB at Standby using Primary Service :

-- At STANDBY
$ rman target /

run{
set newname for pluggable database NEW_PDB to new;
restore pluggable database NEW_PDB from service primarydb;
}

5. Catalog Standby datafiles and Switch to Copy :

-- At STANDBY
RMAN> catalog start with '+ASM/PATH';
RMAN> SWITCH DATABASE TO COPY;

6. Start Managed Recovery Process (MRP) at Standby :

-- At STANDBY
SQL> alter database recover managed standby database disconnect from session;

7. Enable DG Broker at Both Primary and Standby :

-- At Both PRIMARY and STANDBY
$ sqlplus / as sysdba
SQL> alter system set dg_broker_start=TRUE scope=both sid='*';

如果步骤5出现问题则需要执行下面的内容:
1. Catalog the datafiles of standby database
Below command will give you a list of files and ask if they should all be catalog. Review the list and say YES if all the datafiles are properly listed
In below command while cataloging the files, the string specified should refer to the diskgroup/filesystem destination of the standby data files.
RMAN> catalog start with '';
Note:
a) This will only work if you are using OMF. If you are using ASM without OMF you have to catalog all non-OMF Datafiles as Datafile Copies manually using
RMAN> catalog datafilecopy '';
b) If you have Datafiles on different Diskgroups you have to catalog from all Diskgroups, of course.
2. Commit the changes to the controlfile
RMAN> switch database to copy;
If this doesn't work then switch datafiles manually:
If only renaming a single datafile:
RMAN> switch datafile n to copy;
eg.
RMAN> switch datafile 1 to copy;
If renaming a list of files:
RMAN> switch datafile n,o,p,q to copy;
eg.
RMAN> switch datafile 1,2,3,4 to copy;
3. Once all the datafiles are switched, You should start the MRP on Standby database:
SQL> alter database recover managed standby database disconnect from session;

2 没开归档

这是前两周迁移PDB的时候,从别家公司管理的12.2的RAC集群迁移到19.13的Exadata,本来都是驾轻就熟的事情,结果迁移过程中出现了下面的问题:
数据库管理-第五十八期 倒腾PDB(20230226)_第1张图片
随即咨询源库管理员,原来源库没有开归档…这…官方文档也对此有详细说明:

因此通知源库管理员将需要克隆的PDB开启为只读状态,解决问题。虽说源库跑的都是分析型业务,但是不开归档,属实说不过去,说是归档太大了,容量撑不住,但是业务其实还是很重要的,如果出现异常没有归档恢复还是会引起很多问题。没有专业DBA还是一件可怕的事情。

总结

老规矩,知道写了些啥。

你可能感兴趣的:(Oracle,数据库,sql,oracle)