首页 » Cloud » oracle 18c 、19c 重建 PDB standby database dataguard

oracle 18c 、19c 重建 PDB standby database dataguard

在Oracle 12c之后版本多租户环境的Standby DATABASE,当某一个PDB出现文件丢失时或PDB多个文件损坏,如何重建PDB standby database. 这里简单记录在18c后的方法。

方法1 一条命令
# on standby

alter database recover managed standby database cancel;

shut immedaite

statup MOUNT

RMAN>
run{

allocate channel disk1 device type disk;
allocate channel disk2 device type disk;
allocate channel disk3 device type disk;
allocate channel disk4 device type disk;
allocate channel disk5 device type disk;
set newname for pluggable database PDB0006 to '+DATA/ORCL/DATAFILE/%f_%b';

restore pluggable database PDB0006 from service  section size 64G;

release channel disk1 ;
release channel disk2 ;
release channel disk3 ;
release channel disk4 ;
release channel disk5 ;
}


RMAN> switch pluggable database PDB006 to copy;

online datafile(19c不需要)

SQL> alter session set container=PDB006;
SQL> set lines 120
SQL> set pages 9999
SQL> spool online_files.sql
SQL> select 'alter database datafile '||''''||name||''''||' online;' from v$datafile;

'ALTERDATABASEDATAFILE'||''''||NAME||''''||'ONLINE;'
------------------------------------------------------------------------------------------------------------------------
alter database datafile '+///DATAFILE/' online;
alter database datafile '+///DATAFILE/' online;
alter database datafile '+///DATAFILE/' online;

SQL> spool off

Restart the physical standby database in mount mode if it is running in Active Data Guard mode.
Change your container on the physical standby to the PDB to be enabled

SQL> alter session set container=pdb0006;
Session altered.

Issue the ENABLE RECOVERY command
SQL> show con_name
CON_NAME
------------------------------
PDB0006

SQL> alter pluggable database enable recovery;
Pluggable database altered.

方法2 备份+恢复

# on primary


rman > backup pluggable database xxx;


SQL> select q'[set newname for datafile ']' || name || q'[' to ]' || q'['/oracle/app/oradata/prod/]' || substr(name,instr(name,'/',-1)+1) || q'[';]' from v$datafile;


# on standby

alter pluggable databse xxx close;

recovery.sh:
rman target / log=recover_log << EOF 
run
{
allocate channel d1 device type disk;
allocate channel d2 device type disk;
allocate channel d3 device type disk;
catalog start with '/home/oracle/rman';
set newname for datafile '/oracle/app/oradata/proddg2/system01.dbf' to '/oracle/app/oradata/prod/system01.dbf';
set newname for datafile '/oracle/app/oradata/proddg2/sysaux01.dbf' to '/oracle/app/oradata/prod/sysaux01.dbf';
set newname for datafile '/oracle/app/oradata/proddg2/undotbs01.dbf' to '/oracle/app/oradata/prod/undotbs01.dbf';
set newname for datafile '/oracle/app/oradata/proddg2/users01.dbf' to '/oracle/app/oradata/prod/users01.dbf';
set newname for datafile '/oracle/app/oradata/proddg2/example01.dbf' to '/oracle/app/oradata/prod/example01.dbf';
release channel d1;
release channel d2;
release channel d3;
restore pluggable database xxx;
switch datafile all;
}
exit
EOF

— over —

打赏

,

对不起,这篇文章暂时关闭评论。