Prerequisites Required for Installing Oracle Database
In this article, I am going to discuss the Prerequisites Required for Installing Oracle Database. Please read our previous article where we discussed the Basic Linux Commands.
Prerequisites For Installing Oracle Database
Until now we learned how to install Virtual Box, and Oracle Linux and learned a few basic Linux commands. Now we are going to learn how to install the oracle database. There are a few prerequisites for installing the oracle database.
Step1: Edit the host file.
The host file is an operating system (computer file) file that maps hostnames to IP addresses. If you need to edit the file you need to log in as root. The order of editing the host is as below
<IP-address> <fully-qualified-machine-name> <machine-name>
You can find the host file in the vi /etc/hosts. Open a terminal. In order to make changes to the host file, you need to log in as root. So, login as root.
After logging as root. So, we need the hostname and the IP address to edit the file. In order to get the hostname, we use the command hostname(oracletest.com).
In order to know the IP address, we use the below command(ifconfig).
Copy the IP address and follow the process. Using the below command you can open the host file.
Command: vi /etc/hosts
Now you are in the hosts file. As usual, we press the Escape button and then go to the end of the last line (second line) and press A (insert mode). The cursor will be prompted to the next line. Paste the IP Address.
Press tab and give the oracletest.com(fully-qualified-machine-name) and tab oracletest (machine name) and save using ESCAPE and enter wq (write and quit). In this step, we are mapping the IP Address with the hostname.
This is the first step we have updated the host file and saved the file.
Step 2: Automatic Setup for Oracle Prerequisite
We need to install packages from oracle before installing the database. There are two types of installing packages.
- Automatic Setup
- Manual Setup
Previously DBAs used to do a lot of work while installing the oracle database. DBAs need to install many packages. In order to avoid this oracle itself created this package which install all the packages to reduce the load on DBAs. Now we are using the automatic setup.
In an Automatic setup, we need to install all the packages. we can run only one command which installs all the packages.
Command: yum install -y oracle-database-preinstall-19c
This package will install all the packages.
Yum is the command that is used to install packages. This command only works in Oracle Linux. If you have Ubuntu Linux it doesn’t work. Paste in a terminal. Make sure we need to connect to the internet during the installation of packages. You can check the below screenshot that my internet connection is Wired connected.
If you are not sure whether the internet is working on your virtual machine or not. Try opening Google Chrome or Mozilla Firefox and check the connectivity once and then try to install the packages. After checking the internet connection. Copy the below command and paste it into the terminal.
Note: This command works only for installing the 19c database. There will be other database versions which will be discussed later. Make sure you are connected as root.
Once you pasted the command press enter and it shows that there is a lot of processing and creation of users.
You can leave it for some time and shows you below that installation of packages is completed.
This command installs a lot of packages, users, and groups related to oracle. To know what all the groups present in the user oracle execute the command id oracle.
The user oracle is in the primary group called oinstall. You can also see the oracle user is part of groups dba, oper, backupdba, dgdba, kmdba, racdba.
Step 3: Create Directories.
We need to create directories. These directories are required while creating the oracle database and installing oracle software. Commands for creating directories:
mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
This is the location where the Oracle software is installed and the database is created.
mkdir -p /u02/oradata
In this location, you can save database files for the oracle database.
chown -R oracle:oinstall /u01/u02
We are changing the owner for the directories /u01, and /u02 to the oracle, and the group owner to oinstall.
chmod -R 775 /u01 /u02
This command is used to change the permission for the directories /u01 /u02 to 775. The digit 775. It has 3 digits, the first digit is for the user owner, the second digit is permission for the group owner, and the third digit is for the permission of all the other users. In this case, we have given 775 so the user can read, write, and execute on /u01 and /u02. The group owner can also read, write, and execute on /u01 /u02. But the other users can only read and execute on /u01 /u02. They cannot write anything in those directories.
Make sure the directories are present in the files.
Step 4: Disable the Firewall
This is the requirement in order to install the oracle database. We are performing this action only for training purposes. In real-time scenarios, we are not supposed to the firewall. We have to stop the firewall to continue to the next process.
systemctl stop firewalld
systemctl disable firewalld
Step 5: Change Password for Oracle
To change the password for user oracle. We use the command passwd.
Even if we get a BAD PASSWORD error that is fine. The password is accepted. From now we need to use the user oracle. Oracle user is the super user for the oracle database. We need to remember the password.
More Information about Prerequisites:
There might be a few people who need to understand more about installing packages of Linux. This information targets those people. We have seen in step 2 that there is a manual setup. We have seen installing packages for the oracle databases through single commands using automatic setup. There is another method of doing the above. We call it a manual setup. Manual setup is where we need to install packages individually.
In the Automatic setup, we used the command yum install -y oracle-database-preinstall-19c. This command is based on a website ORACLE-BASE – Oracle DBA and development articles, scripts, HOWTOs, and forums (8i, 9i, 10g, 11g, 12c, 13c, 18c, 19c, 21c). On this website, there are many other versions other than 19c to download. (https://oracle-base.com)
There is highlighted part 13c,18c,19c,21c. If you click on 19c the article appears which has all the oracle databases configured for oracle Linux versions.
Go ahead and click on oracle database 19c- Installations. You can see the below details. It has different oracle Linux versions but we have the versions till OL8 (Oracle Linux 8).
We will be using Oracle Linux 7 to get the oracle packages installed. In the below image you can two methods Automatic setup and Manual setup.
We have already installed packages through automatic setup. Let’s try to understand how Manual setup works. Below is the command we used for the automatic setup that we performed in step 2.
For manual setup, we can use the below steps.
Step1: Type the command “vi /etc/sysctl.conf”. After opening the file, you need to add the below lines to the sysctl.conf file and save the file.
Step2: After saving the file you need to run the below commands to change the kernel parameters.
Step3: After making changes to kernel parameters you need to execute the below commands individually which installs a lot of packages.
Step4: Finally, you need to add users and groups individually to the Linux. We have seen these groups in id oracle in step 2(automatic setup)
We will try to do some OS Configuration. There are some environmental variables we have to set up in the operating system so that the oracle users can function properly. These variables should be edited in a file called .bash_profile.
What is bash_profile?
Bash_profile is a configuration file that defines tasks that the shell executes for every user who is logged in. Each user in Linux operating system has an individual bash profile. We can write some commands in this bash profile and whenever the user is logged in to the Linux the commands will execute. So, we will create some commands in the bash_profile.
Before doing this, we need to understand some oracle variables. Below are some of the oracle variables.
Note: ORACLE_SID is a unique name for an Oracle database instance on a specific host
- ORACLE_BASE: This specifies the base of the oracle directory. This is the location where the oracle exists and all the oracle folders will be here.
- ORACLE_HOME: This specifies the directory which contains the oracle software. We use this oracle home for the oracle produces. You need to distinguish between the oracle base and the oracle home. The base is the base for oracle. The home is specified for specific product. If you have multiple products, you will have multiple oracle homes present in the oracle base. Directory: $ORACLE_BASE/product/19.0.0/dbhome_1
- ORACLE_SID: This specifies the oracle system identifier. We have used jayadb as oracle sid. ORACLE_SID is the unique name for the oracle database. The database name will represent the oracle_sid.
- ORACLE_UNQNAME: This specifies the operating system environment variable that holds the database’s unique name value i.e jayadb.
Note: In a single instance database all the below names are configured with only one database name.
oracle_sid= instance_name= oracle_unqname=db_name=jayadb
We have a single server machine. We have one database instance connecting to one database. In this case of a single database instance ORACLE_SID=INSTANCE NAME=jayadb. DB_name=ORACLE_UNQNAME=jayadb. In a single instance, configuration keeps the SID, instance name, database name, unqname same as jayadb. We will be discussing this further.
We need to execute the command vi /home/oracle/.bash_profile and need to add parameters. Below are the parameters we need to add to the bash_profile. I am using the same parameters.
Maybe you need to change the hostname and database. We have already discussed ORACLE_SID, ORACLE_BASE, and ORACLE_HOME.ORACLE_UNQNAME, ORACLE_HOSTNAME. Now we have TMP (/tmp). This is the temp directory. We use this to store the temporary files. PATH is used to help Linux to find out where is the exact folder. When we use SQL Plus, we need to enter complete path details.
We need to copy all these commands to the bash profile. Log in to the Linux machine as an oracle user and open the terminal. Paste the below command.
Command: vi /home/oracle/.bash_profile
After clicking enter you will get the bash_profile page. Press the ESCAPE button and then A to edit the bash profile. Go to the end of export PATH. Now paste the above commands mentioned in the box.
Save using the ESCAPE button and wq (write and quit). In order to make these changes effective, we need to log out and log in again as an oracle user. We will find a little example of this. Let us try with echo $ORACLE_HOME. If we execute this command, it will not show any directory. Here is the output.
Now we will log out and log in as an oracle user.
Now let us try to run the same command and see the output.
We have changed the bash_profile. There is one more setting that needs to do. We need to provide access to the shared folder for oracle. Before that let’s try to access the shared folder. It should ask for the password.
You can see it is asking for the password. Because the oracle user doesn’t have permission to access the shared folder. In order to resolve this open terminal. Connect as the root user.
After connecting as root use the following command to give access to the shared folder.
Command: usermod -a -G vboxsf oracle
After executing the commands check whether the group is assigned to the oracle user or not. But you need to log out and log in again to the oracle user to access the shared folder.
Command: id oracle
In the next article, I am going to discuss Downloading and Installing Oracle Database. Here, in this article, I try to explain the Prerequisites Required for Installing Oracle Database and I hope you enjoy this Prerequisite Required for Installing Oracle Database article.
About the Author: Pranaya Rout
Pranaya Rout has published more than 3,000 articles in his 11-year career. Pranaya Rout has very good experience with Microsoft Technologies, Including C#, VB, ASP.NET MVC, ASP.NET Web API, EF, EF Core, ADO.NET, LINQ, SQL Server, MYSQL, Oracle, ASP.NET Core, Cloud Computing, Microservices, Design Patterns and still learning new technologies.