How to set up Oracle Database 23c — Developer Release and ORDS on OCI
Let’s take a look at the newest release of Oracle Database, and how to set it up on a Compute instance running Oracle Linux 8
For the first time in the history of Oracle, the next version of Oracle Database is available to developers first, for free and before it is generally available as a commercial version.
This easy to download, install and run data-driven apps on developer release is jam-packed with new developer features.
While in this article we’ll be focusing on installing on OCI, you can also get Oracle Database 23c — Developer Release as a container image or a VM. Be sure to check out the link below if you’re interested in any of these options:
Installing Oracle Database 23c — Developer Release
Let’s start off by taking a look at how we can install Oracle Database 23c on an existing Compute instance, and access it from our local machine.
- Create a new Compute instance using the image of your preference. In this article, we will be using an instance running Oracle Linux 8 as an example. Note that ARM architecture is not supported in this release.
- Connect to your Compute instance using SSH.
- Use
sudo
to log in asroot
.
$ sudo su -
- Enable the Oracle Linux 8 Developer channel.
# dnf config-manager --set-enabled ol8_developer
- Run the Oracle Database Preinstallation RPM.
# dnf -y install oracle-database-preinstall-23c
- Access the Oracle Database Free software download page.
Download theoracle-database-free-23c-1.0-1.el8.x86_64.rpm
RPM file required for performing an RPM-based installation to a directory of your choice.
# wget https://download.oracle.com/otn-pub/otn_software/db-free/oracle-database-free-23c-1.0-1.el8.x86_64.rpm
- Install the database software.
# dnf -y localinstall oracle-database-free-23c-1.0-1.el8.x86_64.rpm
Creating and Configuring an Oracle Database 23c Free — Developer Release
The configuration script creates a container database (FREE
) with one pluggable database (FREEPDB1
) and configures the listener at the default port (1521).
You can modify the configuration parameters by editing the /etc/sysconfig/oracle-free–23c.conf
file.
The parameters set in this file are explained in detail in the silent mode installation procedure: Performing a Silent Installation.
To create the database with the default settings:
- Log in as
root
usingsudo
.
$ sudo su -
- Run the service configuration script:
# /etc/init.d/oracle-free-23c configure
- At the command prompt, specify a password for the
SYS
,SYSTEM
, andPDBADMIN
administrative user accounts.
Oracle recommends that your password should be at least 8 characters in length, contain at least 1 upper case character, 1 lower case character and, 1 digit [0-9]. - Add the environment variables to the bash_profile. For the default settings:
# Oracle Database environment variables
export ORACLE_SID=FREE
export ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree
export ORAENV_ASK=NO
export PATH=$ORACLE_HOME/bin:$PATH
Connecting to Oracle Database 23c Free — Developer Release
Let’s see how we can connect to our newly created database using sqlplus or a programming language.
SQL Connect string
[username]@[hostname]:[port]/[DB service name] [as sysdba]
- To connect to the first Pluggable Database (PDB) use:
$ sqlplus sys@localhost:1521/FREEPDB1 as sysdba
- To connect to the Container Database (CDB) use:
$ sqlplus sys@localhost:1521/FREE as sysdba
Java
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@localhost:1521/FREEPDB1"); // jdbc:oracle:thin@[hostname]:[port]/[DB service name]
ods.setUser("[Username]");
ods.setPassword("[Password]");
Connection conn = ods.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT 'Hello World!' FROM dual");
ResultSet rslt = stmt.executeQuery();
while (rslt.next()) {
System.out.println(rslt.getString(1));
}
Python
import oracledb
conn = oracledb.connect(user="[Username]", password="[Password]", dsn="localhost:1521/FREEPDB1")
with conn.cursor() as cur:
cur.execute("SELECT 'Hello World!' FROM dual")
res = cur.fetchall()
print(res)
Node.js
const oracledb = require('oracledb');
async function run() {
let connection = await oracledb.getConnection({
user : "[Username]",
password : "[Password]",
connectString : "localhost:1521/FREEPDB1" // [hostname]:[port]/[DB service name]
});
let result = await connection.execute( "SELECT 'Hello World!' FROM dual");
console.log(result.rows[0]);
}
run();
Installing and enabling ORDS for Oracle Database 23c Free — Developer Release
Now let’s see how we can install and enable Oracle REST Data Services for our newly created database.
ORDS is published in OL7 and OL8 repositories. Since we enabled the repo earlier, we can simply install ORDS using yum
or dnf
.
$ sudo su -
# dnf -y install ords
The preceding command handles all the ORDS dependencies and place the ORDS program in /usr/local/bin/ords
folder to set up your ORDS configuration and install or upgrade ORDS in the database.
Oracle recommends you to use /etc/ords/conf
configuration directory. The following comand is used to configure ORDS:
# ords --config /etc/ords/config install
If you want to use a different directory to place your ORDS configurations and you want to use the Linux system service management as system d or system v, then configure the ORDS config
directory in /etc/ords.conf
folder.
- Start the ORDS daemon
# /etc/init.d/ords start
Allowing access to Oracle Database 23c Free — Developer Release and ORDS from a local machine
In order to be able to access our Oracle Database instance as well as the ORDS services, we need to make two easy configurations, assuming your Compute instance has a public IP.
- Allow access to the Database and ORDS ports in the Security List of the subnet attached to the Compute instance. Create an Ingress Rule for each of the ports (default 1521 for Oracle Database and 8080 for ORDS).
You may want to restrict the Ingress Rule so that only specific IP addresses are allowed access.
- Open the two ports in the Oracle Linux firewall daemon
$ sudo su -
# firewall-cmd --permanent --zone=public --add-port=1521/tcp
# firewall-cmd --permanent --zone=public --add-port=8080/tcp
# firewall-cmd --reload
Now you will be able to use the Compute instance’s IP address and the two ports to access the services.