anwendungsentwicklung für hochverfügbare … · title: anwendungsentwicklung mit data guard...
TRANSCRIPT
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Anwendungsentwicklung für Hochverfügbare Datenbanken
Sebastian Solbach BU Core & Cloud Technologies ORACLE Deutschland B.V. Co. KG Mai, 2017 [email protected] @s2solbach
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Grundlagen: Session, Connection Pools und Services
Transparente Wartungsarbeiten
Gesicherte Transaktionen für die Applikation
Application Continuity
Bonustrack: Für den DBA
1
2
3
4
5
4
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Grundlagen: Session, Connection Pools und Services
Transparente Wartungsarbeiten
Gesicherte Transaktionen für die Applikation
Application Continuity
Bonustrack: Für den DBA
1
2
3
4
5
5
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Services
• Pro Datenbank existieren mehrere Services
– Default Service (DB_UNIQUE_NAME) – nur für den DBA
– Applikations-Services zur primären Verbindung von Applikationen
• Beschreiben Anwendungen und Gruppieren Sessions
• Über Services können Zugriffe gesteuert, Ressourcen zugeteilt, Session beendet und Verfügbarkeit gesteuert werden
• Erlaubt Verwendung von Easy Connect
6
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Verwenden eines eigenen Services !!!
• Oracle Datenbank 12c & Oracle Client 12c
• Services in der Datenbank: https://apex.oracle.com/pls/apex/germancommunities/dbacommunity/tipp/741/index.html
... und das gilt nicht nur für RAC, Data Guard und Multitenant (PDB)
(DESCRIPTION =
(ADDRESS = (PROTOCOL=TCP)(HOST=pri-scan)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME = gold))
)
7
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12.1 Java Thin Data Guard Service Verbindung (DESCRIPTION =
(CONNECT_TIMEOUT=4) (RETRY_COUNT=20) (RETRY_DELAY=3)
(ADDRESS_LIST =
(LOAD_BALANCE=on)
(ADDRESS = (PROTOCOL=TCP)(HOST=primary)(PORT=1521)))
(ADDRESS_LIST =
(LOAD_BALANCE=on)
(ADDRESS = (PROTOCOL=TCP)(HOST=standby)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME = gold)))
8
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12.1 OCI Data Guard Verbindung ALIAS = (DESCRIPTION =
(CONNECT_TIMEOUT=90) (RETRY_COUNT=20) (RETRY_DELAY=3)
(TRANSPORT_CONNECT_TIMEOUT=3)
(ADDRESS_LIST =
(LOAD_BALANCE=on)
(ADDRESS = (PROTOCOL=TCP)(HOST=primary)(PORT=1521)))
(ADDRESS_LIST =
(LOAD_BALANCE=on)
(ADDRESS = (PROTOCOL=TCP)(HOST=standby)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME = gold)))
9
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Erfahrungen
• IMMER einen eigenen Service für Applikationen verwenden
– Default Service der PDB oder Datenbank ist NUR für die Administration
• Aktueller 12c Client verwenden (für neue und alte DB Releases)
• 1x DESCRIPTION – mehr verlangsamen Verbindungsaufbau
• CONNECT_TIMEOUT=90 gegen Logon Storm (OCI & ODP) • Vorsicht: JDBC Property oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR hat Vorrang
• LOAD_BALANCE=ON pro SCAN Address Liste
• Nie RETRY_COUNT ohne RETRY_DELAY
• Kein Easy*Connect (kein HA)
10
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 11
Connection Pools
Microservice Connection Pool
Primär Datenbank
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 12
Connection Pools
Connection Pool
Primär Datenbank
Microservice
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 13
Connection Pools
Connection conn = getConnection(pds);
Connection Pool
Primär Datenbank
Microservice
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 14
Connection Pools
Connection conn = getConnection(pds);
PreparedStatement pstmt = …
…
SQL, PL/SQL, local calls, RPC
…
Connection Pool
Primär Datenbank
Microservice
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 15
Connection Pools
Connection conn = getConnection(pds);
PreparedStatement pstmt = …
…
SQL, PL/SQL, local calls, RPC
…
conn.commit();
Connection Pool
Primär Datenbank
Microservice
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 16
Connection Pools
Connection conn = getConnection(pds);
PreparedStatement pstmt = …
…
SQL, PL/SQL, local calls, RPC
…
conn.commit();
conn.close();
Connection Pool
Primär Datenbank
Microservice
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 17
Connection Pools
Connection conn = getConnection(pds);
PreparedStatement pstmt = …
…
SQL, PL/SQL, local calls, RPC
…
conn.commit();
conn.close();
Connection Pool
Primär Datenbank
Microservice
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 18
Connection Pools
Connection conn = getConnection(pds);
PreparedStatement pstmt = …
…
SQL, PL/SQL, local calls, RPC
…
conn.commit();
conn.close();
Connection Pool
Primär Datenbank
Microservice
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 19
Klassischer Connection Pool im Fehlerfall
Connection Pool
Primär Datenbank
Microservice Standby Datenbank
Test: Select * from dual;
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 20
Klassischer Connection Pool im Fehlerfall
Connection Pool
Primär Datenbank
Microservice Standby Datenbank
Test: Select * from dual;
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 21
Klassischer Connection Pool im Fehlerfall
Connection Pool
Alte Primär Datenbank
Microservice Neue Primär Datenbank
TCP/IP Timeout....
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 22
Klassischer Connection Pool im Fehlerfall
Connection Pool Microservice Neue Primär Datenbank
TCP/IP Timeout....
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 23
Oracle Universal Connection Pool (UCP) im Fehlerfall
UCP
Primär Datenbank
Microservice Standby Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 24
Oracle Universal Connection Pool (UCP) im Fehlerfall
UCP
Primär Datenbank
Microservice Standby Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 25
Oracle Universal Connection Pool (UCP) im Fehlerfall
UCP Microservice Neue Primär Datenbank
ONS
ONS Alte Primär Datenbank
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 26
Oracle Universal Connection Pool (UCP) im Fehlerfall
UCP Microservice Neue Primär Datenbank
ONS
ONS Alte Primär Datenbank
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 27
Oracle Universal Connection Pool (UCP) im Fehlerfall
UCP Microservice Neue Primär Datenbank
ONS
ONS Alte Primär Datenbank
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Fast Application Notification
• Oracle Notification Server (ONS) überwacht die Knoten
– Ereignisse führen zum Senden einer Benachrichtigung
• Event Type: SERVICE, INSTANCE, DATABASE, ASM, NODE
• Status: UP, DOWN, UNKNOWN
• Reason: USER, FAILURE
– Subscription des Clients zu mehreren ONS
28
FAN event type: service_member
Properties: version=1.0 service=OLTP database=SSDB
instance=SSDB host=bumucsvm1 status=up
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Applikationen verlieren Zeit
•Warten auf TCP/IP Timeouts
•Fehler bei geplanten Ausfällen
•Verbindungsabbrüche bei Nichtverfügbarkeit des Services
•Keine Neu-Verbindungsversuche bei Serviceverfügbarkeit
•Verbindungen auf überlastete Knoten
FAN & FCF
Down – Service/Knoten down <50ms für Failover
Planned Down – Entleerung des Connectionspools ohne Verbindungsabbrüche
Up – Verteilung der Arbeitslast bei Serviceverfügbarkeit
RLB % - Informationen zur optimalen Verteilung
Affinity – Optimierung Workload lokal zu halten
Ausfall feststellen: Fast Application Notification
29
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Fast Application Notification: Wo?
Client 11g 12c
JDBC Universal Connection Pool ONS ONS
ODP.NET Unmanaged (OCI) AQ ONS
ODP.NET Managed (C#) ONS
OCI Session Pool AQ ONS
WebLogic Active GridLink ONS ONS
Tuxedo ONS ONS
JDBC thin standalone (12.2) ONS
OCI/OCCI driver AQ ONS
30
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
FAN Client: Java-Beispiel
• Bibliothek in CLASSPATH einbinden
– $ORACLE_HOME/opmn/lib/ons.jar
• Client Program:
Fast Application Notification (including fanWatcher)
ons = new ONS("primary:6200,standby:6200");
s=ons.createNewSubscriber("","database/event");
....
e = s.receive(true);
...
System.out.println(e.type());
System.out.println(e.body());
31
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12cR2 FAN Immer an / Auto-Konfiguration
• Neuer JDBC Thin Treiber inkludiert FAN
• SimpleFAN und ONS jar im Classpath:
– For using Oracle RAC Fast Application Notification, the simplefan.jar file must be present in the classpath, and either the ons.jar file must be present in the classpath or an Oracle Notification Services (ONS) client must be installed and running in the client system. • https://docs.oracle.com/cd/E18283_01/java.112/e16548/apxracfan.htm
32
11.2 / 12.1 und 12.2
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12c JDBC FAN Konfiguration (12.2: On by Default)
• ONS Konfiguration wird aus URL abgeleitet
• Prüfen, ob ons.jar im Classpath enthalten ist
• Vor 12.2
– Registrierung bei den ONS daemons
ods.setConnectionCachingEnabled(True);
ods.setFastConnectionFailoverEnabled(true);
– Wichtig: SCAN Loadbalancing aktivieren
oracle.jdbc.thinForceDNSLoadBalancing=true
– Default: ONS verwendet 3 End-points. Bei Data Guard dies ggf. erhöhen:
oracle.ons.maxconnections=4 (or more)
• Vor 12.1: ods.setONSConfiguration("nodes=bumucsvm1:6200,bumucsvm2:6200,bumucsvm3:6200");
33
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12c OCI FAN Konfiguration (Auto)
• 12.2 OCI Clients & 12 Datenbank
– Service Konfiguration für die AQ HA Notification:
srvctl modify service -db EM -service GOLD -notification TRUE
– ONS Konfiguration aus TNS
• 12.1 OCI Clients
– Verwenden von oraaccess.xml
• Pre-12c OCI Clients
– Aktivierung der OCI_EVENTS während der Laufzeit im Client (OCIEnvCreate(...) )
– Linken der Applikation mit der Client Thread O/S library.
– Falls die Session nicht in den Pool zurückgegeben werden:
Check OCI_ATTR_SERVER_STATUS
<oraaccess>
<default_parameters>
<events>true</events>
</default_parameters>
</oraaccess>
34
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12c ODP.NET FAN Konfiguration
• Aktivierung von HA Events durch "HA Events=true“ und "pooling=true" im Connection String
"user id=oracle; password=pwd; data source=HA; pooling=true; HA events=true;"
• "Load Balancing=true" zur Verwendung von Runtime Conntection LB.
"user id=oracle; password=pwd; data source=HA;
pooling=true; HA events=true; load balancing=true;"
• Falls die Session nicht in den ODP.NET zurückgegeben werden:
Check Connection.State (6620732)
• Pre-12c SRVCTL für die Event Notification (wie bei OCI)
35
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Grundlagen: Session, Connection Pools und Services
Transparente Wartungsarbeiten
Gesicherte Transaktionen für die Applikation
Application Continuity
Bonustrack: Für den DBA
1
2
3
4
5
36
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 37
Geplante Wartungsarbeiten
UCP
Primär Datenbank
Microservice Standby Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 38
Switchover
UCP
Primär Datenbank
Microservice Standby Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 39
Switchover
UCP
Primär Datenbank
Microservice Standby Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 40
Switchover
UCP
Primär Datenbank
Microservice Standby Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 41
Switchover
UCP
Primär Datenbank
Microservice Standby Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 42
Switchover
UCP
Standby Datenbank
Microservice Primär Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 43
Switchover
UCP
Standby Datenbank
Microservice Primär Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 44
Switchover
UCP
Standby Datenbank
Microservice Primär Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 45
Switchover
UCP
Standby Datenbank
Microservice Primär Datenbank
ONS
ONS
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Transparent Client Connection Failover
• Session bleiben bei Active Data Guard erhalten (Failover/Switchover)
• Vorteil:
– Benutzer bleiben Verbunden
– Kein Reconnect Storm nach Failover
• Automatisch – Nur Services müssen konfiguriert sein
46
Beibehalten von Verbindungen auf Standby
Read/Write Read
Read/Write
Active Data Guard Standby
Primary Failed Primary
Primary
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12cR2 FAN Enable Connection Tests to Drain
• JDBC
– isValid
– isUsable
– isClosed
– pingDatabase
– SQL Tests (with HINT)
• OCI
– OCI_ATTR_SERVER_STATUS
• ODP.Net
– connection.status
47
Unterstützt 11.2, 12.1 & 12.2
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 48
Application Server Test Name Connection Test to DB
Oracle WebLogic – Generic and Multi data sources
TestConnectionsOnReserve
TestConnectionsOnCreate
isUsable SQL – SELECT 1 FROM DUAL
Oracle WebLogic Active GridLink embedded isUsable
IBM WebSphere PreTest Connections SQL - SELECT 1 FROM DUAL
Red Hat JBoss check-valid-connection-sql SQL - SELECT COUNT(*) FROM DUAL
Apache TomCat TestonBorrow
TestonRelease SQL - SELECT 1 FROM DUAL
“Drain” von Applikation Servern an “sicheren” Stellen
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Application Condition Connection Test to DB
eBusiness Suite Connection borrowed from Weblogic TestConnectionsOnReserve
with "BEGIN NULL; END;"
Fusion Applications Connection returned to WebLogic and C++
pools and checked
TestConnectionsOnReserve
with isValid
OCI_ATTR_SERVER_STATUS
Siebel EAI (batch) checks status before starting OCI_ATTR_SERVER_STATUS
Customer Custom pool with Meta data table
Checks status every 60s OCI_ATTR_SERVER_STATUS
“Drain” von Applikation Servern an “sicheren” Stellen
49 49
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Grundlagen: Session, Connection Pools und Services
Transparente Wartungsarbeiten
Gesicherte Transaktionen für die Applikation
Application Continuity
Bonustrack: Für den DBA
1
2
3
4
5
50
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 51
Oracle Universal Connection Pool (UCP) im Fehlerfall
UCP Microservice Neue Primär Datenbank
ONS
ONS Alte Primär Datenbank
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Unterbrechung der Datenbank Verbindung
• Ausfall feststellen
• Wiederaufnahme im vorgegebenen Zeitfenster
• Exception Handling
• Transaktionsstatus herausfinden
• Weiterführung der aktuellen Transaktion
52
5 Probleme für den Anwendungsentwickler
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Unterbrechung der DB Verbingung
Ausfall festestellen - FAN
Wiederaufnahme im vorgegebenen Zeitfenster – RAC/Data Guard
• Exception Handling
• Transaktionsstatus herausfinden
• Weiterführung der aktuellen Transaktion
53
5 Probleme für den Anwendungsentwickler
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Exception Handling? “Recoverable Error”
• Formalisiert:
– OracleException.IsRecoverable property
– JDBC throws SQLRecoverableException
• Applikationen brauchen keine eigene Liste mit Fehlercodes (z.B., ORA-1033, ORA-1034, ORA-xxx)
54
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Neu in Oracle Database 12c
Lösungen für Transaktionsstatus & Fortführung
Transaction Guard
Verlässliches Protokoll und API den Status der letzten Transaktionen zu
überprüfen
Application Continuity
Automatische Wiederholung (Replay) der Benutzer-transaktion nach einem Ausfall oder während
einer Wartung
55
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Herausforderung: Commit Ergebnis
Unterbrechung der Kommunikation während eines COMMIT
• Java/JDBC Applikation bekommt eine Fehlermeldung :”Failed”
– Keine Information über das Ergebnis dieser “in-flight” Transaktion
• Typisches Szenario
– t0: Applikation prüft Status der Transaktion und erhält “Not COMMITTED”. Auf Basis dieser Information wird das weitere Vorgehen bestimmt
– t1: Transaktion wird doch noch abgeschlossen
– Es gibt (bis 12c) keinen verlässliche Möglichkeit den Status einer in-flight Transaktion zu prüfen
56
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Applikation/Treiber - RDBMS Interaktion
Transaction Guard – Schematische Darstellung
57
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Transaction Guard
1. RDBMS assoziiert zu jeder “in-flight” Transaktion eine logische TransaktionsID (LTXID)
LTXID wechselt NUR bei einem erfolgreichen COMMIT oder ROLLBACK
2. LTXID wird z.B. an JDBC kommuniziert
3. Falls die Verbindung abbricht
RDBMS: Falls GET_LTXID_OUTCOME weder Committed noch Rollback zurückgibt, wird die Transaktion daran gehindert zu COMMITTEN
Verlässliche Information des COMMIT Ergebnisses
LogicalTransactionId ltxid = oldConn.getLogicalTransactionId();
OracleConnection newConn = getConnection();
CallableStatement cstmt = newConn.prepareCall(GET_LTXID_OUTCOME);
58
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Commit Outcome
GET_COMMIT_OUTCOME forciert das Commit Ergebnis der Session:
• COMMITTED
– TRUE: Der Aufruf hat mindestens einen erfolgreichen Commit enthalten
– FALSE: Der Aufruf ist uncommited und wird auch nicht mehr ausgeführt
• USER_CALL_COMPLETED
– TRUE: Der Aufruf lief bis zum Ende
– FALSE: Es gibt keine Informationen ob der Aufruf beendet wurde
Z.B. Das Autocommit Ergebnis von PL/SQL Bind Variablen (Out) fehlt
59
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Ein Beispiel
• Datenbank Sessions brechen ab:
– FAN & FCF schließen tote Sessions (sehr schnell!)
– Applikation bekommt einen Fehler
• Wenn “recoverable error” dann – Get last LTXID von der toten Session
– Anfordern einer neuen Datenbank Session
– Forcieren des Commit Ergebnisses: DBMS_APP_CONT.GET_LTXID_OUTCOME with last LTXID
If committed then {
process committed;
if user_call_completed then application may continue
else application may not be able to continue}
Else process uncommitted
60
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Transaction Guard
Transaction Guard nur verwenden, wenn die Session tot ist oder nicht reagiert:
• NICHT die LTXID abfragen und für die Laufzeitumgebung verwenden
• NICHT die Funktion GET_LTXID_OUTCOME auf die eigene Session ausführen
• NICHT nach GET_LTXID_OUTCOME fragen mit einer LTXID einer anderen Umgebung
• GET_LTXID_OUTCOME sollte verwendet werden für eine Session, die einen “Recoverable Error” erhalten hat oder auf eine Zeitüberschreitung (Timeout) gelaufen ist
Best Practices
61
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Transaction Guard
• Supportete Commit Modelle
– Local TXN
– Auto-commit, Commit on Success
– Commit embedded in PL/SQL
– DDL, DCL, Parallel DDL
– Remote, Distributed
– XA ab 12.2
• Ausgeschlossen
– R/W DBLinks von Active Data Guard / Read Only
Treiber Unterstützung mit 12.1.0.2
62
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Grundlagen: Session, Connection Pools und Services
Transparente Wartungsarbeiten
Gesicherte Transaktionen für die Applikation
Application Continuity
Bonustrack: Für den DBA
1
2
3
4
5
63
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
PoolDataSource pds = GetPoolDataSource(); Connection conn = getConnection(pds); PreparedStatement pstmt = …
… SQL, PL/SQL, local calls, RPC …
conn.commit(); conn.close();
Legt die Grenzen für die Wiederholung fest
Die Einheit: “Datenbank Request” Begin
Request
Request Body schließt
gewöhnlich mit COMMIT ab
End Request
64
JDK9 Standard Datenbank Request: Unit of work, Default zwischen Check-out & Check-in
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Phasen bei Application Continuity
1-Laufzeit Operationen 2-Reconnect 3-Replay
• Überwachung der einzelnen Datenbank Requests
• Server ermittelt was / was nicht wiederholt werden kann
• Client speichert den orginären Aufruf inkl. Bind Variablen und Validierung
• Prüft ob für den Request Replay aktiviert wurde
• Verwaltung von Timeouts
• Eröffnet neue Verbindung
• Validiert die Zieldatenbank/Zielinstanz
• Verwendet Transaction Guard zur Ermittlung des COMMIT Ergebnisses
• 12.2 Herstellen initialer Status
• Wiederholung der gespeicherten Aufrufe
• Verifizierung der Ergebnisse mit den Vorhergehenden.
• Führt den Request weiter, falls die Wiederholung erfolgreich ist
65
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Konfiguration Application Continuity
• JDBC URL oder Property Datei
• WebLogic Console oder UCP/Weblogic Property Datei
• Setzen von ONS nicht mehr notwendig, da in 12c die ONS Server automatisch konfiguriert werden (via. Listener)
JDBC / WLS
# Verwendung der neuen 12.1 Replay DataSource
datasource=oracle.jdbc.replay.OracleDataSourceImpl
# Auswählen der neuen 12.1
replay datasource=oracle.jdbc.replay.OracleDataSourceImpl
66
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Ausnahmen: Replay deaktiviert
Global Request Target Database
• Default Datenbank Service oder Default PDB Service
• 12.1: XA in 12.1, OCI, ODP.NET, Tuxedo, SQL*Plus
• 12.2: Nur: ODP.NET managed
• Verwendung einiger JDBC-Klassen aus dem Package oracle.sql*
• Restricted Calls (eigentlich logisch) :
– Alter System
– Alter Database
• Active Data Guard mit read/write Datenbanklinks
• Nicht verfügbar bei
– Logical Standby
– Golden Gate
– PDB Clone
*Acchk (Teil von Orachk) “Replay Coverage Analysis” – Analysiert % der SQL Aufrufe, die nicht vom automatischen Replay erfasst würden ORAchk - Health Checks for the Oracle Stack (Doc ID 1268927.2) https://t.co/sSltFjewJo
67
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
SQL*PLUS
$ sqplus -H
...
Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ]
<option> is: [-AC] [-C <version>] [-L] [-M "<options>"] [-NOLOGINTIME] [-R <level>]
[-S]
-AC Enable Application Continuity.
68
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Konfiguration
• FAILOVER_TYPE = TRANSACTION für Application Continuity
• FAILOVER_RESTORE = LEVEL1 für “normale” Server State
• AQ_HA_NOTIFICATIONS=True für FAN mit OCI Treiber, ODP.NET, Tuxedo, SQL*Plus
• Java Client: Replay Data Source, Lokal oder XA (12.2)
• OCI, ODP.NET, Tuxedo, SQL*Plus
69
Setzen der Service Attribute !
replay datasource=oracle.jdbc.replay.OracleDataSourceImpl
On when enabled on the service
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Restriktionen: Wann wird nicht wiederholt?
Normal Runtime Reconnect Replay
Aufrufe im selben Request nach
• Einem erfolgreichen Commit im dynamischen Modus
• Auftreten eines “restricted call”
• disableReplay API
• Fehler ist nicht “recoverable”
• Fehler beim erneuten Verbindungsaufbau
• Zieldatenbank nicht für Replay geeignet
• Letzter Aufruf erfolgreich committed im dynamischen Modus
• Validierung erkennt Unterschiede im Ergebnis
70
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Initialer Session State vor dem Replay
• 12.1 (leerer State) • Applikationen setzen State pro Request
• WebLogic, UCP, DRCP verwenden Connection Labels
• Logon Triggers
– TAF oder JDBC Callback für schwierige Fälle
• 12.2.0.1 - FAILOVER_RESTORE = LEVEL1 für einige Standard State
• Zukunft: Datenbank erkennt ob Session State notwendig ist oder nicht.
71
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Deaktiveren von Replay ?
• Verwenden der disableReplay() API für Aufrufe, die nicht wiederholt werden sollen/dürfen, insbesondere für Externe Aktionen:
– Autonome Transaktionen
– UTL_HTTP, UTL_URL
– UTL_FILE, UTL_FILE_TRANSFER
– UTL_SMPT, UTL_TCP
– UTL_MAIL
– DBMS_PIPE (nicht empfohlen bei RAC)
– DBMS_ALERT
• Verwenden anderer Connection
72
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Optionale Datenbank Konfiguration
• Damit z.B. Sysdate bei einem Replay denselben Wert zurückgibt:
„Mutables“ Rechte vergeben
GRANT [KEEP DATE TIME | KEEP SYSGUID].. [to USER]
REVOKE [KEEP DATE TIME | KEEP SYSGUID][from USER]
GRANT KEEP SEQUENCE.. [to USER] on [sequence object];
REVOKE KEEP SEQUENCE [from USER] on [sequence object];
ALTER SEQUENCE.. [sequence object] [KEEP|NOKEEP];
CREATE SEQUENCE.. [sequence object] [KEEP|NOKEEP];
73
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Grundlagen: Session, Connection Pools und Services
Transparente Wartungsarbeiten
Gesicherte Transaktionen für die Applikation
Application Continuity
Bonustrack: Für den DBA
1
2
3
4
5
74
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Geplante Wartungsarbeiten
• DBA „schwenkt“ Service von Primary auf Standby:
– Manuell: srvctl relocate/stop service
– 12.2 DG Broker: DGMGRL> switchover to standby wait;
– Connection Pool baut offene Sessions ab, sobald diese inaktiv im Pool sind. Neue Connections werden auf den neuen Knoten geöffnet
• Nach XX Minuten werden die verbleibenden Sessions Transaktional geschlossen exec
dbms_service.disconnect_session('service_name‚DBMS_SERVICE.POST_TRANSACTION);
• 12.2: JDBC, OCI, ODP.NET ... Treiber versuchen Connection an „sicheren Stellen“ anzuhalten
75
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Verwenden eines eigenen Services !!!
• Oracle Datenbank 12c & Oracle Client 12c
• Services in der Datenbank: https://apex.oracle.com/pls/apex/GERMAN_COMMUNITIES.SHOW_TI
PP?P_ID=741
... und das gilt nicht nur für RAC, Data Guard und Multitenant (PDB)
srvctl modify service -db ORCL -service APPCON
-failovertype TRANSACTION -replay_init_time 300
-failoverretry 30 -failoverdelay 3
-notification TRUE -commit_outcome TRUE
-session_state DYAMIC –drain_timeout 30 –failover_restore LEVEL1
76
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Service Konfiguration Transaction Guard
• COMMIT_OUTCOME
– Werte : TRUE oder FALSE, Default: FALSE
– Greift sofort bei neuen Sessions
• RETENTION_TIMEOUT
– Einheit: Sekunden, Default: 24 Stunden (86400)
– Maximalwert: 30 Tage (2592000)
• AQ_HA_NOTIFICATIONS
– Werte: TRUE oder FALSE, Default: FALSE (noch)
– Auf TRUE setzen für FAN !!
77
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Service Konfiguration Application Continuity
• FAILOVER_TYPE
– Werte : NONE, SESSION, SELECT, TRANSACTION, Default: NONE
– Für AC auf TRANSACTION setzen
• REPLAY_INITIATION_TIMEOUT = 300
– Zeit in Sekunden nach der ein Replay abgebrochen wird
• FAILOVER_RETRIES = 60
– Anzahl der Verbindungsversuche für einen Replay
• FAILOVER_DELAY = 3
– Verzögerung in Sekunden zwischen den Verbindungsversuchen
Zusätzlich für Application Continuity
78
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Service Konfiguration Application Continuity
• SESSION_STATE
– Werte : DYNAMIC, STATIC, Default: DYNAMIC
– Dynamischer oder Statische Request Grenzen
• DRAIN_TIMEOUT – Zeit in Sekunden bis Service heruntergefahren wird
• FAILOVER_RESTORE
– Werte: NONE, LEVEL1, Default: NONE
– Wiederherstellen von Standard Session States
79
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Rechte & Datenbank Parameter
• Applikationsbenutzer braucht Rechte auf das DBMS_APP_CONT Package
• REMOTE_LISTENERS muss alle Listener kennen, über die die Clients sich initial verbinden (im Normalfall nur SCAN)
GRANT EXECUTE ON DBMS_APP_CONT TO <app-name>;
alter system set REMOTE_LISTENERS='SCAN.domain.com:1521'
80
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Kill Session
• Natürlich greift AC...
– ... nicht unbedingt immer gewollt!
Was passiert, wenn der DBA eine Session killt?
SQL> alter system kill session 'sid, serial#, @inst' noreplay;
SQL> alter system disconnect session 'sid, serial#, @inst'
noreplay;
SQL> execute DBMS_SERVICE.DISCONNECT_SESSION(‘[service name]’,
DBMS_SERVICE.NOREPLAY) ;
81
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Informationen LTXID Tabelle
• Partitioniert nach INST_ID
• Automatisch 1 Partition pro Instanz
• Default: SYSAUX Tablespace
• Darf verschoben werden (Online 12c Feature)
• Nur befüllt von Services mit COMMIT_OUTCOME=TRUE
desc LTXID_TRANS
Name Null? Type
------------- -------- ---------------------------
MAJ_VERSION NOT NULL NUMBER
MIN_VERSION NOT NULL NUMBER
INST_ID NOT NULL NUMBER
DB_ID NOT NULL NUMBER
SESSION_GUID NOT NULL RAW(64)
TXN_UID NOT NULL NUMBER
COMMIT_NO NOT NULL NUMBER
START_DATE NOT NULL TIMESTAMP(6) WITH TIME ZONE
SERVICE_ID NOT NULL NUMBER
STATE NOT NULL NUMBER
FLAGS NOT NULL NUMBER
REQ_FLAGS NOT NULL NUMBER
ERROR_CODE NOT NULL NUMBER
82
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Lizenzen für produktiven Einsatz
• Transaction Guard: Enterprise Edition
• Application Continuity: RAC oder Active Data Guard Option
• Oracle® Database Licensing Information 12c Release 1 (12.1) http://docs.oracle.com/cd/E16655_01/license.121/e17614/edit
ions.htm#DBLIC116
83
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Links & weitere Informationen
• DBA Community https://blogs.oracle.com/dbacommunity_deutsch/
• OTN http://www.oracle.com/technetwork/products/clustering/ac-overview-1967264.html
• Whitepapers http://www.oracle.com/technetwork/database/database-cloud/private/transaction-guard-wp-
12c-1966209.pdf
http://www.oracle.com/technetwork/database/database-cloud/private/application-continuity-
wp-12c-1966213.pdf
• Dokumentation • http://docs.oracle.com/cd/E16655_01/java.121/e17659/app_cont.htm#JJUCP8254
84