Wednesday, 23 November 2016

More About Plugable Database / Multitenant Architecture in Oracle 12c ....

Multitenant Architecture / Plugable Database Concepts:-
Author: Deepak Mishra

Over a period of time oracle have given us various New Features in every Release they do. Here comes an another Release of Oracle Database and with over 500 new features of which widely acknowledged one is Oracle Plugable Database conceptually a Multitenant Architecture.

In earlier releases of Oracle , database term was widely used in conjunction with Single instance Database or a RAC Database but starting with Oracle 12c a new feature called plugable Database is introduced.

In simple words to start with i can name it a multiple databases plugged within one parent database.

While we take a deep drive in understanding what Oracle 12c Plugable Database feature and Multitenant Architecture is , i would like to start with understanding the same with a pictorial presentation:-




The overview architecture show above is termed as Multitenant Architecture. I will elobrate the Multitenant architecture in greater details in upcoming sections. First lets understand the concept and advantages of having such architecture.

Concept


What is Multitenant Architecture?

Many times there has been a requirement to have multiple instances on same node for different purpose/requirement, or may be on on different hosts due to less available resources or application requirement. Having multiple instances requires memory, different processes, Backup Management etc for each instance on the same node or different and may also impact the performance during peak period due to unavailability of required resources.

The choice was very simple either increase the resources or move the database to less busier server.

Looking at various aspects mentioned above, introducing sometime where i can manage multiple databases from within one instance and can share the available resources (better Resource utilization) including flexible backup and recovery management option led to introduction of Multitenant Database.

Another major advantage is having a single point of administration.

Here the Oracle Database which is built on Multitenant foundation is called Container Database(CDB), and each container(Tenant) residing inside is called Plugable Database (PDB). Please refer to above diagram for more information.

As said One of the main reasons for Multitenant Architecture to be in place is "Database Consolidation". Consolidation of database on to a Single powerful server and a Single Oracle Instance, we achieve following benefits:

Cost reduction in terms of Product licensing and Hardware procurement as we require less number of processors and less memory compare to a Non-CDB environments.
Easier Database maintenance, Plugable Databases can easily be moved or copied locally or remotely across Physical machines in the network, Upgrading Operating System, Upgrading or Patching Database itself is a lot easier and "often" a one shot process, that greatly improves the availability.

Performance tuning becomes a lot easier as all PDBs in a CDB environment share same Hardware/Platform/Network resources like CPUs/Memory/OS/Bandwidth (i/o and network),etc..

For instance:- It is easy to tune and manage resources on single server then tuning different databases on different servers with different analysis and resource management. This consumes lot of efforts and require time. For Huge or Mid Sized organizations now a days "TIME is MONEY" and they really dont compromise on good H/w with best of the resources.

Since now we have understood the details of Multitenant Database, lets get bit more technical to understand the installation, implementation, administration and Security.

Details:

When you install Oracle Database 12C, you get a choice to create a NON-CDB database or Create a Container database. Lets assume we opt for creating a container database which will have all the metadata information and will also host the SYSTEM,SYSAUX and any other default tablespaces.

Later you get a option to create a plugable database while creating a container database or you can do it later by invoking dbca or using command line. With every new Plugable database, the SYSTEM and SYSAUX tablespaces will be created, and other tablespace to store user’s data and metadata inside the Plugable database. The SGA memory area and background processes are shared between all the new plugable databases. Each of the Container database can support roughly up to 250 pluggable databases. Each pluggable database in turn will used as a service name to get connected by any application.

Thursday, 17 November 2016

Oracle 12c Release 2 New Features-Part 3

In my previous post Part-2 i only highlighted the most useful features but in this post i will target all other new features which brings in significant difference to this release.

1. Architecture

1.1 Read/Write and Read-Only Instances

Starting with Oracle 12.2.0.1 , a new initialization parameter has been introduced which can open the database in Read Only Mode. In past only standby databases were capable of doing so but with 12cR2 DBA can set the INSTANCE_MODE initialization parameter to READ_ONLY, Default being READ_WRITE.

1.2 Process Monitor Process (PMON) Group

The PMON group includes PMON, Cleanup Main Process (CLMN), and Cleanup Helper Processes (CLnn). These processes are responsible for the monitoring and cleanup of other processes.
  

2. Maximizing Availability

2.1 Restore Point :

Restore points can now be created in PDB's called PDB Restore Points. These restore points are specific to PDB's.

2.2 Flashback Database

As like Restore point PDB's , now a DBA can rewind the database at PDB level to previous point in time without impacting CDB or other PDB's.

2.3 Sparse Backups

This is a most interesting feature to support Oracle Clone DB also know as Snapshot databases and compete Delphix Technology. Oracle has played smart by adding this feature called Sparse Backups.
You must be wondering what's Sparse Backup , its nothing but taking level 1 backup on Clone/Snapshot DB i.e. backing up only changed data.
To know more about Clone DB which works on copy on write technology read Oracle Documentation. There is also a whitepaper which gives more insights about the same.
Unlike the base database, sparse databases are read-write databases.
RMAN restores sparse data files from sparse backups and then recovers them from archive and redo logs. You can perform a complete or a point-in-time recovery on sparse data files.
  

2.4 Oracle 12c GoldenGate Database Enhancement 

In Oracle 12cR2 Oracle have added significant enhancement to GG that enhances its replication capabilities. Couple of them i liked the most are:
- A new view GG_LAG is introduced to view end to end Lag information.
- Automated remote trail file recovery by pump automatically handles when a target system is restored to a previous point in time. This feature also handles most cases where target trail files are deleted or corrupted by automatically regenerating the missing target trail data when the source trail data is available, and by intelligently skipping any duplicate transactions when applying the change data.
For more information please go through Oracle Documentation:

3. Oracle SQL Enhancement

3.1 Join Groups

Join Group is an object that specifies frequently joined columns from the same table or different tables. Such columns typically contain values of compatible data types that fall in similar ranges. When you create a join group it gets created in Oracle In-Memory Column Store which contains special metadata for the columns, which enables the database to optimize join queries for the columns. 
Syntax:
CREATE INMEMORY JOIN GROUP Emp_Grp (EMP(dept_id), Dept(dept_id));

4. Other New Features

- There has been introduction to In-Memory column store for Standby Databases.
- DBA's Can now generate AWR reports at PDB Level.
- In SQL Language , Developer can write Query to convert Structure Data into Json format.
- PDB Lockdown Profiles are another good introductions.
- Using In-Memory Column Store with ADO.
- Application Containers, If you have a real use case these Application containers will come real handy when designing the application with multiple depended PDB's accessing common objects.

Summary 

This was my last installment to Oracle 12c Release 2 New Feature Topic. I leave rest of the features for you to go through and get more insights on..
In my upcoming blogs i will start Blogging about practical use and use cases of these new features.

Monday, 14 November 2016

Oracle 12c Release 2 New Features - Part 2

                As promised, this is my second instalment of Oracle 12cR2 i.e. 12.2.0.1 Release. In Part 1, i have recapped few of the 12c R1 Features along to some highlights on what was coming. Part 3 will contain other useful new features and will also be my last instalment to New Features Blogging.

In this Part i will try to highlight most of the 12cR2 features which i found to be most awaited ones for DBA's .

I will divide this post in sections like Admin, Backup/Recovery, Performance/Tuning, Grid, RAC, and Network...

The post is not intended to collate all the new features, If you want to read about all of that which have changed in this release probably you might want to read the New Features Guide:



Section 1 : SQL

1. Sqlplus Command Line:

1.1 History :


Starting this release you can set the History environment variable to on and get this history of last 100 executed queries by default.

SQL> set history on
SQL> set history 100
SQL> show history
History is ON and set to "100"
SQL> history
1  show history
2  show user
3  desc dual
* 4  select * from dual;
SQL> set history off
SQL> set history off

2. Globalization Support:

With the new Oracle Database 12c Release 2 (12.2) ability to declare collations for columns, you can declare a column to always be compared in a case-insensitive way. Oracle Database supports case-insensitive collations, such as BINARY_CI or GENERIC_M_CI.

This feature can help developers declare data as case-insensitive and do not have to add explicit uppercasing operations to SQL statements or create function based indexes.

 Example:

At table level you can define collation like :-

CREATE TABLE emp
(
  empno   VARCHAR2(5) PRIMARY KEY,
  ename    VARCHAR2(50),
 )
DEFAULT COLLATION BINARY_CI ;

Or at column level you can modify it like :
ALTER TABLE emp ADD gender VARCHAR2(1) COLLATE BINARY_CI;

For other columns the collation is inherited from the table. Also another important point to remember is the default collation of the table can be changed anytime.

Section 2 : Administration And Availability

2.1 Sharding:

Sharding is a data tier architecture in which data is horizontally partitioned across independent databases. Each database in a shard is hosted on a dedicated server with its own local resources like memory/cpu/disk and flash and bring them in a one virtual pool makes up a single virtual database or Sharded Database.

Following is an illustration of how a table will look in a Sharded database architecture.


I will add more specific contents to each topic here in upcoming blogs when I am done with my test cases on the same. I am in process of evaluating the same and will come up with best practises and other advantages and disadvantages as well...

Interestingly I would also like to evaluate this technology against other No-Sql databases which uses Sharding.

2.2 Quarantined Objects:

 Object quarantine enables an Oracle database to function even when there are corrupted, unrecoverable objects. The V$QUARANTINE view contains information about quarantined objects.

Object quarantine isolates an object that has raised an error and monitors the object for impacts on the system.

Example: This query shows the resources that are currently quarantined.
 

COLUMN OBJECT FORMAT A10
COLUMN ADDRESS FORMAT A10
COLUMN BYTES FORMAT 999999999
COLUMN ERROR FORMAT A20
COLUMN TIMESTAMP FORMAT A20
SELECT OBJECT, ADDRESS, BYTES, ERROR, TIMESTAMP FROM V$QUARANTINE;
OBJECT   ADDRESS   BYTES ERROR               TIMESTAMP
---------- ---------- ---------- --------------------------------
session 0000000078 9528  ORA-00600: internal 11-Nov-16 01.17.42.2

The above columns contains below information:
 
Object       : The name of the resource is “session.”
Address     : The start address of the memory region being quarantined is 0000000078.
Bytes         : The resource is using 9528 bytes of memory in quarantine.
Error          : The message of the error that caused the resource to be placed in quarantine is “ORA-00600 internal error code.”
Timestamp : The timestamp shows the date and time of the error.


2.3 Partitioning Enhancements

 

2.3.1 New alter table to partitioned table

In 12.2 there is a single “alter table .. modify ..” command to transform a regular table into a partitioned one. The “alter table” includes the partition type and key clauses to alters the table. 

The conversion of table can be done in online and offline mode. Below example represents Online operation to convert a non-partition table to partition one.

Example:
ALTER TABLE emp MODIFY
  PARTITION BY RANGE (emp_no) INTERVAL (80)
  ( PARTITION Part1 VALUES LESS THAN (100),
    PARTITION Part2 VALUES LESS THAN (500)
   ) ONLINE
  UPDATE INDEXES
( IDX1_SAL LOCAL,
   IDX2_EMP_NO GLOBAL PARTITION BY RANGE (emp_no)
  ( PARTITION allothers VALUES LESS THAN (MAXVALUE))
);


2.3.2 New Automatic List Partitioning

Automatic List partitioning is a nice feature which enable creation of on demand list partition on frequently modified table.
Example:
CREATE TABLE emp_List_auto
(
   emp_id     NUMBER(5),
   emp_name   VARCHAR2(30),
   dept_name  VARCHAR2(20),
)
PARTITION BY LIST (dept_name) AUTOMATIC
(PARTITION P_D_Name VALUES ('IT')
);

2.4 In-Memory option

2.4.1 Standby Database

Oracle 12c introduced the in-memory option in release 1 , however the same was not available in active standby. In Release 2 Active Standby's can be configured to use in-memory, allowing us to configure in-memory column store for reports and analytic.

2.4.2 In-Memory – Dynamic Resizing

In 12c Release 1 In-Memory Column store was static and incase the same was required to change , database restart was required. In 12.2 we can increase the In-Memory column store size dynamically but the same can't be reduced dynamically.

 

2.5 Dictionary with long identifiers

It was so annoying that object and column names were limited to 30 bytes which might was not be a major concern for all time Oracle Developers/DBA's but for Companies / DBA's involved in Migration projects to migrate the SQL-Server/Sybase databases to Oracle had challenges with this Limit but not anymore, 128 bytes is the new limit!.

2.6 PDB Characterset

With 12c R2 we can set a different characterset per PDB with a Pre-Requisite for the root container to use AL32UTF8 which is the super-set of all others characterset and is also default characterset with 12cR2 release onwards.

Section 3. Flashback Pluggable Database

In Database 12.2, flashback can be done on the PDB level with an prerequisite of database been put into local undo mode which also means that each PDB has its own undo tablespace.
Example:
Altering the database to enable local undo, require instance shutdown-startup.
SQL> alter database local undo on;

Database altered.
SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

SQL> alter pluggable database pdb1 close immediate;

Pluggable database altered.

SQL> flashback pluggable database pdb1 to timestamp systimestamp - interval '20' minute;

Flashback complete.

SQL> alter pluggable database pdb1 open resetlogs;

Pluggable database altered.

Section 4: Networking


 Database Resident Connection Pooling:


Like Shared Server and Dedicated Server Architecture, DRCP is yet another connection management framework which enables less utilization of resources and giving performance benefits. Majorly for applications which use connection pooling.

When the first request is received from a client, the Connection Broker picks an available pooled server and hands off the client connection to the pooled server. If no pooled servers are available,

the Connection Broker creates one. If the pool has reached its maximum size, the client request is placed on the wait queue until a pooled server is available. Releasing database resources involves releasing the pooled server to the pool.

For instance, when a client requires database access, the connection broker picks up a server process from the pool and hands it off to the client. The client is directly connected to the server process until the request is served. After the server has finished, the server process is released into the pool. The connection from the client is restored to the broker. Session memory is allocated from the PGA.



 Section 5 : Analytics


Analytic Views

Oracle describes Analytic views to provide a fast and efficient way to create analytic queries of data stored in existing database tables and views. The diagram depicts the pictorial representation of Analytic view.
The model is made up of three objects.
  • Dimension Attribute - Defines a dimension along with the hierarchical levels also multiple hierarchies are possible.
  • Hierarchy - Defines the hierarchical structure of a dimension with parent/child.
  • Analytic View - Brings together the hierarchies and defines the measures. 


Section 6 : Security

 

Internal tablespace encryption


Now it is possible to encrypt internal tablespace i.e. system, sysaux, undo as well.


Section 7 : Performance and Tuning


6.1 SQL Tuning

6.1.1 New Initialization Parameters to controls for adaptive plans and adaptive statistics


The OPTIMIZER_ADAPTIVE_PLANS initialization parameter enables (default) or disables adaptive plans. The OPTIMIZER_ADAPTIVE_STATISTICS initialization parameter enables or disables (default) adaptive statistics.

 

6.1.2 Cursor-Duration Temporary Tables

Complex queries sometimes process the same query block multiple times. To avoid this scenario, Oracle Database can create temporary tables for the query results and store them in memory for the duration of the cursor called Cursor Duration Temp Tables. For complex operations this optimization enhances the materialization of intermediate results from repetitively used subqueries which  improve performance and optimize I/O.

When the database uses cursor-duration temporary tables, the keyword CURSOR DURATION MEMORY appears in the execution plan.

For More information refer to Oracle Documentation:-

6.1.3 Expression tracking

SQL statements commonly include expressions such as (+) or (-) in the query including internal or user defined functions. The Expression Statistics Store (ESS) maintains usage information about expressions identified during compilation and captured during execution.
 

6.1.4 Creating a Database Operation


Using this feature enables DBA or privileged user to monitor a session and find details about the operation going on.

Creating a database operation involves supplying a name and defining its beginning and end times.

Start a database operation by using the DBMS_SQL_MONITOR.BEGIN_OPERATION function, and end it by using the DBMS_SQL_MONITOR.END_OPERATION procedure.

To begin the operation in a different session, specify the combination of SID and SERIAL#.

Example:

COL DBOP_NAME FORMAT a10
COL STATUS FORMAT a10
COL ID FORMAT 999

SELECT DBOP_NAME, DBOP_EXEC_ID AS ID, STATUS, CPU_TIME, BUFFER_GETS
FROM   V$SQL_MONITOR WHERE DBOP_NAME IS NOT NULL ORDER BY DBOP_EXEC_ID;
DBOP_NAME  ID  STATUS    CPU_TIME GETS
---------- -- ---------- -------- ----
sh_count    1  EXECUTING    24997   65

 

Summary

I have tried to jotted down the new Oracle 12.2 Features. Hope you find this article useful. I am still in process of going through documentation and will soon start testing the same. There are still a lot of other features like SQL, Hot Cloning, Rman, Performance Tuning and Security which can be useful in day to day DBA/ Development. I will come up with detailed discussions on few of the important features in my next Blog.