Sustaining Planned/Unplanned Database Outages: Best Practices for DBAs & Developers

Similar documents
Design and Deploy Tomcat Applications for Planned, Unplanned Database Downtimes and Runtime Load Balancing with UCP

Oracle Client HA Configuration with Oracle

Multitenancy and Continuous Availability for Java Applications Oracle Database 18

Application High Availability with Oracle

Pieter Van Puymbroeck - Laurent Léturgez 1

Zero Downtime: Hiding Planned Maintenance and Unplanned Outages from Applications

Continuous Availability

Application Continuity with Oracle Database12c Release 2 O R A C L E W H I T E P A P E R M A R C H

Putting Oracle Database 11g to Work for Java. Kuassi Mensah Group Product Manager, Java Platform Group db360.blogspot.com

Optimize Java Persistence, Scale and Failover Connections with JDBC and UCP

Best Practices for Speeding and Scaling Java Applications Oracle Database 18

Oracle Database 12c 12c és 18c Data Guard újdonságok, Application Continuity tapasztalatok és demó. Papp Balázs - Webváltó

Java Best Practices for Developing and Deploying Against Databases in the Cloud

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

Application Continuity

Application Continuity

NCOUG 2018 Transparent High Availability for Your ApplicaIons

Oracle Universal Connection Pool Developer's Guide. 12c Release 2 (12.2)

What every DBA needs to know about JDBC connection pools * Bridging the language barrier between DBA and Middleware Administrators

What every DBA needs to know about JDBC connection pools Bridging the language barrier between DBA and Middleware Administrators

WebLogic Active GridLink: Intelligent integration between WebLogic Server and Oracle Database Real Application Clusters

Oracle WebLogic Server Integration with Oracle Database 12c O R A C L E W H I T E P A P E R O C T O B E R

Configuring JDBC data-sources

Global Data Services (GDS)

Oracle Global Data Services (GDS)

An Oracle White Paper November Oracle RAC One Node 11g Release 2 User Guide

ZDLRA High Availability for Backup and Recovery

Oracle Database 10g Java Web

Oracle Database 11g: RAC Administration Release 2 NEW

Oracle Universal Connection Pool for JDBC

Oracle WebLogic Server 12c: Seamless Oracle Database Integration

HOL9515 Delivering Continuous Database Services with Oracle Real Application Clusters (Oracle RAC) 12c

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Configuring the Oracle Network Environment. Copyright 2009, Oracle. All rights reserved.

Maximum Availability Architecture. Oracle Best Practices for High Availability. Reducing Siebel Downtime with a Local Standby Database

<Insert Picture Here> Get the best out of Oracle Scheduler: Learn how you can leverage Scheduler for enterprise scheduling

Must know Database facts for WAS 6.1

1 P a g e Ensure HA in Database Cloud with Oracle Database 12c: What to Do and How to Do It.

Using Java - for PL/SQL and Database Developers Student Guide

FCUBS GridLink Datasource Configuration Oracle FLEXCUBE Universal Banking Release [May] [2018]

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Automatic Workload Management with Oracle Real Application Clusters 11g Release 2

SOA Cloud Service Automatic Service Migration

Oracle Database 12c: High Availability New Features

Oracle Universal Connection Pool for JDBC

Oracle Database 12c High Availability For Consolidation and Cloud Deployments

Net Services - Best Practices for Database Performance, Scalability and High-Availability

Mike Hughes Allstate Oracle Tech Lead, Oracle Performance DBA

Load Balancing and Failover with Oracle 10gR2 RAC

Oracle Global Data Services with Active Data Guard. Hands-On Lab

High Availability Infrastructure for Cloud Computing

Database Tables to Storage Bits: Data Protection Best Practices for Oracle Database

ORACLE DATA SHEET KEY FEATURES AND BENEFITS ORACLE WEBLOGIC SUITE

Oracle 12c Flex ASM & Flex Cluster

Maximum Availability Architecture

1Z Oracle. Oracle Real Application Clusters 11g Release 2 and Grid Infrastructure Administration

IBM Power Systems: a Better Choice than Oracle Hardware for Mission-Critical Oracle Databases

What s New with Oracle Database 12c on Windows: On-Premises and in the Cloud

Oracle Database 12c: RAC Administration Ed 1

Oracle Real Application Clusters One Node

12 Cool Features in Oracle RAC

How to Setup Application Server to Access DB2 z/os with High Availability

Oracle Database 12c: Clusterware & RAC Admin Accelerated Ed 1

2 Day + Real Application Clusters Guide 12c Release 1 (12.1)

An Insider s Guide to Oracle Autonomous Transaction Processing

BEAAquaLogic. Service Bus. Interoperability With EJB Transport

Security Benefits of Implementing Database Vault. -Arpita Ghatak

<Insert Picture Here> Scale your PHP Application to Tens of Thousands of Connections

Oracle Database 12c R2: RAC Administration Ed 2

CHAPTER 44. Java Stored Procedures

RAC Deep Dive for Developers. building efficient and scalable RAC-aware applications

Oracle Database 11g for Experienced 9i Database Administrators

Designing Database Solutions for Microsoft SQL Server (465)

Oracle WebLogic Server 12c: Administration I

Oracle Exam 1z0-144 Oracle Database 11g: Program with PL/SQL Version: 8.5 [ Total Questions: 103 ]

Oracle 11g Release 2 RAC & Grid Infrastructure Administration Course Overview

Perceptive Matching Engine

Oracle Database 12c: RAC Administration Ed 1 LVC

Oracle V Table Schema Sql Script

Maximum Availability Architecture

Console Guide. Version 4.4

Oracle Database: SQL and PL/SQL Fundamentals

Focus On: Oracle Database 11g Release 2

Enterprise Manager: Scalable Oracle Management

Database Level 200. Sanjay Narvekar November Copyright 2018, Oracle and/or its affiliates. All rights reserved.

Oracle Database 11g: SQL Fundamentals I

WLS Neue Optionen braucht das Land

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12

Oracle Database Global Data Services Concepts and Administration Guide. 12c Release 2 (12.2)

SQL: Transactions. Introduction to Databases CompSci 316 Fall 2017

Global Data Services Concepts and Administration Guide 12c Release 1 (12.1)

Survey of Oracle Database

Sample Database Table Schemas 11g Release 2 Pdf

Oracle Database 18c and Autonomous Database

WebLogic JMS Clustering. Jayesh Patel

What s New for.net Developers in Oracle Database

Configuring the module for advanced queue integration

Create A Private Database Link In Another Schema In Oracle 11g Drop >>>CLICK HERE<<<

To create a private database link, you must have the CREATE

A RESTful Java Framework for Asynchronous High-Speed Ingest

Transcription:

Sustaining Planned/Unplanned Database Outages: Best Practices for DBAs & Developers Kuassi Mensah Director, Product Management Oracle Database Development @kmensah db360.blogspot.com

Program Agenda 1 2 3 4 5 Maximum Availability planned/unplanned downtimes Building Blocks which Solved the Issues DBAs & Developers Steps for Planned Maintenance DBAs & Developers Steps for Unplanned Downtime Questions 4

Achieving Maximum Application Uptime Avoid this 5

Objectives for planned/unplanned downtimes Planned Maintenance Detect DOWN event triggered by DBA on instances targetted for maintenance Drain sessions away from that (those) instance(s) Perform transparent maintenance Resume operations on upgraded instance(s) Unplanned Downtime Detect DOWN event Reliable determination of the outcome of In-flight work Continuation of In-flight work Recovery with response time targets 6

Program Agenda 1 2 3 4 5 Maximum Availability with planned/unplanned downtimes Building Blocks which Solved the Issues DBAs & Developers Steps for Planned Maintenance DBAs & Developers Steps for Unplanned Downtime Questions 7

Building Blocks of High Availability (HA): Planned & Unplanned Universal Connection Pool (UCP) Fast Application Notification (FAN) Oracle Notification System (ONS) Fast Connection Failover (FCF) Transaction Guard (TG) Application Continuity (AC) Database request (unit of work) Logical Transaction ID (LTXID) Recoverable Errors Mutable Functions 8

Universal Connection Pool (UCP) Standalone jar (ucp.jar) and simple to configure in any application servers Designed to work with RAC, ADG, and GDS An Example PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource(); pds.setconnectionfactoryclassname( oracle.jdbc.pool.oracledatasource ); pds.seturl( jdbc:oracle:thin:@//localhost:1521/orcl ); pds.setuser( <user> ); pds.setpassword( <password> ); Connection conn= pds.getconnection(); 9

UCP Configuration in Tomcat Context.xml <Context docbase="ucptomcat" path="/ucptomcat reloadable="true" source="org.eclipse.jst.jee.server:ucptomcat"> <Resource name="tomcat/ucppool" auth="container factory="oracle.ucp.jdbc.pooldatasourceimpl" type="oracle.ucp.jdbc.pooldatasource description="ucp Pool in Tomcat connectionfactoryclassname="oracle.jdbc.pool.oracledatasource minpoolsize= 40" maxpoolsize="60" initialpoolsize= 50" autocommit= false user= <user>" password= <password>" url="jdbc:oracle:thin:@(description=(address=(host=racscan)(port=1521)(protocol=tcp))(connect _DATA=(SERVICE_NAME=orcl)))" /> </Context> 10

UCP Configuration in WebSphere WAS Admin Console 11

Fast Application Notification (FAN) Oracle FAN APIs provide event notification for developing more responsive applications to take advantage of Oracle Database HA features. Supported FAN events are mentioned below Up Relocates work when services resume Service Down Re-allocates sessions when services resume Node Down Re-allocates sessions when services resume RLB % - Hint to balance sessions locally/globally Affinity - Hint to maintain conversation locality 12

Oracle Notification Service (ONS) Simple publish/subscribe method to produce and deliver event messages for both local and remote consumption. ons.jar : Needs to be included in the classpath Database Side Configuration $ORACLE_HOME/opmn/conf/ons.config or $ORACLE_CONFIG_HOME/opmn/conf/ons.config.<hostid> # First three values are required localport=4100 remoteport=4200 nodes=racnode1:4200, racnode2:4200, racnode3:4200 $srvctl status nodeapps grep ONS Application Side Configuration <!-- Same string as ons.config; not needed in 12c Auto-ONS-- > onsconfiguration="nodes=racnode1:4200,racnode2:4200, racnode3:4200" 13

Fast Connection Failover (FCF) Application Failed DB Connections New DB Connections Instance1 Instance 2 FCF is a feature implemented using FAN APIs in the connection pool FCF is enabled in the application as follows. PoolDataSource pds = new PoolDataSourceFactory.getPoolDataSource(); // Not required with auto-ons in 12c pds.setonsconfiguration(ons_config); pds.setfastconnectionfailoverenabled(true); 14

Enabling FCF in Tomcat Context.xml <Context docbase="ucptomcat" path="/ucptomcat reloadable="true" source="org.eclipse.jst.jee.server:ucptomcat"> <Resource name="tomcat/ucppool" auth="container factory="oracle.ucp.jdbc.pooldatasourceimpl" type="oracle.ucp.jdbc.pooldatasource description="ucp Pool in Tomcat connectionfactoryclassname="oracle.jdbc.pool.oracledatasource minpoolsize= 40" maxpoolsize="60" initialpoolsize= 50" autocommit= false user= <user>" password= <password>" fastconnectionfailoverenabled="true" url="jdbc:oracle:thin:@(description=(address=(host=racscan)(port=1521)(protocol=tcp))( CONNECT_DATA=(SERVICE_NAME=orcl)))" /> </Context> 15

Recoverable Errors Oracle DB 12c error messages have a new OracleException.IsRecoverable property JDBC throws a SQLRecoverableException; your application checks connection validity using JDBC 4.0 isvalid() try { conn = pds.getconnection()...} catch (SQLRecoverableException rea) { if (!((ValidConnection)conn).isValid()) { ea.printstacktrace(); conn.close(); System.out.println( Retry to get a new connection + ea.getmessage()); } } 16

Database Request & Logical Transaction ID (LTXID) Database Request (Unit of Work) Demarcates a replay-able unit of work Connection conn = pooldatasource.getconnection(); // 3rd party conn pool must use beginrequest() PreparedStatement pstmt = SQL, PL/SQL, local calls, RPC conn.commit(); // 3rd conn pool must use endrequest() conn.close(); Request Ends Request Begins Logical Transaction ID (LTXID) Each transaction is associated with a LTXID issued at the beginning of the Tx LTXIDs are changed when a transaction is committed or rolled back 17

Transaction Guard At most Once COMMIT Execution 1. Application starts a TX; RDBMS associates LTXID(Logical Transaction ID) 2. Application performs a transaction (DML) & issues a COMMIT 3. COMMIT fails due to unplanned outage The RDBMS aborts the session and associated connection dies 4. UCP receives a FAN DOWN event and performs the following receives a recoverable SQL Exception gets the LTXID from the dead connection gets a new connection and checks the outcome of the COMMIT using the LTXID 18

Application Continuity (AC) 1- Normal Operation Marks database requests Builds proxy objects Decides what can & cannot be replayed Holds original calls with binds and validation 2 - Reconnect Checks Replay is enabled Creates a new session Validates target database Uses Transaction Guard to check outcome of in-flight COMMIT 3 - Replay Replays held calls If user visible results match, based on validations then application proceeds as if nothing happened 19

AC - Mutable Functions SYSDATE, SYSTIMESTAMP, SEQUENCES and SYS_GUID, and so on which results change on each invocation Replaying mutable functions will not give the same result as the initial call. (Web) Applications may or may not be sensitive to mutable functions during the resubmission of the same unit of work To keep the same values, the user schema must be granted the right to do so, by DBA 20

Program Agenda Maximum Availability with planned/unplanned downtimes Building Blocks which solved the Issues 3 DBAs & Developers Steps for Planned Maintenance DBAs & Developers Steps for Unplanned Downtime Questions 21

DBAs & Developers Steps for Planned Maintenance UCP at work 22

Planned Maintenance Development Steps Two Simple steps as shown below. (1) Enable Fast Connection Failover (FCF) as shown below. PoolDataSource pds = new PoolDataSourceFactory.getPoolDataSource(); pds.setonsconfiguration(ons_config); // not required with auto-ons in 12c pds.setfastconnectionfailoverenabled(true); Make sure to have ons.jar file in the classpath ONSConfiguration is required only in pre 12c database version (2) UCP introduces a new system property to gracefully drain the sessions -Doracle.ucp.PlannedDrainingPeriod=30 Smoothens the session draining Avoids logon storms on the active instance 23

Planned Maintenance DBA Steps Steps Stop the service without -force or Relocate the service Disable the service & Allow sessions to drain Eg.2-30mins Additional Details Wait to allow sessions to drain Wait for 10-30 minutes Check for long-running sessions. Terminate these (you may check again afterwards) $srvctl stop service db <db_name> -service <service_name> -instance <instance_name or $srvctl relocate service db <db_name> -service <service_name> - oldinst <oldins> -newinst <newinst> $srvctl disable service db <db_name> -service <service_name> - instance <instance_name> SQL> select count(*) from ( select 1 from v$session where service_name in upper('<service_name>') union all select 1 from v$transaction where status = 'ACTIVE' ) SQL> exec dbms_service.disconnect_session ('<service_name>', DBMS_SERVICE.POST_TRANSACTION); 24

Planned Maintenance DBA Steps-Contd Steps Repeat the steps above Additional Details Repeat for all services targeted for planned maintenance Stop the database instance $srvctl stop instance db <db_name> -instance <instance_name> - stopoption immediate Disable the instance $srvctl disable instance db <db_name> -instance <instance_name> Maintenance Enable & Start the instance Enable & start the service back Check if the service is up and running Apply patch or carry out the scheduled maintenance work $srvctl enable instance db <db_name> -instance <instance_name> $srvctl start instance db <db_name> -instance <instance_name> $srvctl enable service db <db_name> -service <service_name> - instance <instance_name> $srvctl start service db <db_name> -service <service_name> -instance <instance_name> 25

0:00 0:02 0:04 0:06 0:08 0:10 0:12 0:14 0:16 0:18 0:20 0:22 0:24 0:26 0:28 0:30 0:32 0:34 0:36 0:38 0:40 0:42 0:44 0:46 0:48 0:50 0:52 0:54 0:56 0:58 1:00 1:02 1:04 1:06 1:08 1:10 1:12 1:14 1:16 1:18 1:20 1:22 1:24 1:26 1:28 1:30 1:32 1:34 Number of Connections Planned Maintenance Graphical representation 120 Fig 1: Planned Downtime 100 RAC_Inst_1 RAC_Inst_2 80 60 40 20 0 Time (Mins) 26

Program Agenda Maximum Availability with planned/unplanned downtimes Building Blocks which solved the Issues DBAs & Developers Steps for Planned Maintenance 4 DBAs & Developers Steps for Unplanned Downtime Questions 27

DBAs & Developers Steps for Unplanned Downtime Application Continuity(AC) can fix this 28

Unplanned Downtime Application changes Few Simple steps as shown below; JDBC & UCP take care of the rest Building Blocks Enable Fast Connection Failover (FCF) Design for Application Continuity (AC) Design for Transaction Guard (TG) Description Mandatory Mandatory Optional, can be used independently 29

Unplanned Downtime Application Continuity DBA Steps Specify the Replay Data Source connectionfactoryclassname="oracle.jdbc.replay.oracledatasourceimpl" Some calls can be excluded from replay by disabling them with disablereplay() method of ReplayableConnection interface DBA must configure a service with the following properties. Default database service is not recommended FAILOVER_TYPE='TRANSACTION' -- For Application Continuity REPLAY_INITIATION_TIMEOUT=1800 -- After which replay is cancelled FAILOVER_DELAY=10 -- Delay in seconds between connection retries FAILOVER_RETRIES=30 -- Number of connection retries per replay 30

Unplanned Downtime Enabling Transaction Guard DBA Steps Configure the service for TG $srvctl modify service db <db_name> service tgservice commit_outcome true $GDSCTL modify service db <db_name> -service tgservice commit_outcome true Grant execute privilege to the user schema (e.g., SCOTT) SQL> GRANT EXECUTE ON DBMS_APP_CONT TO SCOTT; 31

White Papers Java Programming with Oracle Database 12c RAC and Active DataGuard Planned/Unplanned downtime & Runtime Load Balancing with UCP in WebSphere Planned/Unplanned downtime & Runtime Load balancing with UCP in Tomcat http://www.oracle.com/technetwork/database/application-development/12c-haconcepts-2408080.pdf http://www.oracle.com/technetwork/database/application-development/plannedunplanned-rlb-ucp-websphere-2409214.pdf http://www.oracle.com/technetwork/database/application-development/plannedunplanned-rlb-ucp-tomcat-2265175.pdf 32

Program Agenda Maximum Availability with planned/unplanned downtimes Building Blocks which solved the Issues DBAs & Developers Steps for Planned Maintenance DBAs & Developers Steps for Unplanned Downtime 5 Questions 33

34