#停快速故障轉移功能
DGMGRL> stop observer
DGMGRL> disable fast_start failover;
#主库停止日志传到从库
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=DEFER;
or
DGMGRL> edit configuration set protection mode as MaxPerformance;
DGMGRL> edit database 'DG125' set property LogXptMode ='ASYNC';
DGMGRL> edit database 'DG126' set property LogXptMode ='ASYNC';
DGMGRL> edit database 'DG125' set state='TRANSPORT-OFF';
SQL> alter system switch logfile; #(主庫切換日誌否則 TRANSPORT-OFF 不會立即生效)
#drop pdb
#备库、主库都close pdb
SQL>alter pluggable database PDB3 close;
#主库drop pdb
SQL>drop pluggable database PDB3 including datafiles;
#主庫 create pdb
#作廢 alter system set db_create_file_dest='/u01/app/oracle/oradata/DG/';
create pluggable database PDB2 admin user xag2 identified by 123456
file_name_convert=('/u01/app/oracle/oradata/DG/pdbseed','/u01/app/oracle/oradata/DG/PDB2');
SYS@XAGDB>alter session set container=PDB2;
SYS@XAGDB> startup;
--sys login pdb2
select tablespace_name,file_name,bytes/1024/1024 mb from dba_temp_files;
create tablespace PDB2_UD datafile
'/u01/app/oracle/oradata/DG/PDB2/PDB2_UD_1.dbf' size 16M AUTOEXTEND ON NEXT 8M MAXSIZE UNLIMITED,
'/u01/app/oracle/oradata/DG/PDB2/PDB2_UD_2.dbf' size 16M AUTOEXTEND ON NEXT 8M MAXSIZE UNLIMITED
default storage (initial 128K next 2M pctincrease 0);
Create tablespace I_PDB2_UD datafile
'/u01/app/oracle/oradata/DG/PDB2/I_PDB2_UD_1.dbf' size 16M AUTOEXTEND ON NEXT 8M MAXSIZE UNLIMITED,
'/u01/app/oracle/oradata/DG/PDB2/I_PDB2_UD_2.dbf' size 16M AUTOEXTEND ON NEXT 8M MAXSIZE UNLIMITED
default storage (initial 128K next 2M pctincrease 0);
--------------------------------------------------------------
CREATE SMALLFILE TEMPORARY TABLESPACE PDB2_TD1 TEMPFILE
'/u01/app/oracle/oradata/DG/PDB2/PDB2_TD1_1.dbf' SIZE 32M,
'/u01/app/oracle/oradata/DG/PDB2/PDB2_TD1_2.dbf' SIZE 32M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
or
create temporary tablespace PDB2_TD1 tempfile
'/u01/app/oracle/oradata/DG/PDB2/PDB2_TD1_1.dbf' size 32M REUSE AUTOEXTEND ON NEXT 32M MAXSIZE 1024M,
'/u01/app/oracle/oradata/DG/PDB2/PDB2_TD1_2.dbf' size 32M REUSE AUTOEXTEND ON NEXT 32M MAXSIZE 1024M extent management local;
-----------------------------------------------------------
ALTER TABLESPACE PDB2_TD1 TABLESPACE GROUP PDB2_GROUP;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE PDB2_GROUP;
select * from dba_tablespace_groups
ALTER DATABASE DEFAULT TABLESPACE PDB2_UD;
drop tablespace TEMP including contents and datafiles cascade constraints;
ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/DG/PDB2/undotbs01.dbf' RESIZE 110M;
ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/DG/PDB2/undotbs01.dbf' AUTOEXTEND ON NEXT 32M;
GRANT DBA to xag2;
SQL> grant connect,resource,unlimited tablespace to xag2;
SQL> grant create any directory to xag2;
SQL> grant drop any directory to xag2;
#異機不同存放位置插入PDB(PDB8來源其他機器)
copy 源機器的PDB8目錄下文件 到
主機及備機 的 /u01/app/oracle/oradata/DG/PDB8;
SQL> create pluggable database PDB8 using '/u01/tmp/pdb8.xml' SOURCE_FILE_NAME_CONVERT =('/u02/app/oracle/oradata/DG/PDB8/', '/u01/app/oracle/oradata/DG/PDB8/') nocopy storage (maxsize 2G) tempfile reuse;
这里xml文件中指示数据文件在/u02/app/oracle/oradata/DG/PDB8/中,
最终我们要将数据文件放在/u01/app/oracle/oradata/DG/PDB8/中
SQL> show pdbs;
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 PDB8 MOUNTED
SQL> alter pluggable database PDB8 open;
SQL> show pdbs;
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 PDB8 READ WRITE NO
#主库启动日志传到从库
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;
or
DGMGRL> edit database 'DG125' set state='TRANSPORT-ON';
DGMGRL> edit database 'DG125' set property LogXptMode ='SYNC';
DGMGRL> edit database 'DG126' set property LogXptMode ='SYNC';
DGMGRL> edit configuration set protection mode as MaxAvailability;
主库启动日志传到从库后,备库也open pdb2
alter pluggable database PDB2 open;
alter pluggable database PDB8 open;
#備庫添加臨時表空間文件
ALTER TABLESPACE PDB2_TD1 ADD TEMPFILE
'/u01/app/oracle/oradata/DG/PDB2/PDB2_TD1_1.dbf'
SIZE 32M REUSE AUTOEXTEND ON NEXT 32M MAXSIZE 1024M; --32767M
ALTER TABLESPACE PDB2_TD1 ADD TEMPFILE
'/u01/app/oracle/oradata/DG/PDB2/PDB2_TD1_2.dbf'
SIZE 32M REUSE AUTOEXTEND ON NEXT 32M MAXSIZE 1024M;
#啟動快速故障轉移功能
DGMGRL> enable fast_start failover;
DGMGRL> start observer
參考:
https://docs.oracle.com/database/121/SQLRF/statements_6010.htm#SQLRF55686