Creating a PDB in a Primary Database using CREATE PLUGGABLE DATABASE

os: centos 7.6
db: oracle 19.3

oracle active dataguard 环境下,在 primary 上创建 pdb.

enabled_pdbs_on_standby

SQL> show parameter enabled_pdbs_on_standby;

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
enabled_PDBs_on_standby 	     string	 *

The ENABLED_PDBS_ON_STANDBY parameter is valid only on a physical standby,it is ignored by primary databases.;

STANDBYS

CREATE PLUGGABLE DATABASE … STANDBYS={('cdb_name', 'cdb_name', ...) |
NONE | ALL [EXCEPT ('cdb_name', 'cdb_name', ...)]}

– cdb_name is the DB_UNIQUE_NAME for the physical standbys in which the PDB is to be included.

– NONE excludes the PDB from being created in any of the standby CDBs. When
a PDB is excluded from all standby CDBs, the PDB’s data files are offline and
marked as unnamed on all of the standby CDBs. Any new standby CDBs that
are instantiated after the PDB has been created must disable the PDB for
recovery explicitly to exclude it from the standby CDB. It is possible to enable
a PDB on a standby CDB after it was excluded on that standby CDB.

– ALL (the default) includes the PDB being created in all standby CDBs.

– EXCEPT cdb_name includes the PDB being created in all standby CDBs except for those CDBs listed in this clause by their DB_UNIQUE_NAME.

automatically maintain standby databases

• To automatically maintain standby databases when performing PDB remote
clones or plugins, use the following initialization parameters:

STANDBY_PDB_SOURCE_FILE_DBLINK
—For use with remote cloning. Specifies
the name of the database link used to clone the PDB at the primary. When
the redo for the PDB clone operation is applied at the standby, it uses that
database link to connect to the source database to repeat the clone process to
the destination standby database. This parameter is available only in Active
Data Guard because it accesses the database dictionary for specific
information about the link.
The source PDB for the cloning operation must be in read only mode for the
duration of both the clone to the primary and the clone to the standby.
On remote clones that do not use the STANDBY_PDB_SOURCE_FILE_DBLINK
parameter, the SQL CREATE PLUGGABLE DATABASE statement used to create
the PDB must use the STANDBYS=NONE clause.

STANDBY_PDB_SOURCE_FILE_DIRECTORY
—For use with plugins. Specifies the
directory location where files of a PDB being used for repeated plugins are
stored. When the redo for the PDB plugin operation is applied at the standby,
it searches the directory location for the data files and after finding them,
copies them to the location the standby requires them to be based on the
settings of the DB_CREATE_FILE_DEST and DB_FILE_NAME_CONVERT parameters.

CREATE PLUGGABLE DATABASE

如果前面已经创建了 pdb2,先删除.生产环境禁止删除

SQL> alter pluggable database pdb2 close immediate;
alter pluggable database pdb2 unplug into '/tmp/pdb2.xml';
drop pluggable database pdb2 including datafiles;

SQL> drop pluggable database pdb1 keep datafiles;

在 primay 上创建 pdb2

SQL> CREATE PLUGGABLE DATABASE pdb2
ADMIN USER pdbadmin IDENTIFIED BY rootroot 
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/ORCLP/pdbseed/', 
                     '/u01/app/oracle/oradata/ORCLP/pdb2/') 
STORAGE UNLIMITED
STANDBYS=ALL    
;

primary 上的 alert 日志

2019-06-21T14:25:39.945581+08:00
CREATE PLUGGABLE DATABASE pdb2
ADMIN USER pdbadmin IDENTIFIED BY *
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/ORCLP/pdbseed/',
                     '/u01/app/oracle/oradata/ORCLP/pdb2/')
STORAGE UNLIMITED
STANDBYS=ALL

2019-06-21T14:25:41.276248+08:00
PDB$SEED(2): AUDSYS.AUD$UNIFIED (SQL_TEXT) - CLOB populated
2019-06-21T14:26:10.256890+08:00
PDB2(4):Endian type of dictionary set to little
2019-06-21T14:26:12.587032+08:00
****************************************************************
Pluggable Database PDB2 with pdb id - 4 is created as UNUSABLE.
If any errors are encountered before the pdb is marked as NEW,
then the pdb must be dropped
local undo-1, localundoscn-0x0000000000000118
****************************************************************
2019-06-21T14:26:14.126613+08:00
PDB2(4):Autotune of undo retention is turned on. 
2019-06-21T14:26:19.574497+08:00
PDB2(4):Undo initialization recovery: err:0 start: 153519677 end: 153519841 diff: 164 ms (0.2 seconds)
2019-06-21T14:26:21.567374+08:00
PDB2(4):[29984] Successfully onlined Undo Tablespace 2.
PDB2(4):Undo initialization online undo segments: err:0 start: 153519841 end: 153521834 diff: 1993 ms (2.0 seconds)
PDB2(4):Undo initialization finished serial:0 start:153519677 end:153521888 diff:2211 ms (2.2 seconds)
PDB2(4):Database Characterset for PDB2 is AL32UTF8
PDB2(4):JIT: pid 29984 requesting stop
2019-06-21T14:26:25.953289+08:00
PDB2(4):Buffer Cache flush started: 4
PDB2(4):Buffer Cache flush finished: 4

2019-06-21T14:26:27.774735+08:00
Completed: CREATE PLUGGABLE DATABASE pdb2
ADMIN USER pdbadmin IDENTIFIED BY *
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/ORCLP/pdbseed/',
                     '/u01/app/oracle/oradata/ORCLP/pdb2/')
STORAGE UNLIMITED
STANDBYS=ALL


standby 上的 alert 日志

2019-06-21T14:26:10.064938+08:00
Recovery created pluggable database PDB2

2019-06-21T14:26:16.893868+08:00
Recovery copied files for tablespace SYSTEM
Recovery successfully copied file /u01/app/oracle/oradata/ORCLS1/pdb2/system01.dbf from /u01/app/oracle/oradata/ORCLS1/pdbseed/system01.dbf
PDB2(4):Recovery created file /u01/app/oracle/oradata/ORCLS1/pdb2/system01.dbf
PDB2(4):Successfully added datafile 17 to media recovery
PDB2(4):Datafile #17: '/u01/app/oracle/oradata/ORCLS1/pdb2/system01.dbf'

2019-06-21T14:26:25.945989+08:00
Recovery copied files for tablespace SYSAUX
Recovery successfully copied file /u01/app/oracle/oradata/ORCLS1/pdb2/sysaux01.dbf from /u01/app/oracle/oradata/ORCLS1/pdbseed/sysaux01.dbf
PDB2(4):Recovery created file /u01/app/oracle/oradata/ORCLS1/pdb2/sysaux01.dbf
PDB2(4):Successfully added datafile 18 to media recovery
PDB2(4):Datafile #18: '/u01/app/oracle/oradata/ORCLS1/pdb2/sysaux01.dbf'

2019-06-21T14:26:28.534948+08:00
Recovery copied files for tablespace UNDOTBS1
Recovery successfully copied file /u01/app/oracle/oradata/ORCLS1/pdb2/undotbs01.dbf from /u01/app/oracle/oradata/ORCLS1/pdbseed/undotbs01.dbf
PDB2(4):Recovery created file /u01/app/oracle/oradata/ORCLS1/pdb2/undotbs01.dbf
PDB2(4):Successfully added datafile 19 to media recovery
PDB2(4):Datafile #19: '/u01/app/oracle/oradata/ORCLS1/pdb2/undotbs01.dbf'

之后在 primary,standby 上分别打开 pdb2

SQL> alter pluggable database pdb2 open;

观察 alert 日志,发现 standby 上有如下信息,这个要处理下,要不然在 standby 上会报错.

PDB2(4):*********************************************************************
PDB2(4):WARNING: The following temporary tablespaces in container(PDB2)
PDB2(4):         contain no files.
PDB2(4):         This condition can occur when a backup controlfile has
PDB2(4):         been restored.  It may be necessary to add files to these
PDB2(4):         tablespaces.  That can be done using the SQL statement:
PDB2(4): 
PDB2(4):         ALTER TABLESPACE <tablespace_name> ADD TEMPFILE
PDB2(4): 
PDB2(4):         Alternatively, if these temporary tablespaces are no longer
PDB2(4):         needed, then they can be dropped.
PDB2(4):           Empty temporary tablespace: TEMP
PDB2(4):*********************************************************************

在 standby 节点 cdb 层面查看 datafile,tempfile.确保和 primary 的数量一致,缺少 tempfile 就手动添加.

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> 
SQL> show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB1 			  READ ONLY  NO
	 4 PDB2 			  READ ONLY  NO

SQL> set lines 200;
set pages 200;
col file# format 99;
col name format a100;
col con_id format 99;
select file#, name,con_id from v$tempfile order by file#;
select file#, name,con_id from v$datafile order by file#;

standby 节点执行 add tempfile 命令

SQL> alter session set container=PDB2;

SQL> set lines 200;
set pages 200;
col tablespace_name format a30;
col file_id format 99;
col file_name format a80;
select tablespace_name,file_id,file_name from dba_temp_files;
select tablespace_name,file_id,file_name from dba_data_files;

SQL> select tablespace_name,status,contents from dba_tablespaces;

TABLESPACE_NAME 	       STATUS	 CONTENTS
------------------------------ --------- ---------------------
SYSTEM			       ONLINE	 PERMANENT
SYSAUX			       ONLINE	 PERMANENT
UNDOTBS1		       ONLINE	 UNDO
TEMP			       ONLINE	 TEMPORARY


SQL> alter tablespace temp add tempfile '/u01/app/oracle/oradata/ORCLS1/pdb2/temp01.dbf' 
size 1g reuse autoextend on next 1g maxsize unlimited;

从这个上面来理解,temptablespace 作为实例运行的一部分,在 dataguard 环境下还需要在 standby 节点手动添加 tempfile .

参考:
<<Data Guard Impact on Oracle Multitenant Environments (文档 ID 2049127.1)>>
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=491556257459343&id=2049127.1&_adf.ctrl-state=qj0kopej7_57

<<Using standby_pdb_source_file_dblink and standby_pdb_source_file_directory to Maintain Standby Databases when Performing PDB Remote Clones or Plugins (文档 ID 2274735.1)>>
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=491589006771750&id=2274735.1&_adf.ctrl-state=qj0kopej7_114

猜你喜欢

转载自blog.csdn.net/ctypyb2002/article/details/93196317
今日推荐