Skip to content

Execution Steps ADB

Rodrigo Jorge edited this page Nov 9, 2020 · 6 revisions

This document will show how to execute OCI360 once for you tenancy, using an Autonomous Database as the supporting DB. If you want to deploy the tool to automatically create a report every N minutes, please refer to the Installing OCI360 Tool page.

1 - DOWNLOAD LATEST VERSION OF OCI360

Download and unzip the oci360 master repo into your computer:

[oracle@orasrv ~]$ wget -O oci360.zip https://github.com/dbarj/oci360/archive/master.zip
[oracle@orasrv ~]$ sha1sum oci360.zip
eaced7a92f88bfcff4176e6651cb6e556cbe4794  oci360.zip
[oracle@orasrv ~]$ unzip oci360.zip
[oracle@orasrv ~]$ mv oci360-master/ oci360/

2 - CREATE TOOL OUTPUT FOLDER AND DATABASE USER

Connect to your Autonomous Database Instance and create a user for OCI360.

PS: For more information about the required grants, check the DB User Privileges page.

[oracle@orasrv ~]$ mkdir /home/oracle/oci360_out/
[oracle@orasrv ~]$ sqlplus admin/xxx@oci360_medium

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> create user OCI360 identified by "xxx";
SQL> alter user OCI360 default tablespace DATA quota unlimited on DATA;
SQL> grant CREATE SESSION, ALTER SESSION, CREATE SEQUENCE, CREATE TABLE, CREATE VIEW to OCI360;
SQL> grant SELECT on SYS.GV_$INSTANCE to OCI360;
SQL> grant SELECT on SYS.GV_$OSSTAT to OCI360;
SQL> grant SELECT on SYS.GV_$SYSTEM_PARAMETER2 to OCI360;
SQL> grant SELECT on SYS.V_$DATABASE to OCI360;
SQL> grant SELECT on SYS.V_$INSTANCE to OCI360;
SQL> grant SELECT on SYS.V_$PARAMETER to OCI360;
SQL> grant SELECT on SYS.V_$PARAMETER2 to OCI360;
SQL> grant SELECT on SYS.V_$PROCESS to OCI360;
SQL> grant SELECT on SYS.V_$SESSION to OCI360;
SQL> grant SELECT on SYS.V_$SYSTEM_PARAMETER2 to OCI360;
SQL> grant EXECUTE on SYS.DBMS_LOCK to OCI360;
SQL> grant EXECUTE on DBMS_CLOUD to OCI360;
SQL> grant READ on directory DATA_PUMP_DIR to OCI360;

SQL> exit

Now connect to your Autonomous Database Instance with the created user and create a credential to access the bucket.

PS: For more information about this bucket requirement, check the Oracle ADB Page page.

[oracle@orasrv ~]$ sqlplus oci360/xxx@oci360_medium

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL (
  credential_name => 'OCI360_CRED',
  user_ocid       => 'ocid1.user.oc1..xxx',
  tenancy_ocid    => 'ocid1.tenancy.oc1..xxx',
  private_key     => '-----BEGIN RSA PRIVATE KEY-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==
-----END RSA PRIVATE KEY-----',
  fingerprint     => 'aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa');
END;
/

PL/SQL procedure successfully completed.

SQL> exit

3 - GENERATE JSON EXPORT

The steps 1 and 2 just need to be executed once per tenancy. If you want to regenerate your OCI360 output, just consider the steps from here.

Call the JSON exporter tool to export all your tenancy info into a zip file.

[oracle@orasrv ~]$ cd /home/oracle/oci360_out/
[oracle@orasrv oci360_out]$ /home/oracle/oci360/sh/oci_json_export.sh ALL_REGIONS
Starting region sa-saopaulo-1.
Starting region us-ashburn-1.
Starting region ap-sydney-1.
Processing "oci_bv_boot-volume-backup.json" in sa-saopaulo-1.
Processing "oci_bv_boot-volume-backup.json" in us-ashburn-1.
Processing "oci_bv_boot-volume-backup.json" in ap-sydney-1.
Processing "oci_bv_boot-volume-kms-key.json" in us-ashburn-1.
Processing "oci_bv_boot-volume-kms-key.json" in sa-saopaulo-1.
Processing "oci_bv_boot-volume-kms-key.json" in ap-sydney-1.
Processing "oci_bv_boot-volume.json" in sa-saopaulo-1.
...
[oracle@orasrv oci360_out]$ ls -l
total 252
-rw-r--r--. 1 oracle oinstall 67200 Dec 31 14:35 oci_json_export_20191231130255_ap-sydney-1.zip
-rw-r--r--. 1 oracle oinstall 87269 Dec 31 14:39 oci_json_export_20191231130255_sa-saopaulo-1.zip
-rw-r--r--. 1 oracle oinstall 84418 Dec 31 14:45 oci_json_export_20191231130255_us-ashburn-1.zip

PS 1: oci_json_export tool is hosted at https://github.com/dbarj/oci-scripts. The step-by-step instructions of how to run it is available at https://www.dbarj.com.br/en/2018/10/howto-backup-oracle-cloud-infrastructure-metadata/.

PS 2: If the export is taking too much time on a given object type, you can skip it using exporting OCI_JSON_EXCLUDE variable.

4 - MERGE THE OUTPUT FILE IF MULTIPLE REGIONS

This step is only valid if you are subscribed to multiple regions and the command above generated multiple zip files (one per region).

The merger shell-script will concatenate all of them into a single zip. In the example below, I'm concatenating 3 region zips in a single file:

[oracle@orasrv ~]$ cd /home/oracle/oci360_out/
[oracle@orasrv oci360_out]$ /home/oracle/oci360/sh/oci_json_merger.sh "oci_json_export_20191231130255_*.zip" oci_json_export_20191231130255.zip
[oracle@orasrv oci360_out]$ ls -l
total 364
-rw-r--r--. 1 oracle oinstall 123250 Dec 31 14:54 oci_json_export_20191231130255.zip
-rw-r--r--. 1 oracle oinstall  67200 Dec 31 14:35 oci_json_export_20191231130255_ap-sydney-1.zip
-rw-r--r--. 1 oracle oinstall  87269 Dec 31 14:39 oci_json_export_20191231130255_sa-saopaulo-1.zip
-rw-r--r--. 1 oracle oinstall  84418 Dec 31 14:45 oci_json_export_20191231130255_us-ashburn-1.zip
[oracle@orasrv oci360_out]$ rm -f oci_json_export_20191231130255_*.zip
[oracle@orasrv oci360_out]$ ls -l
total 124
-rw-r--r--. 1 oracle oinstall 123250 Dec 31 14:54 oci_json_export_20191231130255.zip

5 - OPTIONAL (USAGE AND AUDIT INFO)

If you want to add Usage and/or Audit info from your tenancy into OCI360, before going to the final phase, please follow the steps:

6 - UPLOAD THE ZIP FILE INTO THE OCI BUCKET

This step will upload all the files generated within the zip file above into the Obejct Storage Bucket, in order to be read by the ADB.

[oracle@orasrv ~]$ cd /home/oracle/oci360_out/
[oracle@orasrv oci360_out]$ export OCI_UP_GZIP=1
[oracle@orasrv oci360_out]$ /home/oracle/oci360/sh/oci_bucket_upload.sh oci360 oci_json_export_20191231130255.zip
Checking if bucket is accessible.
Uploading ZIP files..
Unzipping and gziping "oci_bv_boot-volume.json".
Unzipping and gziping "oci_bv_volume-backup-policy.json".
Unzipping and gziping "oci_bv_volume.json".
Unzipping and gziping "oci_compute_boot-volume-attachment.json".
...

Andi if you also executed the optional "Cost and Usage" step:

[oracle@orasrv ~]$ cd /home/oracle/oci360_out/
[oracle@orasrv oci360_out]$ export OCI_UP_GZIP=1
[oracle@orasrv oci360_out]$ /home/oracle/oci360/sh/oci_bucket_upload.sh oci360 oci_csv_usage_20200630030208.zip
Checking if bucket is accessible.
Uploading ZIP files..
Unzipping "reports_cost-csv_0001000000025575.csv.gz".
Archive:  /home/oracle/oci360_out/oci_csv_usage_20200630030208.zip
 extracting: /tmp/.oci/tmp.uc3DAqrSi2/reports_cost-csv_0001000000025575.csv.gz
Unzipping "reports_cost-csv_0001000000026343.csv.gz".
Archive:  /home/oracle/oci360_out/oci_csv_usage_20200630030208.zip
 extracting: /tmp/.oci/tmp.uc3DAqrSi2/reports_cost-csv_0001000000026343.csv.gz
...

7 - RUN OCI360

Finally call OCI360:

[oracle@orasrv ~]$ cd /home/oracle/oci360/
[oracle@orasrv oci360]$ sqlplus oci360/xxx@oci360_medium

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> DEF moat369_pre_sw_output_fdr = '/home/oracle/oci360_out/'
SQL> DEF oci360_adb_cred = 'OCI360_CRED'
SQL> DEF oci360_adb_uri  = 'https://objectstorage.us-ashburn-1.oraclecloud.com/n/xxx/b/oci360/o/'
SQL> @oci360.sql
Wrote file original_settings

Getting JSON Files
Please wait ...

...
...
"End oci360. Output: /home/oracle/oci360_out/oci360_20200104_2042.zip"
Disconnected from Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
[oracle@orasrv oci360]$

PS: For more information about DEFINE variables that can change the script behaviour, check the Control Variables page.

8 - DOWNLOAD, UNZIP AND OPEN THE OCI360 OUTPUT FILE

  • Download and Unzip output oci360_YYYYMMDD_HH24MI.zip into a directory on your PC
  • Review main html file 00001_oci360_index.html