Ready for Switchover: Yes Ready for Failover: Yes (Primary Running)
查看主库所有的pdbs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
sys@ORA12C> show parameter db_unique_name
PARAMETER_NAME TYPE VALUE ------------------------------------------------------------ ----------- ---------------------------------------------------------------------------------------------------- db_unique_name string ora12c sys@ORA12C> select Database_role from v$database;
DATABASE_ROLE ---------------- PRIMARY
sys@ORA12C> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ WRITE NO
PARAMETER_NAME TYPE VALUE ------------------------------------------------------------ ----------- ---------------------------------------------------------------------------------------------------- db_unique_name string ORA12C_DG sys@ORA12C> select database_role from v$database;
DATABASE_ROLE ---------------- PHYSICAL STANDBY
sys@ORA12C> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ ONLY NO sys@ORA12C> select name, recovery_status from v$pdbs;
NAME RECOVERY -------------------------------------------------------------------------------------------------------------------------------- -------- PDB$SEED ENABLED PDB12C ENABLED
通过STANDBYS=NONE选项创建pdb
1 2 3 4 5 6 7 8 9 10 11
sys@ORA12C> create pluggable database pdb2 admin user xb identified by oracle STANDBYS=NONE;
Pluggable database created.
sys@ORA12C> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ WRITE NO 5 PDB2 MOUNTED
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ ONLY NO 5 PDB2 MOUNTED
sys@ORA12C> select name, recovery_status from v$pdbs;
NAME RECOVERY -------------------------------------------------------------------------------------------------------------------------------- -------- PDB$SEED ENABLED PDB12C ENABLED PDB2 DISABLED
查看数据文件的状态
1 2 3 4 5 6 7 8 9 10 11
sys@ORA12C> alter session set container=pdb2;
Session altered.
sys@ORA12C> col name for a80 sys@ORA12C> select name, status from v$datafile; NAME STATUS -------------------------------------------------------------------------------- ------- /u01/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00016 SYSOFF /u01/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00017 RECOVER /u01/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00018 RECOVER
尝试打开PDB2
1 2 3 4 5
sys@ORA12C> alter pluggable database pdb2 open; alter pluggable database pdb2 open * ERROR at line 1: ORA-01111: name for data file 16 is unknown - rename to correct file
PDB2(4):Datafile 13 added to flashback set PDB2(4):Successfully added datafile 13 to media recovery PDB2(4):Datafile #13: '/u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_system_gczyjjms_.dbf' 2019-04-24T13:55:23.737483+08:00 Recovery copied files for tablespace SYSAUX Recovery successfully copied file /u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_sysaux_gczyjjnf_.dbf from /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_sysaux_gcxbqyr5_.dbf PDB2(4):Datafile 14 added to flashback set PDB2(4):Successfully added datafile 14 to media recovery PDB2(4):Datafile #14: '/u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_sysaux_gczyjjnf_.dbf' 2019-04-24T13:55:25.426806+08:00 Recovery copied files for tablespace UNDOTBS1 Recovery successfully copied file /u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_undotbs1_gczyjjnf_.dbf from /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_undotbs1_gcxbsf50_.dbf PDB2(4):Datafile 15 added to flashback set PDB2(4):Successfully added datafile 15 to media recovery PDB2(4):Datafile #15: '/u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_undotbs1_gczyjjnf_.dbf' 2019-04-24T13:55:27.687506+08:00 Buffer Cache Full DB Caching mode changing from FULL CACHING ENABLED to FULL CACHING DISABLED Full DB Caching disabled: DEFAULT_CACHE_SIZE should be at least 70 MBs bigger than current size. 2019-04-24T13:56:40.020461+08:00 PDB2(4):Recovery dropped temporary tablespace 'TEMP' PDB2(4):Recovery deleting file #15:'/u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_undotbs1_gczyjjnf_.dbf' from controlfile. PDB2(4):Deleted Oracle managed file /u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_undotbs1_gczyjjnf_.dbf PDB2(4):Recovery dropped tablespace 'UNDOTBS1' PDB2(4):Recovery deleting file #14:'/u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_sysaux_gczyjjnf_.dbf' from controlfile. PDB2(4):Deleted Oracle managed file /u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_sysaux_gczyjjnf_.dbf 2019-04-24T13:56:41.232472+08:00 PDB2(4):Recovery dropped tablespace 'SYSAUX' PDB2(4):Recovery deleting file #13:'/u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_system_gczyjjms_.dbf' from controlfile. PDB2(4):Deleted Oracle managed file /u01/app/oracle/oradata/ORA12C_DG/874155556D1A9CB6E0536892A8C0B4D1/datafile/o1_mf_system_gczyjjms_.dbf PDB2(4):Recovery dropped tablespace 'SYSTEM' PDB2(4):Recovery dropped pluggable database 'PDB2' 2019-04-24T13:56:43.248383+08:00 Buffer Cache Full DB Caching mode changing from FULL CACHING DISABLED to FULL CACHING ENABLED 2019-04-24T13:58:13.327411+08:00 Recovery created pluggable database PDB2 PDB2(5):File copy for ts-SYSTEM skipped for excluded/offline tablespace PDB2(5):File #16 added to control file as 'UNNAMED00016'. Originally created as: PDB2(5):'/u01/app/oracle/oradata/ORA12C/874155556D1B9CB6E0536892A8C0B4D1/datafile/o1_mf_system_gczyo7v3_.dbf' PDB2(5):because the pluggable database was created with nostandby PDB2(5):or the tablespace belonging to the pluggable database is PDB2(5):offline. 2019-04-24T13:58:14.710452+08:00 PDB2(5):File copy for ts-SYSAUX skipped for excluded/offline tablespace PDB2(5):File #17 added to control file as 'UNNAMED00017'. Originally created as: PDB2(5):'/u01/app/oracle/oradata/ORA12C/874155556D1B9CB6E0536892A8C0B4D1/datafile/o1_mf_sysaux_gczyo7v3_.dbf' PDB2(5):because the pluggable database was created with nostandby PDB2(5):or the tablespace belonging to the pluggable database is PDB2(5):offline. 2019-04-24T13:58:15.722284+08:00 PDB2(5):File copy for ts-UNDOTBS1 skipped for excluded/offline tablespace PDB2(5):File #18 added to control file as 'UNNAMED00018'. Originally created as: PDB2(5):'/u01/app/oracle/oradata/ORA12C/874155556D1B9CB6E0536892A8C0B4D1/datafile/o1_mf_undotbs1_gczyo7v4_.dbf' PDB2(5):because the pluggable database was created with nostandby PDB2(5):or the tablespace belonging to the pluggable database is PDB2(5):offline. 2019-04-24T13:58:16.826353+08:00 PDB2(5):File copy for ts-TEMP skipped for excluded/offline tablespace
DGMGRL> swithover to ora12c_dg Unrecognized command "swithover", try "help" DGMGRL> switchover to ora12c_dg Performing switchover NOW, please wait... Operation requires a connection to database "ora12c_dg" Connecting ... Connected to "ORA12C_DG" Connected as SYSDBA. New primary database "ora12c_dg" is opening... Operation requires start up of instance "ora12c" on database "ora12c" Starting instance "ora12c"... ORACLE instance started. Database mounted. Database opened. Connected to "ora12c" Switchover succeeded, new primary is "ora12c_dg"
PARAMETER_NAME TYPE VALUE ------------------------------------------------------------ ----------- ---------------------------------------------------------------------------------------------------- db_unique_name string ora12c sys@ORA12C> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C MOUNTED 5 PDB2 MOUNTED sys@ORA12C> alter pluggable database all open;
Pluggable database altered.
sys@ORA12C> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ ONLY NO 5 PDB2 READ ONLY NO
Ready for Switchover: Yes Ready for Failover: Yes (Primary Running)
Managed by Clusterware: ora12c_dg: NO ora12c : NO Warning: Ensure primary database's StaticConnectIdentifier property is configured properly so that the primary database can be restarted by DGMGRL after switchover
如果配了archive log删除策略的话,比如APPLIED ON ALL STANDBY之类,先暂时禁用掉,备库需要在拷贝过程开始时所有的归档日志用于恢复,等到全部过程顺利结束以后再修改回来,注意这里主备库都需要修改删除策略
1
Rman> configure archivelog deletion policy to none;
检查主库PDBs的状态,确保是可以读写的
1 2 3 4 5 6 7
sys@ORA12C> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ WRITE NO 5 PDB2 READ WRITE NO
connected to target database: ORA12C (DBID=383814323)
run{ set newname for pluggable database PDB2 to new; restore pluggable database PDB2 from service ora12c; switch datafile all; 5> }
executing command: SET NEWNAME
Starting restore at 24-APR-19 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=622 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ora12c channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00025 to /u01/app/oracle/oradata/ORA12C_DG/874511D1C1D14E3BE0536892A8C07D48/datafile/o1_mf_system_%u_.dbf channel ORA_DISK_1: restore complete, elapsed time: 00:00:36 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ora12c channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00026 to /u01/app/oracle/oradata/ORA12C_DG/874511D1C1D14E3BE0536892A8C07D48/datafile/o1_mf_sysaux_%u_.dbf channel ORA_DISK_1: restore complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service ora12c channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00027 to /u01/app/oracle/oradata/ORA12C_DG/874511D1C1D14E3BE0536892A8C07D48/datafile/o1_mf_undotbs1_%u_.dbf channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 Finished restore at 24-APR-19
sys@ORA12C> col name for a120 sys@ORA12C> select name, status from v$datafile;
NAME STATUS ------------------------------------------------------------------------------------------------------------------------ ------- /u01/app/oracle/oradata/ORA12C_DG/874511D1C1D14E3BE0536892A8C07D48/datafile/o1_mf_system_gd0g96yn_.dbf SYSTEM /u01/app/oracle/oradata/ORA12C_DG/874511D1C1D14E3BE0536892A8C07D48/datafile/o1_mf_sysaux_gd0gb7nr_.dbf RECOVER /u01/app/oracle/oradata/ORA12C_DG/874511D1C1D14E3BE0536892A8C07D48/datafile/o1_mf_undotbs1_gd0gcnsc_.dbf RECOVER
sys@ORA12C> select * from v$recover_file;
no rows selected
sys@ORA12C> select name, recovery_status from v$pdbs where name = 'PDB2';
NAME RECOVERY ------------------------------------------------------------------------------------------------------------------------ -------- PDB2 ENABLED