One of the nice features of Oracle Cloud is that it comes with some additional command-line tooling in the form of the dbaascli command.
When you run this command (while logged into your DBaaS instance) you’ll see
[oracle@DEMO ~]# dbaascli DBAAS CLI version 1.0.0 DBAAS>
This dumps you into an interactive shell, typing ‘help’ gives us a bit more info.
DBAAS>help Help for dbaascli dbaascli is a command line interface for different tools to be used with Oracle Cloud DB. This command line interface supports logging, command history and autocomplete. Logging is done on a session level. Each time dbaascli is run the last log is overwritten. To access command history use the up/down arrow keys as you would normally do in a terminal. Autocomplete uses the Tab key. Autocomplete will complete to the longest common string in case there is not an exact match. To obtain help on a command use the help keyword at the begining or end. Autocomplete is supported if the first word is the "help" keyword. Special commands are available. The list of special commands is: -H -HELP ? - Get dbaascli help CLEAR - Clear the screen HELP - Get dbaascli help HIST - Print command line history HISTORY - Print command line history LIST - List available commands Q - Exit Command Line Interface QUIT - Exit Command Line Interface DBAAS>
Note – you can also run the command non-interactively by specifying the options on the command-line.
So, let’s list the commands available.
DBAAS>list Very Long Text, press q to quit Available commands: database bounce database changepassword database start database status database stop dataguard failover dataguard reinstate dataguard status dataguard switchover dbpatchm dv off dv off cdb dv off pdb dv on dv on cdb dv on pdb gg setup gg status glassfish start glassfish status glassfish stop listener bounce listener start listener status listener stop mrec netsec config netsec config encryption netsec config integrity netsec deconfig netsec deconfig encryption netsec deconfig integrity netsec status netsec status encryption netsec status integrity ore setup orec tde config tde rotate tde rotate masterkey tde status tfa install tfa uninstall DBAAS>
Most of these commands are wrappers around other commands but it does give you one “go-to” centralised command which is consistent across all your DBaaS instances rather than trying to remember each command (and perhaps having to deal with different configurations).
So let’s try a few commands, this time I’ll run them non-interactively (type ‘quit’ to exit the interactive version).
Let’s check the database status
[oracle@DEMO ~]$ dbaascli database status DBAAS CLI version 1.0.0 Executing command database status Database Status: Database is open Database name: ORCL Oracle Database 12c EE Extreme Perf Release 22.214.171.124.0 - 64bit Production PL/SQL Release 126.96.36.199.0 - Production CORE 188.8.131.52.0 Production TNS for Linux: Version 184.108.40.206.0 - Production NLSRTL Version 220.127.116.11.0 - Production
You could leverage this script to perhaps grep for the phrase ‘Database is open’ to check for problems.
We could also do the commands
dbaascli database bounce dbaascli database start dbaascli database stop
Lets check Glassfish
[oracle@DEMO ~]$ dbaascli glassfish status DBAAS CLI version 1.0.0 Executing command glassfish status Unable to run command. This command should be run as user: root. Currently: oracle
Hmmm ok, so depending on the command we need to run it as different users, lets switch to root and try it again
[root@DEMO ~]# dbaascli glassfish status DBAAS CLI version 1.0.0 Executing command glassfish status Calculating the status and metrics: Authentication failed for user: admin with password from password file: /root/statuspwd.txt (Usually, this means invalid user name and/or password) Authentication failed for user: admin with password from password file: /root/statuspwd.txt (Usually, this means invalid user name and/or password) domain1 running Command list-domains executed successfully. Command list-http-listeners failed. Command uptime failed.
Notice the error message stating it’s reading the /root/statuspwd.txt file to get the password. Once I entered the password there and re-ran the command worked (I’ll omit the output here as it’s quite lengthy).
Let’s check the listener
[root@DEMO ~]# dbaascli listener status DBAAS CLI version 1.0.0 Executing command listener status Invalid parameter(s) Command Error Command: listener status Listener Status
Ok, this is getting annoying, maybe I need to be the oracle user for this one?
[root@DEMO ~]# su - oracle [oracle@DEMO ~]$ dbaascli listener status DBAAS CLI version 1.0.0 Executing command listener status Starting listener LSNRCTL for Linux: Version 18.104.22.168.0 - Production on 13-MAY-2016 13:15:50 Copyright (c) 1991, 2014, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DEMO.compute-ae.oraclecloud.internal)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 22.214.171.124.0 - Production Start Date 4-JAN-2015 23:52:34 Uptime 1 days 13 hr. 23 min. 15 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/DEMO/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEMO.compute-ae.oraclecloud.internal)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=DEMO.compute-ae.oraclecloud.internal)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.1.0/dbhome_1/admin/ORCL/xdb_wa llet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "ORCL.ae.oraclecloud.internal" has 1 instance(s). Instance "ORCL", status READY, has 1 handler(s) for this service... Service "ORCLXDB.ae.oraclecloud.internal" has 1 instance(s). Instance "ORCL", status READY, has 1 handler(s) for this service... Service "pdb1.ae.oraclecloud.internal" has 1 instance(s). Instance "ORCL", status READY, has 1 handler(s) for this service... The command completed successfully
So that worked, obviously the output is quite lengthy, but again you could see how this simple command could be used in a monitoring script.
Command Specific Help
If you’re unsure what a particular command might do, rather than risking running it, you can get some help on each command. For example what does that mrec command do?
[oracle@DEMO ~]$ dbaascli mrec help DBAAS CLI version 1.0.0 Executing command mrec help Command: mrec Help for MREC tool. Parameters: --args Format: Not defined Required: NO Usage: mrec --args -oss_cfgfile <cfgfile> -old_hostname <vm_name> mrec --args -oss_cfgfile <cfgfile> -old_hostname <vm_name> -sid <oracle_sid> Where: -help = Print this help. -oss_cfgfile = full path to OSS config file. -old_hostname = Name of the host to recover. -sid = ORACLE SID of the DB instance to recover. Default is orcl Examples: mrec --args -oss_cfgfile /var/opt/oracle/mrec/oss.cfg -old_hostname vmprod01 mrec --args -oss_cfgfile /var/opt/oracle/mrec/oss.cfg -old_hostname vmprod01 -sid orcl
Ok, so it doesn’t tell me what it actually does (I had to search the documentation to figure out MREC = Media Recovery), but it does at least tell you what parameters it expects.