Wednesday, May 9, 2018

Oracle-12c quiet installation on Redhat EC2 instance

Oracle-12c quiet installation on Redhat  EC2 instance


This purpose of this document is providing you a quick and easy way to install Oracle 12C without using X-windows.

Prerequisites

  • EC2 instance with Redhat Linux 7.x
  • At least 30 GB of available disk space
  • You need at least 2GB of RAM, so you should use T2.small or bigger.
  • Swap space with size of the RAM
  • Oracle 12c software
  • In this example, we are going to use the following Oracle setting:
  1. ORACL_HOME: /u01/app/oracle/product/12.1.0/db_1
  2. OSDBA group: dba
  3. Global database name:ORAC12C
  4. Database user password: oracle

Installation

Download Oracle 12c software

  • Down load location: https://www.oracle.com/downloads/index.html
  • You need to sign up an Oracle user account first.
  • Please download the standard edition, instruction here use standard edition.

Install needed RPMs on Redhat Linux

  • Enable the RHEL optional and/or extras channels.
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
  • Install need RPMs
# yum install -y \
binutils.x86_64 \
compat-libcap1.x86_64 \
gcc.x86_64 gcc-c++.x86_64 \
glibc.i686 \
glibc.x86_64 \
glibc-devel.i686 glibc-devel.x86_64 \
ksh \
compat-libstdc++-33 \
libaio.i686 libaio.x86_64 \
libaio-devel.i686 libaio-devel.x86_64 \
libgcc.i686 libgcc.x86_64 \
libstdc++.i686 libstdc++.x86_64 \
libstdc++-devel.i686 libstdc++-devel.x86_64 \
libXi.i686 libXi.x86_64 \
libXtst.i686 libXtst.x86_64 \
make.x86_64 \
sysstat.x86_64 \
zip unzip

Setup Oracle User accounts and OS configuration

  • Add the following kernel parameters to /etc/sysctl.conf file.
#
# Configuration for Oracle DB
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 8329226240
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
  • apply the seting
# sysctl -p
# sysctl -a
  • Allow oracle user ID to read /etc/sysctl.conf during installation
chmod 644 /etc/sysctl.conf
  • Set the limits for oracle in /etc/security/limits.conf file.
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
  • Create swap file, the swap file should be bigger or equal to the RAM size
Following example creates a 10G swapfile
dd if=/dev/zero of=/swapfile bs=10M count=1000
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
  • Make swap file at startup
vi /etc/fstab
Add
/swapfile none swap sw 0 0
  • Create the user account and groups for Oracle.
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
  • Create a directory called /stage
mkdir /stage
chown -R oracle:oinstall /stage
  • Create /u01 be for the actual installation, and assign the necessary permissions.# mkdir /u01 # chown oracle:oracle /u01
mkdir /u01
chown -R oracle:oinstall /u01
chmod -R 775 /u01
chmod g+s /u01
  • Sudo as oracle
sudo su - oracle
  • Extract the zipped installation file 
unzip linuxamd64_12102_database_se2_1of2.zip -d /stage/
unzip linuxamd64_12102_database_se2_2of2.zip -d /stage/


EC2 security group

To allow connections from outside the server, you will need to open the following ports with the security group.
1521/TCP
5500/TCP
5520/TCP
3938/TCP

Oracle Quiet Installation

Response files

After unpacking the binary Oracle Database, in the response directory, you will find example response under the database/response directory for installing Oracle software, database creation and listener in silent mode.
These files are:
  • netca.rsp – configure SQL net services
  • db_install.rsp – Install and optionally create a database
  • dbca.rsp – create a database
$ cd /stage/database/response
$ ls
dbca.rsp  db_install.rsp  netca.rsp

Install Oracle

THIS EXAMPLE IS FOR STANDARD EDITION
  • Login to the EC2 instance and sudo as oracle
  • Create a file called db.rsp file under /stage/database/response directory with the following:
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0

oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=ip-10-204-138-18
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/12.1.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=SE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=
oracle.install.db.BACKUPDBA_GROUP=dba
oracle.install.db.DGDBA_GROUP=dba
oracle.install.db.KMDBA_GROUP=dba

### following are optionals
# RAC options
oracle.install.db.rac.configurationType=
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=false
oracle.install.db.racOneServiceName=
oracle.install.db.rac.serverpoolName=
oracle.install.db.rac.serverpoolCardinality=0

# starter database
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.ConfigureAsContainerDB=false
oracle.install.db.config.PDBName=
oracle.install.db.config.starterdb.characterSet=
oracle.install.db.config.starterdb.memoryOption=false
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.password.PDBADMIN=
oracle.install.db.config.starterdb.managementOption=DEFAULT

# cloud options
oracle.install.db.config.starterdb.omsHost=
oracle.install.db.config.starterdb.omsPort=0
oracle.install.db.config.starterdb.emAdminUser=
oracle.install.db.config.starterdb.emAdminPassword=

# startdb options
oracle.install.db.config.starterdb.enableRecovery=false
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=

# asm options
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=

# my oracle support
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
COLLECTOR_SUPPORTHUB_URL=
  • Run the following to install Oracle software
cd /stage/database
./runInstaller -silent -responseFile /stage/database/response/db.rsp
Output of the command:
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 52872 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 9999 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-05-08_01-31-44PM. Please wait ...[oracle@gcc-deploy-uat101 database]$ You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2018-05-08_01-31-44PM.log
If you see any validation failure, fix the problem and re-run the installation.
The installation is runing in the background, the only way to tell if the install completes is tailing the log file.
If everything success, you should see the following in the log file
INFO: Terminating all background operations
INFO: Terminated all background operations
INFO: Successfully executed the flow in SILENT mode
INFO: Dispose the current Session instance
INFO: Dispose the install area control object
INFO: Update the state machine to STATE_CLEAN
INFO: Finding the most appropriate exit status for the current application
INFO: Exit Status is 0
INFO: Shutdown Oracle Database 12c Release 1 Installer
INFO: Unloading Setup Driver
  • After the installation completes, execute the following scripts as root user:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/12.1.0/db_1/root.sh

Setup ~/.bash_profile for oracle user

As the oracle user, edit ~/.bash_profile
export TMP=/tmp
export ORACLE_HOSTNAME=localhost
export ORACLE_UNQNAME=ORA12C
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1
export ORACLE_SID=ORA12C
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export CLASSPATH=ORACLE_HOME/jlib:ORACLE_HOME/rdbms/jlib;
  • source in profile
source ~/.bash_profile
  • Test the Oracle installation. You should able to login with the following commands:
source ~/.bash_profile
sqlplus / as sysdba

Listener quiet installation

There is no need to edit the netca.rsp file, run the following as oracle user to configure the LISTENER with standard settings.
netca -silent -responseFile /stage/database/response/netca.rsp
It should generate something like the following:
Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /stage/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control:
      /u01/app/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
This command will create the listener file /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
  • Finally, replace the localhost with 0.0.0.0 on /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
# vi $ORACLE_HOME/network/admin/listener.ora
From:
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
To
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

Re-start listener

  • Run the following as oracle
lsnrctl stop
lsnrctl start
  • Check the status
lsnrctl status

Quiet database creation

Here I’m going to install a single database instance called ORA12C.
  • Make the directories for data files

su oracle
mkdir /u01/app/oracle/oradata
mkdir /u01/app/oracle/flash_recovery_area
  • Create the database by running the following comand:
dbca \
-silent \
-createDatabase \
-templateName General_Purpose.dbc   \
-gdbName ORA12C \
-pdbadminPassword oracle \
-SysPassword oracle \
-SystemPassword oracle \
-emConfiguration NONE \
-datafileDestination /u01/app/oracle/oradata \
-asmSysPassword oracle \
-characterSet AL32UTF8 \
-totalMemory 1024 \
-recoveryAreaDestination /u01/app/oracle/flash_recovery_area

TOTALMEMORY is In KB , this value can be up to 70% of your total memory.


  • Now execute the below command to create the database.
dbca \
-silent \
-responseFile /ora01/app/oracle/distribs/database/response/dbca.rsp

Test login to database

  • Make sure tnsnames.ora has the right values
$ cat tnsnames.ora
It should has the following:
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORA12C =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORA12C)
    )
  )

LISTENER_ORA12C =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
  • Login to ORA12C database:
 sqlplus system/oracle@ORA12C


Now, you have an Oracle database installed and running.

DB start and stop

Using the dbstart and dbshut command

  • Make sure you have the ORACLE_BASE environment variable set
  • To start Oracle database and listener, run
dbstart $ORACLE_BASE
  • To stop Oracle database and listener, run
dbshut $ORACLE_BASE

Enabling Oracle to Start on System Boot

  • login as root
  • Add the following lines to /etc/systemd/system/oracle-rdbms.service file.
# /etc/systemd/system/oracle-rdbms.service
# Invoking Oracle scripts to start/shutdown Instances defined in /etc/oratab
# and starts Listener
[Unit]
Description=Oracle Database(s) and Listener
Requires=network.target
[Service]
Type=forking
Restart=no
ORACLE_HOME=/u01/app/oracle/product/12.1.0/db_1
ExecStart=$ORACLE_BASE/bin/dbstart $ORACLE_HOME
ExecStop=$ORACLE_BASE/bin/dbshut $ORACLE_HOME
User=oracle
[Install]
WantedBy=multi-user.target
  • Edit /etc/oratab and change the last file "N" to "Y"
ORA12C:/u01/app/oracle/product/12.1.0/db_1:N
To
ORA12C:/u01/app/oracle/product/12.1.0/db_1:Y
  • Eanble oracle to start on boot
systemctl daemon-reload
systemctl enable oracle-rdbms

6 comments:

  1. DevOps technology is designed with combining Development, Best Software Training Institute for DevOps Online Training, Provides DevOps Online Training Course, Classes by Real-Time Experts- Provides DevOps
    Online Training Course, Classes by Real-Time Experts- Naresh IT-Best online training Institute in Hyderabad.

    devops Online Training

    ReplyDelete
  2. This is so helpful!! Thanks for this article - https://www.infosectrain.com

    ReplyDelete
  3. Excellent blog , you touch all point so well .

    ReplyDelete
  4. Nice Post. I like your blog. Thanks for Sharing.
    DevOps Online Training

    ReplyDelete