Oracle Multitenant Self-Service Provisioning – Neue Version

Mit der Oracle Multitenant Self-Service Provisioning Applikation PDBSS hat ein DBA / Entwickler die Möglichkeit, sich mit dem mit 12c neu eingeführten Konzept von Multitenant und den Pluggable Databases (PDB) vertraut zu machen. Die auf Oracle Application Express basierende Webapplikation ist eine prima Möglichkeit, Aktionen wie Bereitstellung, cloning, plug unplug durchzuführen.

Bereits 2013 habe ich im Trivadis O-AI Blog darüber berichtet, damals war die Software noch im Beta-Status. Seit dem 20. Mai 2015 ist die finale Version als Download verfügbar. Als Neuerung wird bspw. die Apex-Applikation in CDB$ROOT installiert und der Oracle REST Data Service verwendet (vorher APEX-Listener).

Die Applikation ist nicht für den produktiven Einsatz gedacht.

Aus dem Readme:

PDBSS provides an interface to an Oracle Database 12c multitenant environment and allows for the self-service provisioning of pluggable databases (PDBs) in a multitenant container database  (CDB). Its primary goal is to encourage learning about PDBs in development and test environments. It is an easy and productive way to allow database administrators (DBAs) and application developers the opportunity to gain hands-on experience with powerful PDB features, including creating PDBs, cloning PDBs, plugging in PDBs, and unplugging PDBs.

Voraussetzungen – Software

Oracle 12.1.0.2 oder höher
Oracle Application Express 4.2.5 oder höher (4.2.5 wird mit 12.1.0.2 mitgeliefert)
Oracle REST Data Services 2.0.6 oder höher (2.0.7 wird mit 12.1.0.2 mitgeliefert)
Oracle Pluggable Database Self-Service Provisioning Application

Im ZIP-Paket der Oracle Pluggable Database Self-Service Provisioning Application ist ein README.pdf mit der detaillierten Installationsanleitung verfügbar. Dabei wird auch empfohlen die neueste Version der Oracle REST Data Services herunterzuladen.

Voraussetzungen – Datenbank

Es wird eine leere Datenbank mit dem Zeichensatz AL32UTF8, sollte der lokale Listener nicht auf Port 1521 laufen, so muss in der Container-Datenbank CDB$ROOT der Parameter LOCAL_LISTENER gesetzt werden:

ALTER SYSTEM SET LOCAL_LISTENER =
'(ADDRESS = (PROTOCOL=TCP)(HOST=LOCALHOST)(PORT=1522))' SCOPE = BOTH;

RESTful Web Services in der Datenbank konfigurieren

Es muss für die Datenbankbenutzer APEX_LISTENER und APEX_REST_PUBLIC_USER ein Passwort gesetzt werden. Hinweis: Die Passwörter werden später für die Konfiguration der Oracle REST Data Services benötigt.

$ cd $ORACLE_HOME/apex
$ sqplus / as sysdba
SQL> @apex_rest_config_con.sql

PL/SQL procedure successfully completed.

Enter a password for the APEX_LISTENER user              []
Enter a password for the APEX_REST_PUBLIC_USER user              []

Performing installation in multitenant container database in the background.
The installation progress is spooled into apex_rest_config_con*.log files.

Please wait...

catcon: ALL catcon-related output will be written to apex_rest_config_con_catcon_18454.lst
catcon: See apex_rest_config_con*.log files for output generated by scripts
catcon: See apex_rest_config_con_*.lst files for spool files, if any
catcon.pl: completed successfully

Installation completed. Log files for each container can be found in:

apex_rest_config_con*.log

You can quickly scan for ORA errors or compilation errors by using a utility
like grep:

oracle@solothurn:/u00/app/oracle/product/12.1.0.2/apex/ [PDBSS12] grep PLS- *.log | wc -l
0

oracle@solothurn:/u00/app/oracle/product/12.1.0.2/apex/ [PDBSS12] grep ORA- *.log | wc -l
0

Unlock APEX_PUBLIC_USER und Passwort ändern

Hinweis: Das Passwort werden später für die Konfiguration der Oracle REST Data Services benötigt.

SQL> ALTER USER APEX_PUBLIC_USER IDENTIFIED BY <password>  ACCOUNT UNLOCK;

SQL> GRANT SET CONTAINER TO APEX_PUBLIC_USER CONTAINER=ALL;
SQL> GRANT SET CONTAINER TO APEX_REST_PUBLIC_USER CONTAINER=ALL;
SQL> GRANT SET CONTAINER TO APEX_LISTENER CONTAINER=ALL;

Oracle REST Data Services ORDS konfigurieren

Auf Grund von Konfigurationsproblemen habe ich auf eine aktuelle 3-er Version verzichtet und mir stattdessen die Version 2.0.10 runtergeladen und entpackt:

http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/ords-downloads-2010-2528184.html

oracle@solothurn:/u00/app/oracle/product/ords/ [rdbms12102] ll
total 55796
drwxr-xr-x. 4 oracle oinstall     4096 Jun  1 09:22 .
drwxr-xr-x. 4 oracle oinstall     4096 Jun  1 09:21 ..
drwxr-xr-x. 2 oracle oinstall     4096 Oct 16  2014 docs
drwxr-xr-x. 4 oracle oinstall     4096 Oct 16  2014 javadoc
-rw-r--r--. 1 oracle oinstall 28596908 May 23 13:53 ords.2.0.10.289.08.09.zip
-rw-r--r--. 1 oracle oinstall 28491706 Oct 16  2014 ords.war
-rw-r--r--. 1 oracle oinstall    24699 Oct 16  2014 readme.html

Erster Start vom ORDS

Beim ersten Start vom APEX Listener werden folgende Abfragen gemacht – diese werden dann in der Konfigurationsdatei gespeichert:

  • Pfad für die Konfiguationsdatei – bspw.  /u00/app/oracle/product/ords/config
  • Hostname
  • Port
  • Datenbank-Servicename
  • Passwort APEX_PUBLIC_USER
  • Passwörter APEX_REST_PUBLIC_USER / APEX_LISTENER

Hinweis: Die Konfiguration vom ORDS-Benutzer muss übersprungen werden (Known Issues) – der Listener wird beim ersten Mal nicht gestartet: exit [2] am Schluss.

oracle@solothurn:/u00/app/oracle/product/ords/ [rdbms12102] java -jar ords.war
This Oracle REST Data Services instance has not yet been configured.
Please complete the following prompts

Enter the location to store configuration data:/u00/app/oracle/product/ords/config
Jun 01, 2015 9:23:15 AM oracle.dbtools.common.config.cmds.ConfigDir execute
INFO: Set config.dir to /u00/app/oracle/product/ords/config in: /u00/app/oracle/product/ords/ords.war
Jun 01, 2015 9:23:16 AM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /u00/app/oracle/product/ords/config/ords
Enter the name of the database server [localhost]:solothurn
Enter the database listen port [1521]:
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:
Enter the database service name:PDBSS12.trivadis.com
Enter the database user name [APEX_PUBLIC_USER]:
Enter the database password for APEX_PUBLIC_USER:
Confirm password:
Enter 1 to enter passwords for the RESTful Services database users (APEX_LISTENER,APEX_REST_PUBLIC_USER), 2 to use the same password as used for APEX_PUBLIC_USER or, 3 to skip this step [1]:
Enter the database password for APEX_LISTENER:
Confirm password:
Enter the database password for APEX_REST_PUBLIC_USER:
Confirm password:
Jun 01, 2015 9:24:08 AM oracle.dbtools.common.config.file.ConfigurationFiles update
INFO: Updated configurations: defaults, apex, apex_al, apex_rt
Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2

Konfiguration vom DB-Suffix für ORDS

Die DB-Domain in die ORDS-Konfiguration eingetragen – Beispiel: trivadis.com. Ermitteln der DB-Domain als SYSDBA:

SQL> show parameter DB_DOMAIN

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_domain                            string      trivadis.com

Danach wird die Domain in ein Konfigurationsfile eingtragen welches anschliessend verwendet wird.

# echo db.serviceNameSuffix=.trivadis.com > snsuffix.properties

 ORDS Konfiguration aktualisieren

oracle@solothurn:/u00/app/oracle/product/ords/ [rdbms12102] java -jar ords.war set-properties --conf apex snsuffix.properties
Jun 01, 2015 7:52:15 AM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /u00/app/oracle/product/ords/config/ords
Jun 01, 2015 7:52:15 AM oracle.dbtools.rt.config.setup.SetProperties execute
INFO: Modified: /u00/app/oracle/product/ords/config/ords/conf/apex.xml, updated properties: db.serviceNameSuffix

Starten vom ORDS

Beim ersten Start wird nach dem /images Pfad gefragt – hier muss der Pfad vom $ORACLE_HOME/apex/images angegeben werden.Sollte Oracle Application Express in einem anderen Pfad installiert worden sein, so muss das entsprechende Verzeichnis angegeben werden.

oracle@solothurn:/u00/app/oracle/product/ords/ [rdbms12102] java -jar ords.war standalone --context-path /multitenant
Jun 01, 2015 7:57:32 AM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /u00/app/oracle/product/ords/config/ords
Enter the APEX static resources location or Enter to skip:/u00/app/oracle/product/12.1.0.2/apex/images
Enter the HTTP port [8080]:
Jun 01, 2015 7:57:55 AM oracle.dbtools.standalone.Standalone execute
INFO: NOTE:

Standalone mode is designed for use in development and test environments. It is not supported for use in production environments.

Jun 01, 2015 7:57:55 AM oracle.dbtools.standalone.Standalone execute
INFO: Starting standalone Web Container in: /u00/app/oracle/product/ords/config/ords
Jun 01, 2015 7:57:55 AM oracle.dbtools.standalone.Deployer deploy
INFO: Will deploy application path = /u00/app/oracle/product/ords/config/ords/ords/WEB-INF/web.xml
Jun 01, 2015 7:57:56 AM oracle.dbtools.standalone.Deployer deploy
INFO: Deployed application path = /u00/app/oracle/product/ords/config/ords/ords/WEB-INF/web.xml
Jun 01, 2015 7:57:56 AM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /u00/app/oracle/product/ords/config/ords
Configuration properties for: apex
cache.caching=false
cache.directory=/tmp/apex/cache
cache.duration=days
cache.expiration=7
cache.maxEntries=500
cache.monitorInterval=60
cache.procedureNameList=
cache.type=lru
db.hostname=solothurn
db.password=******
db.port=1521
db.servicename=PDBSS12.trivadis.com
debug.debugger=false
debug.printDebugToScreen=false
error.keepErrorMessages=true
error.maxEntries=50
jdbc.DriverType=thin
jdbc.InactivityTimeout=1800
jdbc.InitialLimit=3
jdbc.MaxConnectionReuseCount=1000
jdbc.MaxLimit=10
jdbc.MaxStatementsLimit=10
jdbc.MinLimit=1
jdbc.statementTimeout=900
log.logging=false
log.maxEntries=50
misc.compress=
misc.defaultPage=apex
security.disableDefaultExclusionList=false
security.maxEntries=2000
db.serviceNameSuffix=.trivadis.com
db.username=APEX_PUBLIC_USER
Jun 01, 2015 7:57:56 AM oracle.dbtools.common.config.db.ConfigurationValues intValue
WARNING: *** jdbc.MaxLimit in configuration apex is using a value of 10, this setting may not be sized adequately for a production environment ***
Jun 01, 2015 7:57:56 AM oracle.dbtools.common.config.db.ConfigurationValues intValue
WARNING: *** jdbc.InitialLimit in configuration apex is using a value of 3, this setting may not be sized adequately for a production environment ***
Using JDBC driver: Oracle JDBC driver version: 11.2.0.3.0
Jun 01, 2015 7:57:57 AM oracle.dbtools.rt.web.SCListener contextInitialized
INFO: Oracle REST Data Services initialized
Oracle REST Data Services version : 2.0.10.289.08.09
Oracle REST Data Services server info: Grizzly/1.9.49

Jun 01, 2015 7:57:57 AM com.sun.grizzly.Controller logVersion
INFO: GRIZZLY0001: Starting Grizzly Framework 1.9.49 - 6/1/15 7:57 AM
Jun 01, 2015 7:57:57 AM oracle.dbtools.standalone.Standalone execute
INFO: http://localhost:8080/multitenant/ started.

Mit der URL http://localhost:8080/multitenant/ erreicht man die Oracle Application Express Startseite:

apex_einstiegsseite

Installation der PDBSS-Applikation

Die Applikation habe ich auf dem Server  in ein temporäres Verzeichnis entpackt, welches später dann gelöscht werden kann. Die Installation erfolgt mit einem SQL-Script aus dem entpackten Unterverzeichnis pdbss, welches als SYSDBA in der Container-Datenbank CDB$ROOT ausgeführt wird:

oracle@solothurn:/u00/app/oracle/tmp/ [rdbms12102] ll
total 604
drwxr-xr-x.  3 oracle oinstall   4096 Jun  1 08:05 .
drwxr-xr-x. 14 oracle dba        4096 Jun  1 08:04 ..
-rw-r--r--.  1 oracle oinstall 176954 May  8 16:45 README.pdf
drwxr-xr-x.  3 oracle oinstall   4096 Apr 28 18:10 pdbss
-rw-r--r--.  1 oracle oinstall 425183 May 21 12:12 pdbss_2.0.5.zip

Das Script pdbss_ins.sql wird als SYSDBA gestartet. Die Frage nach dem Demonstration Mode, Datafiles und Port kann mit Enter beantwortet werden. Der neu angelegte ADMIN User ist dann der Verwalter der PDBSS-Applikation. Die Installation ist in kurzer Zeit durch.

SQL> @pdbss_ins.sql
.
... Prerequisite checks passed.
.
Allow demonstration mode [no]:
Enter destination for PDB data files [/u01/oradata/PDBSS12]:
Enter the port used to access this database [1521]:
Enter a password for the self-service ADMIN user:
..
timing for: Complete Install
Elapsed: 00:01:53.18
.
. Done. Please review pdbss_ins.log for any errors.
.

Login in die Oracle Multitenant Self-Service Provisioning Applikation

Die URL muss mit dem Suffix f?p=pdbss ergänz werden:http://localhost:8080/multitenant/f?p=pdbss – danach erscheint die Startseite und es kann sich eingeloggt werden. Der Benutzer heisst ADMIN, das Passwort wurde bei der Installation mit dem pdbss_ins.sql gesetzt.

pdbss_login

pdbss_startseite

ORDS Service separat starten

Der Service läuft aktuell als Terminal-Job. Das heisst sobald das Terminalfenster zu ist, ist kein Zugriff mehr auf die Applikation möglich. Verschiedene Lösungen sind möglich:

#!/bin/sh
#
. /etc/rc.d/init.d/functions
NAME="Oracle REST Data Services"
JAVA="/usr/bin/java"
ORDSWAR="/u00/app/oracle/product/ords/ords.war"
 
 
OPTIONS="-Xmx1024m -Xms256m  -jar $ORDSWAR"
 
LOGFILE=/tmp/ords_listener.log
PIDFILE=/tmp/ords_listener.pid
start() {
        echo -n "Starting $NAME: "
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
                echo ORDS already running: $PID
                exit 2;
        else
                nohup $JAVA $OPTIONS 2>&1 > $LOGFILE  &
                RETVAL=$!
                echo Started PID: $RETVAL
                echo
                echo $RETVAL >>$PIDFILE
                return $RETVAL
        fi
 
}
 
status() {
        echo -n "Status $NAME: "
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
                echo ORDS already running: $PID
                ps -ef | grep $PID
        else
                echo ORDS Listener not running
        fi
}
 
stop() {
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
                echo -n "Shutting down $NAME "
                echo
                kill $PID
                rm -f $PIDFILE
        else
                echo ORDS  not running
        fi
        return 0
}
 
log() {
        tail -f $LOGFILE
}
 
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status
        ;;
    restart)
        stop
        start
        ;;
    log)
        log
        ;;
    *)
        echo "Usage:  {start|stop|status|restart|log}"
        exit 1
        ;;
esac
exit $?

Fazit

Die Oracle Multitenant Self-Service Provisioning Applikation hat den Beta-Status überwunden und ist nun offiziell verfügbar. Gerade für DBAs und Entwickler bietet die Apex-Applikation eine tolle Gelegenheit, sich mit Multitenant auseinanderzusetzen. Das Verständnis für die neue Architektur ist wichtig und gehört zu den technischen Grundlagen beim zukünftigen Einsatz von Oracle 12c.