Setup Oracle in Ubuntu 20.04

In this tutorial we will be setting up Oracle on the Ubuntu system. For the tutorial purpose I will be using the Oracle XE 19.3.0 version. The same tutorial should work for any other oracle version as well.

Pre-requisite –

Ubuntu 18.04 +, Git

1. Set up docker on Ubuntu following below instructions.

https://docs.docker.com/engine/install/ubuntu/

2. Use below link to down the Oracle Database files which we will be using later to build the docker Image. A file named LINUX.X64_193000_db_home.zip should be downloaded.

https://www.oracle.com/database/technologies/oracle19c-linux-downloads.html

3. Clone the docker file from the official Oracle repository.

git clone https://github.com/oracle/docker-images.git

4. Copy the downloaded Binary in step 2 to the below folder – images/OracleDatabase/SingleInstance/dockerfiles/19.3.0

5. It should look like this.

6. In the docker files folder you’d find a files named buildContainerImage.sh. Run the shell script with the below command to build the docker image for the specific version of the oracle,

sudo ./buildContainerImage.sh -s -v 19.3.0

7. Try to run below docker images command to check if the image was build successfully.

sudo docker images

 An  Image named oracle/database:19.3.0-se2 will be created as shown in the below image.

8. Prepare a local Directory where we’ll be storing the Oracle Data. Lets create a folder named /opt/myoracle. This folder should be given permission in a way that oracle docker user can read and write from here. You can use chmod 777 on the /opt/myoracle folder. Note that you might have to give this permission to the sub directory as well. You can use chmod -R 777 /opt/myoracle

9. Run below command to start Oracle docker process named myxedb which will be accesible on port 51521. set your password by replacing ORACLE_PWD value.

sudo docker run --name myxedb  -d -p 51521:1521 -p 55500:5500 -e ORACLE_PWD=shashank123 -e ORACLE_CHARACTERSET=AL32UTF8 -v /opt/myoracle/myxedb/oradata:/opt/oracle/oradata -v /opt/myoracle/myxedb/scripts/setup:/opt/oracle/scripts/setup -v /opt/myoracle/myxedb/scripts/startup:/opt/oracle/scripts/startup oracle/database:19.3.0-se2

10. Check Logs to Verify

sudo docker logs --follow myxedb

11. Connect to Docker via bash and use SQL Plus to connect to the Oracle instance.

sudo docker exec -it --user=oracle myxedb bash

run below command inside docker to connect to running Oracle Database. Don’t forget to change your password that you set on 9th step.

sqlplus sys/shashank123@//localhost:1521/ORCLPDB1 as sysdba

You should be able to connect to the Oracle Database now. Do let me know If you’d need some assistance on this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s