Saturday 2 February 2019

Near Zero down time for relocating a PDB from one CDB to another CDB - a 12.2 new feature

This new feature significantly reduces downtime by leveraging the clone functionality to relocate a pluggable database (PDB) from one multitenant container database (CDB) to another CDB. The source PDB is still open and fully functional while the actual cloning operation is taking place. The application outage is reduced to a very small window while the source PDB is quiesced and the destination PDB is brought online after applying the incremental redo. The source PDB is subsequently dropped. 

With this feature, you can now adjust to changing workloads and comply with Service Level Agreement (SLA) requirements in near real time.




In Oracle Database 12.1, unplugging and plugging a PDB requires several steps such as unplugging the PDB from the source CDB, copying the database files to a new location, creating the new PDB by plugging the source PDB at the target CDB, and finally dropping the PDB from the source CDB.
A single DDL statement can relocate a PDB, using the “pull” mode, connected to the CDB where the PDB will be relocated to pull it from the CDB where the PDB exists, managing draining existing connections and migrating new connections without requiring any changes to the application.
There are two relocation methods:


 • Normal availability mode
  • −  When the newly created PDB is opened in read-write mode for the first time, the source PDB is automatically closed and dropped, and the relocation operation is completed with the relocated PDB being fully available. This is the “normal availability” default mode.
  • −  This method can be used to relocate application PDBs too.


  • Maximum availability mode
    • −  The maximum availability mode reduces application impact by handling the migration of connections, preserving the source CDB in mount state to guarantee connection forwarding of the listener to the remote listener where the PDB is relocated. In this case, you cannot create a PDB with the same name as the source PDB because it will conflict with the listener forwarding. It is expected that connect strings are updated at a time that is convenient for the application. After this is done and all the clients connect to the new host without forwarding, the DBA can drop the source PDB.
    • −  If AVAILABILITY MAX is specified during the CREATE PLUGGABLE DATABASE RELOCATE command, additional handling is performed to ensure smooth migration of workload and persistent connection forwarding from the source to the target. The PDB is always first opened in read-only mode. This makes the PDB available as a target for new connections before the source PDB is closed. During this operation, listener information of the target CDB is automatically sent to the source and a special forwarding registration is performed with the source PDB’s current listener. New connections to the existing listener are automatically forwarded to connect to the new target. This forwarding persists even after the relocation operation has been completed, and effectively allows for no changes to connect strings.
    • −  It is still recommended that connect strings are updated eventually at a time that is convenient for the application, but availability is not dependent on when this action is performed.
      PDB relocation requires enabling the local UNDO mode and ARCHIVELOG mode in both CDBs.

Generic Python DB Module to connect Oracle Database



Please refer my post [ http://jeyaseelan-m.blogspot.com/2018/11/how-to-connect-oracle-database-using.html ] for basic setup or python to oracle connection




import sys,os,datetime,cx_Oracle,subprocess,traceback,logging
from pprint import pprint
# Global Variables declarations
global CONFIG_FILE
CONFIG_FILE=".BLACKOUT_CONFIG"
CONFIG_TEMPLATE = { 'SOURCE_DIR' : 'SOURCE_DIR', 'USERID' : 'USERID', 'PASSWORD' : 'PASSWORD', 'TNS_NAME' : 'TNS_NAME' }
# Print messages
def printError(module,message):
    logging.error("Error at Module - {}: {} " .format(module,message))
    sys.exit(1)

def printWarning(module,message):
    print("Wanning at Module - {}: {} " .format(module,message))



# Get config values
def getConfig():
    global configDict
    configDict = {}
    if os.path.exists(CONFIG_FILE):
       with open(CONFIG_FILE) as config_file:
            for row in config_file:
                key,value = row.split(":")
                configDict[key]=value.strip()
    else:
       printError("getConfig","{} doesnot exist".format(CONFIG_FILE))
    CONFIG_TEMPLATE_set=set(CONFIG_TEMPLATE)
    config_set         =set(configDict)
    if CONFIG_TEMPLATE_set ^ config_set :
       printError("getConfig"," {} parameter is missing in the {} confgile file ".format(CONFIG_TEMPLATE_set ^ config_set,CONFIG_FILE) )




# Get DB details

def getDBconfig():
    global cmdb_dBuser ,cmdb_dBpass,cmdb_dBname,cmdb_dBconection
    cmdb_dBuser=configDict["USERID"]
    cmdb_dBpass=configDict["PASSWORD"]
    cmdb_dBconection=configDict["TNS_NAME"]


# Connect Database
def connectDB():
    global cmdb_dBconection,cmdb_dBcursor
    try:
        cmdb_dBconection = cx_Oracle.connect(cmdb_dBuser,cmdb_dBpass,cmdb_dBconection)
        cmdb_dBcursor=cmdb_dBconection.cursor()
    except  cx_Oracle.DatabaseError as e:
        error, = e.args
        printError(connectDB,error.message)



# run query  
def runQuery(sql):
    cmdb_dBcursor.execute(sql, REFERENCE_NUMBER=str(sys.argv[1]) )
    result=cmdb_dBcursor.fetchall ()
    for row in result:
        print ( " Task Number              : {0} ". format(row[0]))
        print ( " Assigned To              : {0} ". format(row[1]))
        print ( " Assigment Group          : {0} ". format(row[2]))
        print ( " Change Number            : {0} ". format(row[3]))
        print ( " Task State               : {0} ". format(row[4]))
        print ( " Planned Start            : {0} ". format(row[5]))
        print ( " Planned End              : {0} ". format(row[6]))
        print ( " Task details             : {0} ". format(row[11]))





 


 

ZFS

Public Cloud tools comparison