Flex ASM

In previous release, ASM clients can only access ASM using ASM instance running on the same server.  If ASM instance on that node fails, the clients all fail.  With Flex ASM removes the hard dependency between ASM and database clients and therefore it does not require ASM instance on each node.  ASM clients can use a remote ASM network for communication (ASM metadata, data blocks, and etc.) between ASM and its clients network connection to access ASM, so if ASM instance fails, its clients can connect to another instance.  The default cardinality for ASM instances is three (similar as scan) regardless of the cluster size.  Its different with scan is that with two nodes flex cluster, there are 2 ASM instances not 3.

Up to three ASM listeners are registered as remote listeners for each database client.  When setting up 12c, if you choose to configure a flex Cluster, Flex ASM is inherited and you must specify an ASM network.  However, ASM does not require a Flex cluster.  It can run on standard cluster providing I/O services and there are no new instance parameters for Flex ASM.  The default parameter settings are suitable to support most situations.

Clients are automatically relocated to another instance and are transparent to end users.  DBAs can query v$asm_client and manual relocation using the command “alter system relocate client <client_id>) before planned maintenance, applying a patch or adjust the workload balance between instances.

Flex Cluster - 12c Grid Infrastructure and RAC New Features

With oracle 12c clusterware, "Flex clusters" are built to scale up to 2000 nodes that you can use Flex cluster to manage large pools of high availability and failover protection application resources with multiple databases and application running in one cluster.
  • Hub Nodes:  The main component of a Flex Cluster is a group of Hub Nodes.  There is only one group of Hub nodes in a Flex cluster deployment, and each Hub Node must be connected to Shared storage across the group of Hub Nodes. 
  • Leaf Nodes:  Zero or more Leaf Nodes can be connected to a Flex Cluster through a Hub Node. Leaf nodes are loosely coupled and they are associated with a single Hub Node and periodically hub nodes exchange heartbeat messages with their associated Leaf Nodes.  Failure of hub node or network results in leaf node eviction.  It does not require direct access to shared storage and on the same networks (public and private) as the Hub nodes.
  • Only the Hub Nodes have direct access to the OCR and voting disks
  • Hub-and-spoke topology is the key architecture feature that segments the cluster into groups of nodes.  Two fundamental impacts:  1)  limiting the size of the hub to reduce contention to OCR and voting disks and 2) less heartbeats network traffic exchange between the nodes
  • Clients on Leaf Nodes use GNS (Grid Naming Service) to locate Hub Node services.  This requires access to GNS through a fixed VIP running on one of the nodes so that Leaf Node clients have reliable naming service within the cluster.
  • You can disable or enable Flex cluster functionalities.  By the default, Flex cluster functionality is disabled.
To convert from a standard cluster to a Flex Cluster, you need to ensure that GNS is configured with a fixed VIP and then set the cluster cluster mode via "crsctl set cluster mode flex" .  To covert from a Flex cluster to a standard cluster "crsctl set cluster mode standard".

To show the current node role:
crsctl get node role status -node glsn02
Node glsn02 active role is 'hub

Administrator can explicitly specified the node role as hub or leaf:
crsctl set node role leaf -node glsn02

Administrator can also set the node role to auto.  This allows the cluster to decide which role a node will perform based on the composition of the cluster.  The auto role works with cluster hubsize setting.  If Hub Nodes is smaller than hubsize, the nodes joins the cluster as a Hub Node.  Else, it joins the cluster as a Leaf Node.

The leafmisscount setting defines the threshold (in seconds) duration for tolerable communication failure between a Hub Node and associated leaf Node, if more than the defined value, the leaf node is evicted from the cluster.  By default, leafmisscount setting is 30 seconds.

Flex cluster and Node Failure:
  • Nodes that are evicted from the cluster do not require a restart; only a cluster software restart
  • If a Hub Node fails:   1)  the node is evicted from the cluster (services on the hub node are relocated to another Hub nodes)  2) Leaf nodes can reconnect to other Hub nodes within the grace period otherwise they are evicted from the cluster.
  • If a Leaf Node fails:  the node is evicted from the cluster, the cluster attempts to relocate services running on the leaf node to other leaf nodes connected to the same Hub node.

sosreport utility

Collect debugging information about a system and stores the information in /tmp as compressed file.
sosreport uses plug-ins with option -l (list available plugin), -n PLUGNAME (do not load specified plugin), -e PLUGNAME (enable the specified plug-in)

To install it:
yum install sos

Loaded plugins: rhnplugin, security
rhel-x86_64-server-5                                                                                                                                                                    | 1.4 kB     00:00  
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package sos.noarch 0:1.7-9.62.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================================
 Package                                   Arch                                         Version                                               Repository                                                  Size
===============================================================================================================================================================================================================
Updating:
 sos                                       noarch                                       1.7-9.62.el5                                          rhel-x86_64-server-5                                       162 k

Transaction Summary
===============================================================================================================================================================================================================
Install       0 Package(s)
Upgrade       1 Package(s)

Total download size: 162 k
Is this ok [y/N]: y
Downloading Packages:
sos-1.7-9.62.el5.noarch.rpm                                                                                                                                                             | 162 kB     00:00  
Transaction Test Succeeded
Running Transaction
  Updating       : sos                                                                                                                                                                                     1/2
  Cleanup        : sos                                                                                                                                                                                     2/2

Updated:
  sos.noarch 0:1.7-9.62.el5                                                                                                                                                                                  

Complete!

To execute sosreport
sosreport

sosreport (version 1.7)

This utility will collect some detailed  information about the
hardware and  setup of your  Red Hat Enterprise Linux  system.
The information is collected and an archive is  packaged under
/tmp, which you can send to a support representative.
Red Hat will use this information for diagnostic purposes ONLY
and it will be considered confidential information.

This process may take a while to complete.
No changes will be made to your system.

Press ENTER to continue, or CTRL-C to quit.

One or more plugins have detected a problem in your configuration.
Please review the following messages:

process:
    * one or more processes are in state D (sosreport might hang)

Are you sure you would like to continue (y/n) ? y

Please enter your first initial and last name [gls02]: anguyengls02
Please enter the case number that you are generating this report for: 1

EMC PowerPath is installed.
 Gathering EMC PowerPath information...
EMC PowerPath is running.
 Gathering additional EMC PowerPath information...
 plugin emc finished ...                          
 plugin yum finished ...                        
 Completed.

Creating compressed archive...

Your sosreport has been generated and saved in:
  /tmp/sosreport-anguyengls02.1-710805-8771ca.tar.bz2

The md5sum is: ed33337f0f37d788f5bb61690b8771ca

Please send this file to your support representative.

SharePlex installation

Download Shareplex software SharePlex-7.6.1-b27-oracle100-aix-52-ppc-m64.tpm  from Quest.

GLSLAB1 >>> ulimit -aH
time(seconds)        unlimited
file(blocks)         unlimited
data(kbytes)         unlimited
stack(kbytes)        4194304
memory(kbytes)       unlimited
coredump(blocks)     unlimited
nofiles(descriptors) unlimited

Installation:
glsdb01:/apps/oracle/soft
GLSLAB1 >>> ./SharePlex-7.6.1-b27-oracle100-aix-52-ppc-m64.tpm  Unpacking ..................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  .................................................................
SharePlex for Oracle installation program:
    SharePlex Version: 7.6.1
    Supported Oracle Version: 10gR2
    Build platform: aix-52-ppc
    Target platform: aix-53-ppc
Please enter the product directory location? /app/software/shareplex
Please enter the variable data directory location? /data/oracle/splex/vardir
Please specify the SharePlex Admin group (select a number):
1. [oinstall]
2. dba
?  1
Please wait while the installer obtains Oracle information ........
Please specify the ORACLE_SID that corresponds to this installation (select a number):
1. [current => GLSLAB1]
2. REFRESH1
6. <Other ...>
1
Please enter the ORACLE_HOME directory that corresponds to this ORACLE_SID? [/u01/oracle/10.2.0/DB04]
Please enter the TCP/IP port number for SharePlex communications? [2100]
Preparing to install SharePlex for Oracle v. 7.6.1:
    User:                     oracle
    Admin Group:              oinstall
    Product Directory:        /splex/oracle/product/splex
    Variable Data Directory:  /data/oracle/splex/vardir
    ORACLE_SID:               GLSLAB1
    ORACLE_HOME:              /u01/oracle/10.2.0/DB04
Proceed with installation? [yes]
Installing ................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  ..
Create Profile for Shareplex pr_splex and insert the following lines in .pr_splex profile

 cat .pr_splex
 export SP_SYS_HOST_NAME=glsdb01-vip
 export SP_COP_TPORT=2100
 export SP_COP_UPORT=2100
 export SP_SYS_VARDIR=/data/oracle/bkup1/splex/vardir
 #
 export SP_SW=/data/oracle/bkup1/splex/proddir
 export SP_BIN=${SP_SW}/bin
 #
 # -- For AIX Only
 # --

export EXTSHM=ON

cd $SP_BIN

To startup / shutdown / create configuration for shareplex:

Startup
$ cd /productdir/bin
$ ./sp_cop &
$ . /sp_ctrl

Create configuration
sp_ctrl(sysA)> create config od.config

Activate configurationsp_ctrl(sysA)> activate config od.config

Shutdown Shareplex
sp_ctrl > shutdown
splex_add_key script to start the SharePlex License Utility

List, Compare, show status

sp_ctrl(sysA)> list param all read
sp_ctrl > show compare
sp_ctrl > show compare detail
sp_ctrl > compare table from source to target
sp_ctrl > qstatus

GoldenGate Installation

High level GoldenGate Architecture

It provides log-based change data capture (CDC) nd replication of commited database transactions.  The software provies capture, routing, transformation and delivery of transactional data across heterogenerous enviornments in real time.
The movement of datain 4 steps:
1) Capture:  Changed data operations commited in the database transaction logsin a nonintrusive, high_performance, low-overhead implementation
2) Route:  variety of transport protocols and compress, encrypt changed data prior to routing
3) Transform: GoldenGate can execute a number of built-in functions like filtering and transformation
4) Apply:  It applies the changed transactional data with only sub-second latency

Installation:

Download the golden gate software ogg112102_ggs_Linux_s390x_ora11g_64bit.zip from edelivery.com
http://edelivery.oracle.com
select a langeguage ==> Continue ==> Export Validation and check the box to agree the license agreement
Select the Oracle Fusion Middleware Product Pact and select the appropriate platform and the Oracle GoldenGate Media Pack

Perform the same steps (1 to 4) in source and destination servers
1) tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar
2) Make a symbolic link

ln -s $ORACLE_HOME/lib/libnnz11.so $ORACLE_HOME/lib/libnnz10.so
3) Set LD_LIBRARY_PATH and validate the libraries required by GoldenGate are installed by executing the follwoing shell comands
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/apps/11.2.0/gg
dd ggsci
ldd mgr
ldd extract
ldd replicat
The command will return an error message if any missing libraries..
DBATOOLS - oracle: ldd replicat
        linux-vdso.so.1 =>  (0x00007fff557fd000)
        libdl.so.2 => /lib64/libdl.so.2 (0x000000392e400000)
        libgglog.so => /apps/11.2.0/gg/libgglog.so (0x00002ba6aee97000)
        libggrepo.so => /apps/11.2.0/gg/libggrepo.so (0x00002ba6af0d3000)
        libdb-5.2.so => /apps/11.2.0/gg/libdb-5.2.so (0x00002ba6af227000)
        libicui18n.so.38 => /apps/11.2.0/gg/libicui18n.so.38 (0x00002ba6af4c8000)
        libicuuc.so.38 => /apps/11.2.0/gg/libicuuc.so.38 (0x00002ba6af829000)
        libicudata.so.38 => /apps/11.2.0/gg/libicudata.so.38 (0x00002ba6afb62000)
        libxerces-c.so.28 => /apps/11.2.0/gg/libxerces-c.so.28 (0x00002ba6b0b3e000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x000000392e800000)
        libantlr3c.so => /apps/11.2.0/gg/libantlr3c.so (0x00002ba6b1056000)
        libnnz11.so => /apps/11.2.0/DB/lib/libnnz11.so (0x00002ba6b116c000)
        libclntsh.so.11.1 => /apps/11.2.0/DB/lib/libclntsh.so.11.1 (0x00002ba6b1539000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x000000392fc00000)
        libm.so.6 => /lib64/libm.so.6 (0x000000392ec00000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003930000000)
        libc.so.6 => /lib64/libc.so.6 (0x000000392e000000)
        /lib64/ld-linux-x86-64.so.2 (0x000000392dc00000)
        libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003931c00000)
        libaio.so.1 => /usr/lib64/libaio.so.1 (0x00002ba6b3ec7000)

4) ./ggsci
GGSCI (ljtcdb105.fnf.com) 2> create subdirs
Creating subdirectories under current directory /apps/11.2.0/gg
Parameter files                /apps/11.2.0/gg/dirprm: created (Parameter runtime configuration)
Report files                   /apps/11.2.0/gg/dirrpt: created (Process report files)
Checkpoint files               /apps/11.2.0/gg/dirchk: created (Golden Gate Checkpoint files)
Process status files           /apps/11.2.0/gg/dirpcs: created (Process Status)
SQL script files               /apps/11.2.0/gg/dirsql: created (SQL scipts)
Database definitions files     /apps/11.2.0/gg/dirdef: created (Source data definitions produced by DEFGEN and used to translate heterogeneous data)
Extract data files             /apps/11.2.0/gg/dirdat: created (Golden Gate trail and Extract files)
Temporary files                /apps/11.2.0/gg/dirtmp: created (Temporary storage for transactions that exceed memory)
Stdout files                   /apps/11.2.0/gg/dirout: created

5) Switch to archivelog mode
SQL> shutdown immediate ==> startup mount ==>alter database archivelog; alter database open;

6) Enable minimum sumplemental logging
SQL> alter database add supplemental log data;
SQL> alter system switch logfile;
SQL> select supplemental_log_data_min from v$database;

7) Turn off recyclebin (this is optional) and bounce the database
SQL> alter system set recyclebin=off scope=spfile;

8> Create a new tablespace GGATE and a new user GG_USER as Oracle GoldenGate schema name, then assigned it to this tablespace.
create tablespace ggate datafile '+DBA_PD101' size 5g autoextend on;
create user gg_user identified by oracle123 default tablespace GGATE temporary tablespace temp;

9) Grant necessary permission to gg_user
SQL> grant connect, resource, unlimited tablespace to gg_user;
SQL> grant execute on utl_file to gg_user;

10) Create necessary objects for ddl replication
SQL> @marker_setup.sql
Marker setup script
SQL> @ddl_setup.sql
Oracle GoldenGate DDL Replication setup script
SQL> @role_setup
GGS Role setup script
This script will drop and recreate the role GGS_GGSUSER_ROLE
SQL> GRANT GGS_GGSUSER_ROLE TO gg_user;
SQL> @ddl_enable.sql
Trigger altered.

ORA-00338: log 32 of thread 3 is more recent than control file

The solution is to apply patch 12770551.

We got this error ORA-338 in the Data Guard environment with ASYNC redo transport.  The connection with the remote database is closed and will not reopen until the next log switch.  Although it's not a critical situation and is not affect the database operation, applying the patch 12770551 is simple to get rid of the error.

Summary steps to apply PSU 11.2.0.3.2

It’s recommended to patch the PSU manually  on IBM Linux on z and other platform.  The opatch auto is still testing by Oracle support. and it won’t be stable (at least from what we’ve been tested)  until July 2013 PSU patchsets.  There are couple note that worth to mention: 

·         Before applying GI home, you must run rootcrs.pl to unlock the permissions.  Otherwise, the patching process will be failed with Opatch failed with error code 39.
·         When applying a GI patch to either the Grid Home or Database Home, you use "napply"
·         When applying a Database patch to either Database Home or Grid Home, you use "apply"

1)  export PATH=$ORACLE_HOME/OPatch:$PATH

2)  opatch version
     OPatch Version: 11.2.0.3.4 ß-------- Make sure you have the latest opatch version.

3) opatch prereq CheckconflictAgainstOHWithDetail -phBaseDir ./13696251
     Oracle Interim Patch Installer version 11.2.0.3.4
    Copyright (c) 2012, Oracle Corporation.  All rights reserved.
…….
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.

4)  sudo -u root $ORACLE_HOME/crs/install/rootcrs.pl –unlock Don’t forget this step!

[sudo] password for oracle:
Using configuration parameter file: /u01/app/oracle/11.2.0.3/grid/crs/install/crsconfig_params

Grid Home Patch:
5)  opatch napply -oh /u01/app/oracle/11.2.0.3/grid -local /data/oracle/bkup1/software/psu11.2.0.3.2/13696251

6) opatch apply -oh /u01/app/oracle/11.2.0.3/grid -local /data/oracle/bkup1/software/psu11.2.0.3.2/13696216

Database Patch:
7) opatch napply -oh /u01/app/oracle/11.2.0.3/racdb -local /data/oracle/bkup1/software/psu11.2.0.3.2/13696251/custom/server/13696251

8) opatch apply -oh /u01/app/oracle/11.2.0.3/racdb -local /data/oracle/bkup1/software/psu11.2.0.3.2/13696216

9) /data/oracle/bkup1/software/psu11.2.0.3.2/13696251/custom/server/13696251/custom/scripts/postpatch.sh -dbhome /u01/app/oracle/11.2.0.3/racdb

10) as root:  /u01/app/oracle/11.2.0.3/grid/rdbms/install/rootadd_rdbms.sh

11) as root :  /u01/app/oracle/11.2.0.3/grid/crs/install/rootcrs.pl -patch

OPatch failed to locate Central Inventory

Problem:

Inventory load failed... OPatch cannot load inventory for the given Oracle Home.
Possible causes are:
   Oracle Home dir. path does not exist in Central Inventory
   Oracle Home is a symbolic link
   Oracle Home inventory is corrupted
LsInventorySession failed: OracleHomeInventory gets null oracleHomeInfo
OPatch failed with error code 73

Solution:

+ASM2 > /aps/oracle/product/11.2.0.3/grid/oui/bin/runInstaller -attachHome -noClusterEnabled ORACLE_HOME=/aps/oracle/product/11.2.0.3/grid ORACLE_HOME_NAME=Ora11g_gridinfrahome1 CLUSTER_NODES=glscind01,glscind02 "INVENTORY_LOCATION=/aps/oracle/oraInventory" -invPtrLoc "/aps/oracle/product/11.2.0.3/grid/oraInst.loc" LOCAL_NODE=glscind02   
Starting Oracle Universal Installer...
   
    Checking swap space: must be greater than 500 MB.   Actual 7844 MB    Passed
    The inventory pointer is located at /aps/oracle/product/11.2.0.3/grid/oraInst.loc
    The inventory is located at /apps/oracle/oraInventory
    'AttachHome' was successful.

Frequency v.s Heigh Balanced Histogram

Frequency
·         Each bucket has its own size (counts of rows with that value)
·         NDV <= Buckets request <=254
·         One distinct value per bucket
·         Bucket_size = rows with “that” particular value
  
Height Balanced
·         Bucket size = (num_rows – num_nulls) / num_buckets
·         Values are sorted before splitting them into buckets
·         One or more distinct values per bucket
·         Only values of end-points are stored in histogram
·         Bucket_size = (Orig_CarD – Nnulls) / Buckets_total

dbms_stats

SQL> select dbms_stats.get_stats_history_retention from dual;

GET_STATS_HISTORY_RETENTION
---------------------------
                         31 => this is the default value

If you like to change it to 45 days, then use the ALTER_STATS_HISTORY_RETENTION procedure

SQL> exec dbms_stats.alter_stats_history_retention(45);
PL/SQL procedure successfully completed.

SQL> select dbms_stats.get_stats_history_availability from dual; => this query will return the date statistics have been purged up to. 

GET_STATS_HISTORY_AVAILABILITY
---------------------------------------------------------------------------
18-APR-13 07.20.37.099029000 PM -05:00

SQL> select table_name, stats_update_time from dba_tab_stats_history where owner = ‘GLS’;  è this query shows the time when  given tables’ statistics were re-gathered
  
TABLE_NAME                     STATS_UPDATE_TIME
------------------------------ ---------------------------------------
GLS_CONTACT_NEW                 19-MAY-13 09.56.39.845243 PM -05:00
GLS_CONTACT_NEW                 06-MAY-13 05.22.14.338999 PM -05:00

To restore table statistics:   For example, for GLS_CONTACT_NEW table, the statistics on May 19 is bad but May 6th is good, so you like to restore it to May 6th.

SQL> execute dbms_stats.restore_table_stats('GLS','GLS_CONTACT_NEW','06-MAY-13 05.22.14.338999 PM -05:00');

PL/SQL procedure successfully completed.

To compare statistics for a table from two timestamps or date in the past

select * from table(dbms_stats.diff_table_stats_in_history
(ownname => upper('&ownname'),
tabname => upper('&tabname'),
time1 => systimestamp,
time2 => to_timestamp('&time2','mm/dd/yyyy'),
pctthreshold => 0))

Whenever it is necessary, statistics can be restored from the history.  The dbms_stats provides:

Execute dbms_stats.restore_table_stats(‘owner’, ‘table’, date)
Execute dbms_stats.restore_database_stats(date)
Execute dbms_stats.restore_dictionary_stats(date)
Execute dbms_stats.restore_fixed_objects_stats(date)
Execute dbms_stats.restore_schemas_stats(‘owner’,date)
Execute dbms_stats.restore_system_stats(date)

To set table statistics, you can use dbms_stats.set_table_stats

SQL> exec dbms_stats.set_table_stats(ownname=>'GLS', tabname=>'TEST_ISSUE', numrows=>140);
PL/SQL procedure successfully completed.
SQL> exec dbms_stats.set_table_stats(ownname=>'GLS', tabname=>'TEST_ISSUE',numblks=>10);
PL/SQL procedure successfully completed.

To set index statistics, you can use dbms_stats.set_index_stats to set number rows in index, number of leaf blocks, distinct keys, clustering factor, heigh of index 

exec dbms_stats.set_index_stats (ownname=>'GLS',tabname=>'PROD_NEW',numdist=>1000);

DBMS_SQLTUNE package to Run the Sql Tuning Advisor (ID 262687.1)

Check out the SQL TUNING document is from metalink (ID 262687.1).  It’s very handy when you need to get some advices to tune a poor SQL query using dbms_sqltune package. 

DECLARE
  my_task_name VARCHAR2(30);
  my_sqltext CLOB;
BEGIN
  my_sqltext := 'SELECT * '   ||
                'FROM sales ' || 'WHERE prod_id = 10 AND ' || 'cust_id = 100 ';

  my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
                           sql_text => my_sqltext,
                           user_name => 'SH',
                           scope => 'COMPREHENSIVE',
                           time_limit => 60,
                           task_name => ‘gls_sql_tuning_task’,
                           description => 'Task to tune a query on a specified PRODUCT');
END;

Execute the tuning task.:
Execute dbms_sqltune.Execute_tuning_task (task_name => ‘gls_sql_tuning_task’);

Check the status of the task using following query:
 select status from dba_advisor_log where task_name=‘gls_sql_tuning_task’;

View the Recommendations
set long 65536
set longchunksize 65536
set linesize 100
select dbms_sqltune.report_tuning_task(‘gls_sql_tuning_task’) from dual;

The report can suggest to add index, or gather statistics, or SQL profile.  In my case, the sql_profile was recommended and to accept it, the performance was improved 99.9%

execute dbms_sqltune.accept_sql_profile(task_name =>‘gls_sql_tuning_task’, task_owner => 'SYSTEM', replace => TRUE);


12c Database cheat sheet

This sheet is work in progress.  Please come back for the update...

select view_name from dab_views where view_name like 'CDB%'
select name, pdb from cdb_services;
show con_name
alter pluggable database all open;
startup nomount
select name, open_mode from v$pdbs;
alter database mount; --> select name, open_mode from v$pdbs; all mount
alter database open; -->PDBs$SEED mount mode
alter pluggable database all open:  all pluggable databases in read/write 

select name, pdb from cdb_services;
connect sys/oracle@pdb1 as sysdba
show con_name
show parameter ddl_lock_timeout
There is a single SPFILE per CDB to store prameters. 
SQL> connect sys/oracle@pdb1 as sysdba
Connected.
Instance PDB changes example:
SQL> show parameter ddl_lock_timeout

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
ddl_lock_timeout             integer     0
SQL> alter system set ddl_lock_timeout=10;
System altered.

SQL> show parameter timeout

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
ddl_lock_timeout             integer     10
SQL> alter system set sessions=150;
System altered.
select name, value, ispdb_modifiable, con_id from v$system_parameter where ispdb_modifiable='TRUE' ==> there are 174 parameters
select p.con_id, p.name, p.dbid, s.name, s.value, s.ispdb_modifiable
from v$system_parameter s, v$pdbs p
where s.con_id = p.con_id and
s.name = 'sessions';
CREATE Permanent tablespaces in a CDB
SQL> create tablespace cdb_tools datafile '/u01/app/oracle/oradata/cdb1/cdb_tools01.dbf' size 10m;                                 
Tablespace created.
SQL> show con_name
CON_NAME
------------------------------
PDB2
SQL> create tablespace pdb2_tools datafile '/u01/app/oracle/oradata/cdb1/pdb2/pdb2_tools01.dbf' size 5m;
Tablespace created.
Create user in Container ==> has to be inside the container DB
SQL> create user C##_MYID_ALL identified by ali container=ALL;
User created.
Create user in PDB ==> from PDB
SQL> create user MYID_DBA identified by ali container=CURRENT;
User created.

Create Tablespaces CDB and PDB

Prior version of Oracle, all the tablespaces belong to one database. In the CDB, however, there is one set of tablespaces belong to the root container and each PDB has its own set of tablespaces. All common objects are created in the root container's tablespace and is visible in the PDBs through links.

There is only one active UNDO tablespace per CDB, and it's common to all PDBs.

Create a tablespace in a root CDB

SQL> create tablespace cdb_tools datafile '/u01/app/oracle/oradata/cdb1/cdb_tools01.dbf' size 10m;

Tablespace created.

Create a permanent tablespace in a PDB

SQL> show con_name

CON_NAME
------------------------------
PDB2
SQL> create tablespace pdb2_tools datafile '/u01/app/oracle/oradata/cdb1/pdb2/pdb2_tools01.dbf' size 5m;

Tablespace created.

Managing CDB and PDB Databases

When you startup a CDB, the sequence of operations performed as following:

Instance is started -->Control files are opened --> The root container is opened redo logs and root data files -->The seed pluggable database in READ ONLY mode-->PDBs are stilled in MOUNTED mode--> Triggers can fire to open other PDBs

SQL> alter database cdb1 open;
SQL> alter pluggable database all close;
SQL> alter pluggable database all open;
SQL> alter pluggable database all close;
SQL > alter pluggable database all except GLS close;
SQL> alter pluggable database all open read only;
SQL> select name, open_mode from v$pdbs;

NAME       OPEN_MODE
------------------------------ ----------
PDB$SEED       READ ONLY
PDB1       READ ONLY
PDB2       READ ONLY
GLS       READ ONLY

SQL> alter pluggable database gls close;
SQL> alter pluggable database gls open;
SQL> select * from cdb_pdbs;
SQL > select * from cdb_tablespaces;
SQL> select * from cdb_data_files;
select name, pdb from cdb_services
SQL> select name, open_mode from v$pdbs;

NAME        OPEN_MODE
------------------------------ ----------
PDB$SEED        MOUNTED
PDB1        MOUNTED
PDB2        MOUNTED
GLS        MOUNTED

SQL > select name, pdb, network_name from cdb_pdb;

SQL> connect sys/oracle123@pdb1 as sysdba
Connected.
SQL > show con_name

To be continued...





Container and Pluggable Databases

Pluggable Database is the new feature and allows the DBA to consolidate larget number of small database applications departmental applications into a single larger RDBMS installation.  It's a set of database schemas that appears logically to users and applications as a separate database.  The Oracle Metadata and user data are totally separated into two sections.  One is Container DB (CDB) stores metadata and One is Pluggable DB(PDB) which stores user data.  This will reduce significant percentage of hardware deployment, patch and upgrade, instance and storage overhead and DBA time.

With Oracle 11g, there are non container databases and share nothing.  As a result, there are too many background processes with high shared memory and many copies of Oracle metadata.  When you need to upgrade/patch the database applications, it's time consuming as you have to upgrade each database.

Benefits of Pluggable Databases (PDBs):
Multiple databases in a centrally managed platform
Easy and Fast provisioning, patching and upgrading time savings
Central Management and administration of databases (backups, restore, disaster recovery, patching/upgrading)
Secure separation of duties (the administrator of an application can do all the required tasks, but cannot see other PDBs in the same Container Database(CDB)

From the Enterprise Manager
A Container Database (CDB) can be defined as target and a Pluggable database can be setup as a sub target of a CDB target.  After the creation of the Oracle database, only objects in the data dictionary ar the Oracle-supplied objects.

Create a new CDB either via DBCA or SQLPLUS:

  • Configure an instance with init.ora parameter file then STARTUP NOMOUNT.  Be sure to check (DB_NAME, CONTROL_FILES, DB_BLOCK_SIZE, _ENABLE_PLUGGABLE_DATABASE=TRUE
  • Create CBD using the CREATE DATABASE command with a new clause ENABLE PLUGGABLE DATABASE.  This will create the root container with the control files during the mount phase, the redo log files and root data files.  The root data files are used for the SYSTEM (metadata & dictionary) and SYSAUX (AWR).  It also create the seed pluggable database with its own data files used for SYSTEM and SYSAUX.  The FILE_NAME_CONVERT, like RMAN clone, to rename the data files of the seed pluggable database while copying from the root container to another location (see demo below)


SQL> connect / as sysdba
SQL > Startup nomount
SQL > Create database ORDER user sys identified by passcode user SYSTEM identified by passcode2 EXTENT MANAGEMENT LOCAL DEFAULT TEMPORARY TABLESPACE temp UNDO TABLESPACE UNDOTBS DEFAULT tablespace users ENABLE PLUGGABLE DATABASE

Create Pluggable database:

SQL> create pluggable database GLS admin user admin identified by admin file_name_convert= ('/pdbseed/','gls/');

Pluggable database created


SQL> alter pluggable database GLS open;

If you create the database with DBCA, then select the "Create As Container Database"

Enterprise Manager (EM) Cloud Control and Database Express

Enterprise Manager Database Control is not available in 12c database.  There are enhancement in Enterprise Manager Cloud Control Interface and Database Express Navigation.  The enterprise manager cloud control is composed of Four main components

  1. The Oracle Management Repository (OMR)
  2. The Oracle Management Service (OMS)
  3. The Oracle Management Agent (OMA or agent) with target specific plug-ins
  4. The Cloud Control Console

To start the whole enterprise manager cloud control frame work, follow the steps below:

  • Startup the repository database listener:  lnsrctl start
  • Startup the repository database:  $ORACLE_HOME/bin/sqlplus / as sysdba -> Startup
  • Start the OMS including OHS and WebLogic Managed Server:  emctl start oms
  • Start the AGENT on OMS repository host:  emctl start agent
  • Start the AGENT on the managed/target servers:  emctl start agent

To stop the enterprise manager cloud control, perform the above steps (bottom to top)

Type of Credentials and Three levels of access 

Named Credentials:  You can store credential username/password, public key-private key pair.  It's used when performing operation like system management tasks (running jobs, patching, changing password, etc)

Preferred Credentials:  You can store access of managed targets login credentials in the Management Repository to simplify the access

Default Credentials:  You can set a particular target type and is available for all the targets of the target type.  

There are three level of access:  View access, Edit access (change the credentials, name/password), and Full access (complete access including the ability to delete the named credential)

Enterprise Manager Database Express:  It's a replacement of EM Database Control and is created via DBCA with XMLDB components installed.  The homepage represents an overall view of the database instance status and activity.  The EM Database Express is built on the Common Reporting Framework in the database and is available when the database is opened.