Total Pageviews

Tuesday, September 10, 2019

Oracle 18c XE installtion on AWS EC2 Server


Installation of Oracle 18c XE on  on AWS
                               (RPM based installation on CentOS)

Step 1) Download the rpm from oracle site on your local machine.

For example I have downloaded the rpm from oracle site to my local drive G:\ Oracle_AWS

I am using Cygwin tool for connecting the EC2 machine. You can download the setup from https://www.cygwin.com/ .You can also use putty for same purpose.

Open the Cygwin terminal and use below command to SCP the downloaded rmp file to AWS EC2     machine. Below command will copy the rpm file (oracle-database-xe-18c-1.0-1.x86_64.rpm) from local location G:\ Oracle_AWS to to EC2 machine  /tmp location.
Note: ec2-13-233-153-8.ap-south-1.compute.amazonaws.com is an endpoint and it varies machine to machine please change according to your EC2 Operating Machine.

Step 2) SCP the rpm from local machine to EC2.

scp -i "xeserver.pem" /cygdrive/g/Oracle_AWS/oracle-database-xe-18c-1.0-1.x86_64.rpm centos@ec2-13-233-153-8.ap-south-1.compute.amazonaws.com:/tmp

Where, xeserver.pem is a key for connecting the EC2 machine. Keep this file at location G:\
Centos is a user Centos server. For REHL servers you have to use ec2-user instead of Centos.

[root@ip-172-31-15-9 tmp]# ls -lrth
total 2.4G
-rwxrwx---. 1 centos centos 2.4G Sep  6 13:49 oracle-database-xe-18c-1.0-1.x86_64.rpm

Step 3) Download the Oracle Database Preinstall RPM via. The process of doing so is using curl.
As a root user run below command:

[root@ip-172-31-15-9]#cd /tmp

[root@ip-172-31-15-9 tmp]# curl -o oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

Now you can see two files at /tmp location:

[root@ip-172-31-15-9 tmp]# ls -lrth
total 2.4G
-rwxrwx---. 1 centos centos 2.4G Sep  6 13:49 oracle-database-xe-18c-1.0-1.x86_64.rpm
-rw-r--r--. 1 root   root      18K Sep  6 14:07  oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm



Step 4) So to enable Red Hat's/Centos Extras and Optional repos, you would then run the following:

[root@ip-172-31-15-9]# sudo su - oracle

yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional


Step 5) Run the below command to install both the rpm in one go:

[root@ip-172-31-15-9 tmp]# yum -y localinstall oracle-database*18c*

The above command will check all the dependencies and download the all the stuff for you.

Step 6) Create database:
By now oracle home is installed now it’s time to create the database.

If we create the database directly using command /etc/sysconfig/oracle-xe-18c.conf
this will use all default location for database creation. Let’s modified few parameters before proceeding with database creation step.

[root@ip-172-31-15-9]# mkdir -p /u01/app/oracle/oradata
[root@ip-172-31-15-9]# chown -R oracle:oinstall /u01/app
[root@ip-172-31-15-9]# cd /etc/sysconfig

Make the changes to file /etc/sysconfig/oracle-xe-18c.conf as highlighted in yellow.

[root@ip-172-31-15-9 tmp]#vi /etc/sysconfig/oracle-xe-18c.conf

#This is a configuration file to setup the Oracle Database.
#It is used when running '/etc/init.d/oracle-xe-18c configure'.

# LISTENER PORT used Database listener, Leave empty for automatic port assignment
LISTENER_PORT=1521

# EM_EXPRESS_PORT Oracle EM Express URL port
EM_EXPRESS_PORT=5500

# Character set of the database
CHARSET=AL32UTF8

# Database file directory
# If not specified, database files are stored under Oracle base/oradata
DBFILE_DEST=/u01/app/oracle/oradata

# SKIP Validations, memory, space
SKIP_VALIDATIONS=false

Save the file by pressing Esc + Esc wq!

Execute the below command to start the database creation.

[root@ip-172-31-15-9 tmp]#/etc/init.d/oracle-xe-18c configure

Provide the password for SYS User:

[root@ip-172-31-15-9 tmp]# /etc/init.d/oracle-xe-18c configure
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password:
********
Enter SYSTEM user password:
********
Enter PDBADMIN User Password:
**********
Prepare for db operation
7% complete
Copying database files
29% complete
Creating and starting Oracle instance
30% complete
31% complete
34% complete
38% complete
41% complete
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.
Connect to Oracle Database using one of the connect strings:
     Pluggable database: ip-172-31-15-9.ap-south-1.compute.internal/XEPDB1
     Multitenant container database: ip-172-31-15-9.ap-south-1.compute.internal
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE


If you don’t want to create database as container. Make changes to parameter export CREATE_AS_CDB=false under the file /etc/init.d/oracle-xe-18c
Now login to database:

-bash-4.2$ . oraenv
ORACLE_SID = [oracle] ? XE
The Oracle base has been set to /opt/oracle
-bash-4.2$
-bash-4.2$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Mon Sep 9 13:08:47 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
XE        READ WRITE

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/XE/system01.dbf
/u01/app/oracle/oradata/XE/sysaux01.dbf
/u01/app/oracle/oradata/XE/undotbs01.dbf
/u01/app/oracle/oradata/XE/pdbseed/system01.dbf
/u01/app/oracle/oradata/XE/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/XE/users01.dbf
/u01/app/oracle/oradata/XE/pdbseed/undotbs01.dbf
/u01/app/oracle/oradata/XE/XEPDB1/system01.dbf
/u01/app/oracle/oradata/XE/XEPDB1/sysaux01.dbf
/u01/app/oracle/oradata/XE/XEPDB1/undotbs01.dbf
/u01/app/oracle/oradata/XE/XEPDB1/users01.dbf

11 rows selected.

SQL>