Oracle 19c Activity Task
Oracle 19c Activity Task
Tasks:
Use the new commands SHOW CON_NAME and CON_ID to know which container you
are connected to.
SQL> SHOW con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> SHOW con_id
CON_ID
------------------------------
1
SQL>
1.3 View some of the family of view CDB_xxx:
===========================
==============================
export ORACLE_HOME=/u01/app/oracle/product/19.1.0/dbhome_1
export ORACLE_SID=cdb19
PATH=$ORACLE_HOME/bin:$PATH; export PATH
cd /home/oracle/labs/admin
mkdir -p /u04/app/oracle/redo/CDB19
=============
3. Verify that the characteristics of the database are satisfied.
======================
a. Check that the CDB is a CDB.
$ . oraenv
ORACLE_SID = [ORCL] ? cdb19
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus / AS SYSDBA
SQL> SELECT cdb FROM v$database;
CDB
---
YES
SQL>
b. Check that the data files are located in the /u02/app/oracle/oradata/cdb19
directory.
SQL> COL name FORMAT A58
SQL> SELECT name FROM v$datafile ORDER BY 1;
NAME
----------------------------------------------------------
/u02/app/oracle/oradata/CDB19/pdbseed/sysaux01.dbf
/u02/app/oracle/oradata/CDB19/pdbseed/system01.dbf
c. Verify that the permanent tablespaces USERS and UNDO tablespaces are created and
that there is the TEMP temporary tablespace.
SQL> SELECT tablespace_name, contents FROM dba_tablespaces;
TABLESPA CONTENTS
-------- ---------------------
SYSTEM PERMANENT
SYSAUX PERMANENT
UNDOTBS1 UNDO
TEMP TEMPORARY
USERS PERMANENT
7. Let’s explore the ADR (Automatic Diagnostic Repository) for the CDB and PDBs.
a. Check the alert_cdb19.log file of the CDB instance.
$ cd $ORACLE_BASE/diag/rdbms/cdb19/cdb19/trace
$ tail -20 alert_cdb19.log
PDB19(4):Deleting old file#8 from file$
Observe that all operations related to PDBs in the CDB are reported in the single
alert_cdb19.log file of the CDB instance.
b. Find the CREATE PLUGGABLE DATABASE and ALTER PLUGGABLE DATABASE
operations in the alert.log.
$ grep -i "create pluggable database" alert_cdb19.log
CREATE PLUGGABLE DATABASE PDB$SEED AS CLONE USING
'/u01/app/oracle/product/19.1.0/dbhome_1/assistants/dbca/templat
es/pdbseed.xml' source_file_name_convert =
('/oradata/SEEDDATA/pdbseed/system01.dbf','/u02/app/oracle/orada
ta/CDB19/pdbseed/system01.dbf',
Completed: CREATE PLUGGABLE DATABASE
4.Relocating PDBs
1.verify that the source remote CDB is configured to use local UNDO.
$ . oraenv
ORACLE_SID = [cdb19] ? ORCL
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus / AS SYSDBA
SQL> SELECT property_name, property_value
FROM database_properties
WHERE property_name = 'LOCAL_UNDO_ENABLED';
23
PROPERTY_NAME PROPERTY_VALUE
------------------ --------------
LOCAL_UNDO_ENABLED TRUE
SQL> CONNECT test@PDB1
Enter password:
Connected.
SQL> SELECT LABEL, COUNT(*) FROM test.bigtab GROUP BY label;
LABEL COUNT(*)
------------------------------ ----------
DATA FROM test.bigtab 10000
SQL>
===========================================
SQL> STARTUP
ORACLE instance started.
Total System Global Area 4697620480 bytes
Fixed Size 2923760 bytes
Variable Size 989856528 bytes
Database Buffers 3690987520 bytes
Redo Buffers 13852672 bytes
Database mounted.
Database opened.
====================
Not all instance parameters are modifiable at the PDB level. A modifiable one,
OPTIMIZER_USE_SQL_PLAN_BASELINES, has been chosen for the example so as to
show how instance parameters behave at PDB and CDB level
$ . oraenv
ORACLE_SID = [ORCL] ? ORCL
The Oracle base has been set to /u01/app/oracle
$ sqlplus / AS SYSDBA
Connected.
SQL> SELECT ispdb_modifiable FROM v$parameter
WHERE name = 'optimizer_use_sql_plan_baselines';
2
ISPDB
-----
TRUE
Connect to pdb1 in ORCL and check the current value of the same instance parameter
OPTIMIZER_USE_SQL_PLAN_BASELINES.
SQL> CONNECT sys@pdb1 AS SYSDBA
Enter password:
Connected.
SQL> SHOW PARAMETER optimizer_use_sql_plan_baselines
NAME TYPE VALUE
------------------------------------ ----------- ---------
optimizer_use_sql_plan_baselines boolean TRUE
9.Storage:
========
Make the CDATA tablespace the default tablespace in the root container.
SQL> ALTER DATABASE DEFAULT TABLESPACE CDATA;
Database altered.
Make the ldata tablespace the default tablespace in the pdb1 container.
SQL> ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE ldata;
Pluggable database altered.
SQL> SELECT property_name, property_value
FROM database_properties
WHERE property_name LIKE 'DEFAULT_%TABLE%';
23
PROPERTY_NAME PROPERTY_VALUE
---------------------------- --------------
DEFAULT_PERMANENT_TABLESPACE LDATA
DEFAULT_TEMP_TABLESPACE TEMP
SQL>
Set undopdb1 as the new DEFAULT UNDO TABLESPACE for pdb1, drop the old UNDO
TABLESPACE UNDOTBS1, and validate the result.
SQL> ALTER SYSTEM SET undo_tablespace='undopdb1' SCOPE=BOTH;
System altered.
SQL> DROP TABLESPACE UNDOTBS1;
Tablespace dropped.
SQL> SELECT file#, ts.name, ts.ts#, ts.con_id
FROM v$datafile d, v$tablespace ts
WHERE d.ts#=ts.ts#
AND d.con_id=ts.con_id
AND ts.name like 'UNDO%';
2345
FILE# NAME TS# CON_ID
---------- --------------- ---------- ------
63 UNDOPDB1 8 4
SQL> EXIT
====================
10. Security
=================
================
Observe lockdown profile behavior in pdb1 when the CDB root lockdown profile is set.
a. Set the CDB_prof1 lockdown profile in the CDB root.
SQL> SHOW PARAMETER pdb_lockdown
NAME TYPE VALUE
----------------------------- ----------- --------------------
pdb_lockdown string
SQL> ALTER SYSTEM SET pdb_lockdown = CDB_prof1 SCOPE = BOTH;
System altered.
SQL> SHOW PARAMETER pdb_lockdown
NAME TYPE VALUE
----------------------------- ----------- --------------------
pdb_lockdown string CDB_PROF1
SQL>
b. Observe how the pdb1 PDB inherits the restrictions of the CDB root lockdown
Observe how the pdb1 PDB inherits the restrictions of the CDB root lockdown profile.
SQL> CONNECT sys@PDB1 AS SYSDBA
Enter password:
Connected.
SQL> SHOW PARAMETER pdb_lockdown
NAME TYPE VALUE
----------------------------- ----------- --------------------
pdb_lockdown string CDB_PROF1
SQL> ALTER SYSTEM SET ddl_lock_timeout=30 SCOPE = BOTH;
System altered.
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> ALTER SYSTEM CHECKPOINT;
ALTER SYSTEM CHECKPOINT
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL>
===================
Managing PDB Keystores
===================
Configure the wallet root location and restart the database instance.
Configure the default keystore type for any future isolated PDB. In our case, the
isolated keystores will be stored as OS files.
SQL> ALTER SYSTEM SET tde_configuration =
'KEYSTORE_CONFIGURATION=FILE'
SCOPE=BOTH;
23
System altered.
SQL>
==============================
=======================================
PDB PITR
======
RMAN> RUN {
SET UNTIL SCN = 3267497;
RESTORE PLUGGABLE DATABASE pdb1;
RECOVER PLUGGABLE DATABASE pdb1 AUXILIARY
DESTINATION='/u02/app/oracle/oradata';
ALTER PLUGGABLE DATABASE pdb1 OPEN RESETLOGS;
}