This week we made Arm-based servers available in Oracle Cloud Infrastructure, including a generous free offering with 4 cores and 24 GB of RAM of Ampere A1 Compute as part of our Always Free tier. Todd Sharp wrote a cool blog post showing how to create your own Minecraft Server using one of these Free Tier A1 shapes.
In this blog post I’ll demonstrate how to connect from an A1 shape running Oracle Linux 8 to Autonomous Database two ways:
For these examples, it’s assumed you have the following already running:
Over on the Database blog, Gerald Venzl covered how SQLcl recently became easier to obtain and install. I’ll use some of his techniques to install SQLcl on my Arm-based A1 shape.
Use the OCI console to download the Wallet for your Autonomous Database
Copy the Wallet zip file to your A1 instance
scp -i <path to ssh private key> Wallet_<database name>.zip opc@<public IP address>
As I’m writing this blog post, there isn’t a SQLcl RPM available yet in the yum repositories for aarch64. Not a problem, the latest SQLcl is available under the Oracle Free Use Terms and Conditions license and you can download it using curl. SQLcl connects using the Thin JDBC driver, which is platform-independent and does not require any additional Oracle software on the client-side.
sudo dnf install jdk curl -O https://download.oracle.com/otn_software/java/sqldeveloper/sqlcl-latest.zip unzip sqlcl-latest.zip chmod 755 sqlcl/bin/sql
My Autonomous Database is called testdb, and the wallet I downloaded is Wallet_testdb.zip. The Wallet zip contains a tnsnames.ora that contains several connect descriptors for your Autonomous Database. Here I’m using <database name>_high. I use the set cloudconfig command to point SQLcl to the Wallet zip archive.
sqlcl/bin/sql /nolog set cloudconfig /home/opc/oracle/wallets/testdb/Wallet_testdb.zip Operation is successfully completed. Operation is successfully completed. Using temp directory:/tmp/oracle_cloud_config3986877764276892824 SQL> connect admin@testdb_high Password? (**********?) ************ Connected. SQL> select sysdate from dual; SYSDATE ____________ 27-MAY-21
These are the steps to connect Python 3.8 to Oracle Autonomous Database using the cx_Oracle module. While we offer cx_Oracle RPMs Oracle Linux on x86_64, they aren’t available for aarch64 yet as I’m writing this post. Instead of an RPM-based package, I’m going to use pip to install from PyPi. cx_Oracle depends on Oracle Instant Client, so I install that first.
sudo dnf module install python38 sudo dnf install python38-pip python38-devel python3.8 -m pip install --user cx_Oracle
sudo dnf install oracle-release-el8 sudo dnf install oracle-instantclient19.10-basic
[opc@a1 testdb]$ python3.8 Python 3.8.6 (default, Apr 9 2021, 14:43:42) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1.0.1)] on linux Type "help", "copyright", "credits" or "license" for more information. import cx_Oracle >>> con = cx_Oracle.connect('admin', '<YOUR PASSWORD>', 'testdb_high') >>> print("Database version:", con.version) Database version: 184.108.40.206.0
In this blog post, I explained how to connect from both SQLcl and Python 3.8 on an Arm-based A1 shape running Oracle Linux 8 to Oracle Autonomous Database.