Using REST API with Oracle AutoUpgrade utility

Oracle AutoUpgrade utility, since version 22, is compatible with RESTful API. This brings all the advantages of using that interface that I won't mention here, but the most important is that is no longer needed to SSH or create a shellscript to perform a database upgrade. Now all can be done simply by reaching the HTTP(S) endpoint exposed.

In this post, I will show how to setup AutoUpgrade utility to work with REST.

Download JARs

First of all, you need to download the latest utilities:

Now that you have all of them let's start it. For this demo, I will be using the Hands-On Lab VirtualBox.

All the files above are placed on the /home/oracle/AU_REST folder of the VirtualBox.

Starting ORDS

First, connect to the host to install ORDS.

In this tutorial, I will deploy ORDS in standalone mode, making it straightforward.

For more details, check the official doc.

[oracle@hol ~]$ cd AU_REST/
[oracle@hol AU_REST]$ ls -l
total 84448
-rwxrwx---. 1 oracle dba  4798426 Apr 18 16:35 autoupgrade.jar
-rwxr-x---. 1 oracle dba 81622442 Apr 18 16:34 ords-21.4.2.062.1806.zip
[oracle@hol AU_REST]$ mkdir ords_install
[oracle@hol AU_REST]$ unzip -q -d ords_install/ ords-21.4.2.062.1806.zip
[oracle@hol AU_REST]$ cd ords_install/
[oracle@hol ords_install]$ ls -l
total 77548
drwxr-xr-x. 3 oracle dba       21 Mar  3 19:10 docs
drwxrwxrwx. 7 oracle dba       93 Mar  3 18:05 examples
-rw-rw-rw-. 1 oracle dba     5744 Mar  3 18:05 FUTC.txt
-rw-rw-rw-. 1 oracle dba    58565 Mar  3 18:05 index.html
-rw-rw-rw-. 1 oracle dba     5744 Mar  3 18:05 license.txt
-rw-r--r--. 1 oracle dba 79327439 Mar  3 19:10 ords.war
drwxrwxrwx. 2 oracle dba       36 Mar  3 18:05 params
drwxrwxrwx. 4 oracle dba       38 Mar  3 18:05 scripts
[oracle@hol ords_install]$ java -jar ords.war standalone
This Oracle REST Data Services instance has not yet been configured.
Please complete the following prompts


Enter the location to store configuration data: /home/oracle/AU_REST/conf/
Enter 1 if using HTTP or 2 if using HTTPS [1]:2
Enter the HTTPS port [8443]:8443
Enter the SSL hostname:hol
Enter 1 to use the self-signed certificate or 2 if you will provide the SSL certificate [1]:1
2022-04-18T14:46:40.536Z INFO        HTTPS listening on host: localhost port: 8443
2022-04-18T14:46:40.565Z INFO        Disabling document root because the specified folder does not exist: /home/oracle/AU_REST/conf/ords/standalone/doc_root
2022-04-18T14:46:41.534Z INFO        No pools configured yet
2022-04-18T14:46:42.603Z INFO        Oracle REST Data Services initialized
Oracle REST Data Services version : 21.4.2.r0621806
Oracle REST Data Services server info: jetty/9.4.44.v20210927

Note I've placed the ORDS files under the /home/oracle/AU_REST/conf/ folder as this will be temporary. If you want to put it in a more permanent location, you can use something like /u01/ords/conf.

I've also started the service using HTTPS to encrypt the network traffic and avoid connection sniffing.

PS: Note that the AU API will be exposed to anyone with access to this endpoint (IP and Port) without authentication. You need to have a firewall on top of that.

Now that the ORDS service is up and running, keep that window open and start another terminal to deploy the AutoUpgrade RESTful API. If you close or stop the ORDS, you can simply restart it by rerunning the same command:

$ java -jar ords.war standalone

Check if ORDS is running

In another window, try to run the CURL command to ORDS endpoint and check if you get a "NotFound" response:

[oracle@hol ords_install]$ curl -k https://localhost:8443/ords/

{
    "code": "NotFound",
    "title": "Not Found",
    "message": "The request could not be mapped to any database. Check the request URL is correct, and that URL to database mappings have been correctly configured",
    "type": "tag:oracle.com,2020:error/NotFound",
    "instance": "tag:oracle.com,2020:ecid/ANdQt15fgkopV7ppyPBnug"
}

Please note that receiving this "NotFound" return code is OK, as ORDS is still not fully configured. The problem will be if you get:

curl: (7) Failed connect to localhost:8443; Connection refused

In this case, you need to double-check your network and firewall.

Enabling AU REST

In the next step, we will enable the AutoUpgrade API in ORDS. For this, the following properties must be set:

java -jar ords.war set-property autoupgrade.api.enabled true

java -jar ords.war set-property autoupgrade.api.loglocation /home/oracle/AU_REST/autoupgrade_logs

java -jar ords.war set-property autoupgrade.api.aulocation /home/oracle/AU_REST/autoupgrade.jar

java -jar ords.war set-property autoupgrade.api.jvmlocation /bin/java
[oracle@hol AU_REST]$ mkdir /home/oracle/AU_REST/autoupgrade_logs
[oracle@hol AU_REST]$ ls -l
total 84452
-rwxrwx---. 1 oracle dba  4798426 Apr 18 16:35 autoupgrade.jar
drwxr-xr-x. 2 oracle dba        6 Apr 18 20:33 autoupgrade_logs
drwxr-xr-x. 3 oracle dba       18 Apr 18 20:31 conf
-rwxr-x---. 1 oracle dba 81622442 Apr 18 16:34 ords-21.4.2.062.1806.zip
drwxr-xr-x. 6 oracle dba     4096 Apr 18 20:31 ords_install
[oracle@hol AU_REST]$ cd ords_install
[oracle@hol ords_install]$ java -jar ords.war set-property autoupgrade.api.enabled true
2022-04-18T18:33:27.661Z INFO        Modified: /home/oracle/AU_REST/conf/ords/defaults.xml, setting: autoupgrade.api.enabled = true
[oracle@hol ords_install]$ java -jar ords.war set-property autoupgrade.api.loglocation /home/oracle/AU_REST/autoupgrade_logs
2022-04-18T18:33:48.282Z INFO        Modified: /home/oracle/AU_REST/conf/ords/defaults.xml, setting: autoupgrade.api.loglocation = /home/oracle/AU_REST/autoupgrade_logs
[oracle@hol ords_install]$ java -jar ords.war set-property autoupgrade.api.aulocation /home/oracle/AU_REST/autoupgrade.jar
2022-04-18T18:34:05.322Z INFO        Modified: /home/oracle/AU_REST/conf/ords/defaults.xml, setting: autoupgrade.api.aulocation = /home/oracle/AU_REST/autoupgrade.jar
[oracle@hol ords_install]$ java -jar ords.war set-property autoupgrade.api.jvmlocation /bin/java
2022-04-18T18:34:20.434Z INFO        Modified: /home/oracle/AU_REST/conf/ords/defaults.xml, setting: autoupgrade.api.jvmlocation = /bin/java
[oracle@hol ords_install]$

Finally, check in the ORDS XML if all the settings are correct:

[oracle@hol ords_install]$ cat /home/oracle/AU_REST/conf/ords/defaults.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>Saved on Mon Apr 18 20:34:20 CEST 2022</comment>
<entry key="autoupgrade.api.aulocation">/home/oracle/AU_REST/autoupgrade.jar</entry>
<entry key="autoupgrade.api.enabled">true</entry>
<entry key="autoupgrade.api.jvmlocation">/bin/java</entry>
<entry key="autoupgrade.api.loglocation">/home/oracle/AU_REST/autoupgrade_logs</entry>
<entry key="cache.caching">false</entry>
<entry key="cache.directory">/tmp/apex/cache</entry>
<entry key="cache.duration">days</entry>
<entry key="cache.expiration">7</entry>
<entry key="cache.maxEntries">500</entry>
<entry key="cache.monitorInterval">60</entry>
<entry key="cache.procedureNameList"/>
<entry key="cache.type">lru</entry>
<entry key="debug.debugger">false</entry>
<entry key="debug.printDebugToScreen">false</entry>
<entry key="error.keepErrorMessages">true</entry>
<entry key="error.maxEntries">50</entry>
<entry key="jdbc.DriverType">thin</entry>
<entry key="jdbc.InactivityTimeout">1800</entry>
<entry key="jdbc.InitialLimit">3</entry>
<entry key="jdbc.MaxConnectionReuseCount">1000</entry>
<entry key="jdbc.MaxLimit">10</entry>
<entry key="jdbc.MaxStatementsLimit">10</entry>
<entry key="jdbc.MinLimit">1</entry>
<entry key="jdbc.statementTimeout">900</entry>
<entry key="log.logging">false</entry>
<entry key="log.maxEntries">50</entry>
<entry key="misc.compress"/>
<entry key="misc.defaultPage">apex</entry>
<entry key="security.disableDefaultExclusionList">false</entry>
<entry key="security.maxEntries">2000</entry>
</properties>
[oracle@hol ords_install]$

Now, go back to the other terminal and restart the ORDS standalone service by pressing CTRL-C and rerunning the command of the previous step:

2022-04-18T14:59:23.485Z INFO        Oracle REST Data Services initialized
Oracle REST Data Services version : 21.4.2.r0621806
Oracle REST Data Services server info: jetty/9.4.44.v20210927

^C
[oracle@hol ords_install]$ java -jar ords.war standalone
2022-04-18T15:02:41.067Z INFO        HTTPS listening on host: localhost port: 8443
2022-04-18T15:02:41.095Z INFO        Disabling document root because the specified folder does not exist: /home/oracle/AU_REST/conf/ords/standalone/doc_root
2022-04-18T15:02:42.292Z INFO        No pools configured yet
2022-04-18T15:02:43.456Z INFO        Oracle REST Data Services initialized
Oracle REST Data Services version : 21.4.2.r0621806
Oracle REST Data Services server info: jetty/9.4.44.v20210927

Running AutoUpgrade

Finally, let's try to upgrade a database using the REST API.

When running AutoUpgrade using the command line, we create a config.cfg file with the needed parameters. For REST, the idea is the same, but using the JSON notation instead of the parameter/value pair.

So, for a UPGR.cfg like this:

global.autoupg_log_dir=/home/oracle/logs

upg1.source_home=/u01/app/oracle/product/11.2.0.4
upg1.target_home=/u01/app/oracle/product/19
upg1.sid=UPGR
upg1.log_dir=/home/oracle/logs
upg1.restoration=no

We would need to create a UPGR.json like that:

{
"global": {
        "autoupg_log_dir": "/home/oracle/logs"
    },
    "jobs": [{
        "source_home": "/u01/app/oracle/product/11.2.0.4",
        "target_home": "/u01/app/oracle/product/19",
        "sid": "UPGR",
        "log_dir": "/home/oracle/logs",
        "restoration": "no"
    }]
}

Now, let's start playing with the REST API.

Using the REST API

It's pretty simple. For the list of the available APIs, check the Official Doc here: https://docs.oracle.com/en/database/oracle/oracle-database/19/upgrd/autoupgrade-rest-apis.html

There are 6 APIs:

First, I will start the analyze of my database (task endpoint with POST):

[oracle@hol ~]$ curl -k --data-binary "@UPGR.json" -X POST --header "Content-Type:application/json" 'https://localhost:8443/ords/autoupgrade/task?mode=analyze'

{
    "taskid": "job_2022_04_19_19.07.20.26_2",
    "status": "submitted",
    "message": "",
    "link": "https://localhost:8443/ords/autoupgrade/task?taskid=job_2022_04_19_19.07.20.26_2",
    "config": {
        "global": {
            "autoupg_log_dir": "/home/oracle/logs"
        },
        "jobs": [
            {
                "source_home": "/u01/app/oracle/product/11.2.0.4",
                "target_home": "/u01/app/oracle/product/19",
                "sid": "UPGR",
                "log_dir": "/home/oracle/logs",
                "restoration": "no"
            }
        ]
    }
}

Job was submitted. A new taskid job_2022_04_19_19.07.20.26_2 was created. We will use this ID whenever we want to check or work with this job from this point onwards. You can see that the returned body has a link to check the task status.

Checking the status (task API with GET):

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/task?taskid=job_2022_04_19_19.07.20.26_2'

{
    "taskid": "job_2022_04_19_19.07.20.26_2",
    "status": "finished",
    "message": "",
    "link": "https://localhost:8443/ords/autoupgrade/task?taskid=job_2022_04_19_19.07.20.26_2",
    "config": {
        "global": {
            "autoupg_log_dir": "/home/oracle/logs"
        },
        "jobs": [
            {
                "source_home": "/u01/app/oracle/product/11.2.0.4",
                "target_home": "/u01/app/oracle/product/19",
                "sid": "UPGR",
                "log_dir": "/home/oracle/logs",
                "restoration": "no"
            }
        ]
    }
}

It shows as finished. If we want to check how the output would show in the AutoUpgrade console window, is it also possible (console API with GET):

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/console?taskid=job_2022_04_19_19.07.20.26_2'

AutoUpgrade is not fully tested on OpenJDK 64-Bit Server VM, Oracle recommends to use Java HotSpot(TM)
AutoUpgrade 22.2.220324 launched with default internal options
Processing config file ...
------------ ERROR ------------
Error Cause: Database UPGR shutdown or open with incorrect binaries for ANALYZE. Ensure it is open with /u01/app/oracle/product/11.2.0.4

------------ ERROR ------------
Error Cause: Database UPGR currently has a status of CLOSED.  For ANALYZE mode, open it with one of the following: [OPEN].

Unable to connect to database UPGR for entry job_0

So clearly, the problem here is that I forgot to startup the source database before running AutoUpgrade. I will restart the database and try the analyze mode again:

[oracle@hol ~]$ curl -k -X POST 'https://localhost:8443/ords/autoupgrade/task?taskid=job_2022_04_19_19.07.20.26_2&mode=analyze'

{
    "taskid": "job_2022_04_19_19.07.20.26_2",
    "status": "submitted",
    "message": "",
    "link": "https://localhost:8443/ords/autoupgrade/task?taskid=job_2022_04_19_19.07.20.26_2",
    "config": {
        "global": {
            "autoupg_log_dir": "/home/oracle/logs"
        },
        "jobs": [
            {
                "source_home": "/u01/app/oracle/product/11.2.0.4",
                "target_home": "/u01/app/oracle/product/19",
                "sid": "UPGR",
                "log_dir": "/home/oracle/logs",
                "restoration": "no"
            }
        ]
    }
}

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/console?taskid=job_2022_04_19_19.07.20.26_2'

AutoUpgrade is not fully tested on OpenJDK 64-Bit Server VM, Oracle recommends to use Java HotSpot(TM)
AutoUpgrade 22.2.220324 launched with default internal options
Processing config file ...
+--------------------------------+
| Starting AutoUpgrade execution |
+--------------------------------+
1 Non-CDB(s) will be analyzed
Job 100 database upgr

( Rerunning the same command after a while... )

AutoUpgrade is not fully tested on OpenJDK 64-Bit Server VM, Oracle recommends to use Java HotSpot(TM)
AutoUpgrade 22.2.220324 launched with default internal options
Processing config file ...
+--------------------------------+
| Starting AutoUpgrade execution |
+--------------------------------+
1 Non-CDB(s) will be analyzed
Job 100 database upgr
Job 100 completed
------------------- Final Summary --------------------
Number of databases            [ 1 ]

Jobs finished                  [1]
Jobs failed                    [0]

Please check the summary report at:
/home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2/cfgtoollogs/upgrade/auto/status/status.html
/home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2/cfgtoollogs/upgrade/auto/status/status.log

Getting the status (status API with GET):

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/status?taskid=job_2022_04_19_19.07.20.26_2'

{
    "taskid": "job_2022_04_19_19.07.20.26_2",
    "status": "successful",
    "message": "",
    "autoupgrade_status": {
        "totalJobs": 1,
        "lastUpdateTime": "2022-04-19 19:39:14",
        "jobs": [
            {
                "sid": "UPGR",
                "jobNo": 101,
                "logDirectory": "/home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2/UPGR/101",
                "conNumber": 1,
                "lastUpdateTime": "2022-04-19 19:39:14",
                "modules": [
                    {
                        "moduleName": "PRECHECKS",
                        "status": 0,
                        "errors": [
                        ],
                        "lastUpdateTime": "2022-04-19 19:39:14"
                    }
                ]
            }
        ]
    }
}

 

I can also get the list of log files created (log API with GET):

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2'

{
    "logs": [
        {
            "filename": "cfgtoollogs/upgrade/auto/autoupgrade.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/autoupgrade.log"
        },
        {
            "filename": "cfgtoollogs/upgrade/auto/autoupgrade_user.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/autoupgrade_user.log"
        },
        {
            "filename": "cfgtoollogs/upgrade/auto/autoupgrade_err.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/autoupgrade_err.log"
        },
        {
            "filename": "cfgtoollogs/upgrade/auto/status/status.json",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/status/status.json"
        },
        {
            "filename": "cfgtoollogs/upgrade/auto/status/status.html",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/status/status.html"
        },
        {
            "filename": "cfgtoollogs/upgrade/auto/status/status.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/status/status.log"
        },
        {
            "filename": "cfgtoollogs/upgrade/auto/status/progress.json",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/status/progress.json"
        },
        {
            "filename": "UPGR/100/autoupgrade_20220419.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/autoupgrade_20220419.log"
        },
        {
            "filename": "UPGR/100/autoupgrade_20220419_user.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/autoupgrade_20220419_user.log"
        },
        {
            "filename": "UPGR/100/autoupgrade_err.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/autoupgrade_err.log"
        },
        {
            "filename": "UPGR/100/prechecks/prechecks_upgr.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/prechecks/prechecks_upgr.log"
        },
        {
            "filename": "UPGR/100/prechecks/upgr_checklist.xml",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/prechecks/upgr_checklist.xml"
        },
        {
            "filename": "UPGR/100/prechecks/upgr_checklist.json",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/prechecks/upgr_checklist.json"
        },
        {
            "filename": "UPGR/100/prechecks/upgr_preupgrade.html",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/prechecks/upgr_preupgrade.html"
        },
        {
            "filename": "UPGR/100/prechecks/upgrade.xml",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/prechecks/upgrade.xml"
        },
        {
            "filename": "UPGR/100/prechecks/upgr_preupgrade.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/100/prechecks/upgr_preupgrade.log"
        },
        {
            "filename": "UPGR/101/autoupgrade_20220419.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/autoupgrade_20220419.log"
        },
        {
            "filename": "UPGR/101/autoupgrade_20220419_user.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/autoupgrade_20220419_user.log"
        },
        {
            "filename": "UPGR/101/autoupgrade_err.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/autoupgrade_err.log"
        },
        {
            "filename": "UPGR/101/prechecks/prechecks_upgr.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/prechecks/prechecks_upgr.log"
        },
        {
            "filename": "UPGR/101/prechecks/upgr_checklist.xml",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/prechecks/upgr_checklist.xml"
        },
        {
            "filename": "UPGR/101/prechecks/upgr_checklist.json",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/prechecks/upgr_checklist.json"
        },
        {
            "filename": "UPGR/101/prechecks/upgr_preupgrade.html",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/prechecks/upgr_preupgrade.html"
        },
        {
            "filename": "UPGR/101/prechecks/upgrade.xml",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/prechecks/upgrade.xml"
        },
        {
            "filename": "UPGR/101/prechecks/upgr_preupgrade.log",
            "link": "https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=UPGR/101/prechecks/upgr_preupgrade.log"
        }
    ]
}

If we want to get the file contents, we can use the link URL that is provided on the JSON body output:

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/log?taskid=job_2022_04_19_19.07.20.26_2&name=cfgtoollogs/upgrade/auto/status/status.log'

==========================================
          Autoupgrade Summary Report
==========================================
[Date]           Tue Apr 19 19:39:14 CEST 2022
[Number of Jobs] 1
==========================================
[Job ID] 101
==========================================
[DB Name]                UPGR
[Version Before Upgrade] 11.2.0.4.0
[Version After Upgrade]  19.14.0.0.0
------------------------------------------
[Stage Name]    PRECHECKS
[Status]        SUCCESS
[Start Time]    2022-04-19 19:39:08
[Duration]
[Log Directory] /home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2/UPGR/101/prechecks
[Detail]        /home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2/UPGR/101/prechecks/upgr_preupgrade.log
                Check passed and no manual intervention needed
------------------------------------------

Or even open it straight from a browser:

Now that I'm good with the prechecks, I can run my task in deploy mode.

[oracle@hol ~]$ curl -k -X POST 'https://localhost:8443/ords/autoupgrade/task?taskid=job_2022_04_19_19.07.20.26_2&mode=deploy'

{
    "taskid": "job_2022_04_19_19.07.20.26_2",
    "status": "submitted",
    "message": "",
    "link": "https://localhost:8443/ords/autoupgrade/task?taskid=job_2022_04_19_19.07.20.26_2",
    "config": {
        "global": {
            "autoupg_log_dir": "/home/oracle/logs"
        },
        "jobs": [
            {
                "source_home": "/u01/app/oracle/product/11.2.0.4",
                "target_home": "/u01/app/oracle/product/19",
                "sid": "UPGR",
                "log_dir": "/home/oracle/logs",
                "restoration": "no"
            }
        ]
    }
}

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/console?taskid=job_2022_04_19_19.07.20.26_2'

AutoUpgrade is not fully tested on OpenJDK 64-Bit Server VM, Oracle recommends to use Java HotSpot(TM)
AutoUpgrade 22.2.220324 launched with default internal options
Processing config file ...
+--------------------------------+
| Starting AutoUpgrade execution |
+--------------------------------+
1 Non-CDB(s) will be processed
Job 102 database upgr
+----+-------+---------+---------+-------+----------+-------+-------+
|Job#|DB_NAME|    STAGE|OPERATION| STATUS|START_TIME|UPDATED|MESSAGE|
+----+-------+---------+---------+-------+----------+-------+-------+
| 102|   UPGR|PREFIXUPS|EXECUTING|RUNNING|  19:46:33|21s ago|       |
+----+-------+---------+---------+-------+----------+-------+-------+
Total jobs 1

+----+-------+---------+---------+-------+----------+-------+-------+
|Job#|DB_NAME|    STAGE|OPERATION| STATUS|START_TIME|UPDATED|MESSAGE|
+----+-------+---------+---------+-------+----------+-------+-------+
| 102|   UPGR|PREFIXUPS|EXECUTING|RUNNING|  19:46:33|27s ago|       |
+----+-------+---------+---------+-------+----------+-------+-------+
Total jobs 1

+----+-------+---------+---------+-------+----------+-------+-------+
|Job#|DB_NAME|    STAGE|OPERATION| STATUS|START_TIME|UPDATED|MESSAGE|
+----+-------+---------+---------+-------+----------+-------+-------+
| 102|   UPGR|DBUPGRADE|EXECUTING|RUNNING|  19:46:33|12s ago|Running|
+----+-------+---------+---------+-------+----------+-------+-------+
Total jobs 1

+----+-------+---------+---------+-------+----------+-------+-----------+
|Job#|DB_NAME|    STAGE|OPERATION| STATUS|START_TIME|UPDATED|    MESSAGE|
+----+-------+---------+---------+-------+----------+-------+-----------+
| 102|   UPGR|DBUPGRADE|EXECUTING|RUNNING|  19:46:33|15s ago|0%Upgraded |
+----+-------+---------+---------+-------+----------+-------+-----------+
Total jobs 1

If you now connect on the compute with a terminal, you will see that the REST started a AutoUpgrade process:

[oracle@hol ~]$ ps -ef | grep java
oracle    1524 24550  0 19:59 pts/3    00:00:00 grep --color=auto java
oracle   30255 30253  1 19:46 pts/2    00:00:10 /bin/java -jar /home/oracle/AU_REST/autoupgrade.jar -config /home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2/config.cfg -noconsole -mode DEPLOY
[oracle@hol ~]$ cat /home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2/config.cfg
global.autoupg_log_dir=/home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2

job_0.log_dir=/home/oracle/AU_REST/autoupgrade_logs/job_2022_04_19_19.07.20.26_2
job_0.target_home=/u01/app/oracle/product/19
job_0.source_home=/u01/app/oracle/product/11.2.0.4
job_0.restoration=no
job_0.sid=UPGR

 

We can also check the progress of the process (progress API with GET):

[oracle@hol ~]$ curl -k -X GET 'https://localhost:8443/ords/autoupgrade/progress?taskid=job_2022_04_19_19.07.20.26_2'

{
    "taskid": "job_2022_04_19_19.07.20.26_2",
    "status": "successful",
    "message": "",
    "autoupgrade_progress": {
        "totalJobs": 1,
        "totalFinishedJobs": 0,
        "startTime": "2022-04-19 19:46:33",
        "lastUpdateTime": "2022-04-19 19:50:18",
        "jobs": [
            {
                "sid": "UPGR",
                "jobNo": 102,
                "isCDB": false,
                "totalPercentCompleted": 75,
                "totalContainers": 1,
                "totalStages": 8,
                "additionalInfo": "",
                "lastUpdateTime": "2022-04-19 19:50:18",
                "stages": [ ... ],
                "summary": [
                    {
                        "stage": "PREUPGRADE",
                        "complete": "Yes",
                        "duration": "0.038S"
                    },
                    {
                        "stage": "PRECHECKS",
                        "complete": "Yes",
                        "duration": "6.5S"
                    },
                    {
                        "stage": "PREFIXUPS",
                        "complete": "Yes",
                        "duration": "1M0.216S"
                    },
                    {
                        "stage": "DRAIN",
                        "complete": "Yes",
                        "duration": "10.216S"
                    },
                    {
                        "stage": "DBUPGRADE",
                        "complete": "No",
                        "duration": "2M28.395S"
                    }
                ]
            }
        ]
    }
}

 

Postman

One easy way to play and test with REST is using Postman instead of CURL. It provides you with a graphical interface where it is easy to parse the input and output.

Postman is available here. If you use a self-signed certificate in ORDS as I did in this tutorial, you will need to disable the SSL certificate verification: Postman Settings > General > turn OFF SSL certificate verification.

Have you enjoyed? Please leave a comment or give a 👍!

1 comments

    • Hemant on May 25, 2022 at 07:11
    • Reply

    Nice article, if we want to setup this on one server and upgrade multiple databases running on other setvers. What steps do we need to follow

Leave a Reply

Your email address will not be published.