12C adg 同步新加PDB
一、12c ADG 在主库创建PDB
create pluggable database testpdb ADMIN USER test identified by test
ROLES=(CONNECT) FILE_NAME_CONVERT=('/u01/app/oracle/oradata/testdb/pdbseed','/u01/app/oracle/oradata/testdb/testpdb') tempfile reuse STANDBYS=NONE;
alter pluggable database testpdb open;--启动PDB
--备份新建pdb
rman target '"/ as sysbackup"'
RMAN> backup format '/home/oracle/backup/full_pdb_testpdb.dmp' pluggable database testpdb;
--拷贝备份集和控制文件到备库/dbbackup目录下
-- 备库操作
--验证主备库文件
select file#,name from v$datafile;---查询文件对应的 ID 号
---RMAN 恢复
$ rman target '"/ as sysbackup"'
RMAN> catalog start with '/home/oracle/backup';
RMAN>
run{
set newname for datafile 14 to '/u01/app/oracle/oradata/teststdydb/testpdb/system01.dbf';
set newname for datafile 15 to '/u01/app/oracle/oradata/teststdydb/testpdb/sysaux01.dbf';
set newname for datafile 16 to '/u01/app/oracle/oradata/teststdydb/testpdb/undotbs01.dbf';
restore pluggable database testpdb;
switch datafile all;
}
SQL> shutdown immediate
SQL> startup mount
SQL> alter session set container=testpdb;
SQL> alter pluggable database enable recovery;
SQL> alter database open;---起的是CDB--不能直接起PDB
ORA-01219: database or pluggable database not open: queries allowed on fixed tables or views only
SQL> alter pluggable database testpdb open;
再重启一次。
---上面这种方式创建的PDB 没有USERS 表空间--主库操作
create tablespace users datafile '/u01/app/oracle/oradata/testdb/testpdb/users01.dbf' size 2G autoextend off;