Troubleshoot Vagrant with OEM Database Express!
Everyone loves Vagrant! The official documentation from Vagrant states:
Vagrant is designed for everyone as the easiest and fastest way to create a virtualized environment!
However in a headless environment, there are no GUI tools, and so there can be less visibility of what’s happening inside your Vagrant virtual machine.
Fortunately, the Vagrant boxes from Oracle allow client tools to access a running virtual machine via port forwarding.
The following ports are forwarded from the Oracle 19.3c Vagrant file:
# Oracle port forwarding
config.vm.network "forwarded_port", guest: 1521, host: 1521
config.vm.network "forwarded_port", guest: 5500, host: 5500
The Vagrant file already does forward some ports, but there are some extra steps that need to be done, and those are in the documentation:
In summary, to complete the connectivity between the client and the virtual machine follow the steps below.
After the virtual machine has been started via Vagrant, we need to log in to the database:
[vagrant@oracle-19c-vagrant ~]$ sudo su - oracle
Last login: Sun Feb 23 20:34:27 +08 2020 on pts/0
[oracle@oracle-19c-vagrant ~]$ sqlplus / as sysdbaSQL*Plus: Release 19.0.0.0.0 - Production on Mon Feb 24 19:19:47 2020
Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle. All rights reserved.Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0SQL>
The next step is to enable XDB as follows:
SQL> alter session set container=CDB$ROOT;Session altered.SQL> exec dbms_xdb_config.setglobalportenabled(TRUE);PL/SQL procedure successfully completed.SQL> select dbms_xdb_config.gethttpsport() from dual;DBMS_XDB_CONFIG.GETHTTPSPORT()
------------------------------
5500SQL> exit
So the database will use port 5500, which is perfect as Vagrant has already forwarded port 5500 in the startup phase.
Now need to ensure that the Oracle listener of the virtual machine is running.
[oracle@oracle-19c-vagrant ~]$ lsnrctl startLSNRCTL for Linux: Version 19.0.0.0.0 - Production on 23-FEB-2020 12:27:59Copyright (c) 1991, 2019, Oracle. All rights reserved.Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/oracle-19c-vagrant/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 23-FEB-2020 12:28:01
Uptime 0 days 0 hr. 0 min. 1 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/oracle-19c-vagrant/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully[oracle@oracle-19c-vagrant ~]$
After the listener has been started, so wait up to half a minute for the database to register services with the listener.
[oracle@oracle-19c-vagrant ~]$ lsnrctl statusLSNRCTL for Linux: Version 19.0.0.0.0 - Production on 23-FEB-2020 12:28:52Copyright (c) 1991, 2019, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 23-FEB-2020 12:28:01
Uptime 0 days 0 hr. 0 min. 53 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/oracle-19c-vagrant/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=oracle-19c-vagrant)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/admin/ORCLCDB/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "990bbc30667422cde0530100007faa37" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "ORCLCDB" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "ORCLCDBXDB" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "orclpdb1" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
The command completed successfully[oracle@oracle-19c-vagrant ~]$
So services have been registered with the listener, which means we are ready for business.
From any internet browser on the local host use the following URL to navigate to port 5500.
https://127.0.0.1:5500/em/shell
Initially the browser will warn that the site is not secure.
Confirm that you want to proceed anyway, and you’ll get the OEM Database Express page.
The Vagrant box for Oracle 19.3c is a containerised database, so after the login credentials, enter the container name as cdb$root.
Then you’ll be presented with the OEM Database Express front page.
There are few GUI tools more suited to Vagrant than OEM Database Express!
Paul Guerin is an international consultant that specialises in Oracle database. Paul is based from a global delivery center in South East Asia, but has clients from Australia, Europe, Asia, and North America. Moreover, he has presented at some of the world’s leading Oracle conferences, including Oracle Open World 2013. Since 2015, his work has been featured in the IOUG Best Practices Tip Booklet, and in publications from AUSOUG, Oracle Technology Network, and Oracle Developers (Medium). In 2019, he was awarded as a most valued contributor for the My Oracle Support Community. He is a DBA OCP, and continues to be a participant of the Oracle ACE program.