Tuesday, September 19, 2017

Oracle Database 12c Release 2 (12.2) Installation On Oracle Linux 6


Host-name: el6.example.com
IP-address: 1.0.5.5

sources:
https://docs.oracle.com/database/122/LADBI/toc.htm
https://oracle-base.com/articles/12c/oracle-db-12cr2-installation-on-oracle-linux-6-and-7
https://oracle-base.com/articles/12c/multitenant-startup-and-shutdown-cdb-and-pdb-12cr1
http://dbaora.com/install-oracle-12c-12-1-0-1-on-oel6/

- Software Download:
https://edelivery.oracle.com

- OS Installation:
https://docs.oracle.com/cd/E37670_01/E41137/html/
https://oracle-base.com/articles/linux/oracle-linux-6-installation

- Network settings
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=1.0.5.5
NETMASK=255.255.255.0
GATEWAY=1.0.5.2
USERCTL=no

# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=el6.example.com
NETWORKING_IPV6=no
NOZEROCONF=yes

- SSH Login
$ ssh -X root@1.0.5.5 # (-X to enable remote graphics)
$ touch  ~/.Xauthority #(if not existed)

- Edit /etc/hosts file 
# vi /etc/hosts
1.0.5.5    el6.example.com     el6

and edit /etc/hostname file:
# vi /etc/hostname
el6.example.com

- Change kernel parameters 
# vi /etc/sysctl.conf
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500

applying kernel new parameters 
# /sbin/sysctl -p

- Change OS resources limits 
# vi /etc/security/limits.conf
oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    16384
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768
oracle   hard   memlock    134217728
oracle   soft   memlock    134217728

and this file too.
# vi /etc/pam.d/login
session    required     pam_limits.so

Amend the "/etc/security/limits.d/90-nproc.conf" file as described below
# vi /etc/security/limits.d/90-nproc.conf

Change this
*          soft    nproc    1024

To this
* - nproc 16384

- Create local yum repo from OL6 iso 
# mkdir /media/cdrom
# mount /dev/sr0 /media/cdrom
# vi /etc/yum.repo.d/dvd.repo
[dvd]
name=dvd-OL6.9x64
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0

- Install required packages for both 64bit & 32bit architect
# yum install -y binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33.i686 glibc glibc.i686 glibc-devel glibc-devel.i686 ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libX11 libX11.i686 libXau libXau.i686 libXi libXi.i686 libXtst libXtst.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel libstdc++-devel.i686 libxcb libxcb.i686 make nfs-utils net-tools smartmontools sysstat unixODBC unixODBC-devel e2fsprogs e2fsprogs-libs libs libxcb.i686 libxcb

- Create new groups & users
# groupadd -g 54321 oinstall
# groupadd -g 54322 dba
# groupadd -g 54323 oper
# groupadd -g 54324 backupdba
# groupadd -g 54325 dgdba
# groupadd -g 54326 kmdba
# groupadd -g 54327 asmdba
# groupadd -g 54328 asmoper
# groupadd -g 54329 asmadmin

# useradd -g oinstall -G dba,oper oracle
# passwd oracle

- Edit SELinux settings for installation
# vi /etc/selinux/config
SELINUX=permissive
# setenforce permissive
# getenforce 
Permissive

- Disable firewalld 
# service iptables stop
# chkconfig iptables off

- Create Oracle software installation directories 
# mkdir -p /u01/app/oracle/product/12.2.0/db_1
# chown -R oracle:oinstall /u01
# chmod -R 775 /u01

- Edit oracle user profile file 
# vi /home/oracle/.bash_profile
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=el6.example.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=cdb1; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1; export ORACLE_HOME
ORACLE_SID=cdb1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

- Unpack files into Virtualbox guest and start installer 
if you make shared folder named oracle in your host machine with software source files and guest additions in installed guest machine
# usermod -aG vboxsf oracle # add oracle user to vboxsf to list shared folders
# su - oracle
$ cd /media/sf_oracle/
$ unzip linuxx64_12201_database -d /tmp
$ /tmp/database/runInstaller &

- Post Installation
Edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.
# vi /etc/oratab
cdb1:/u01/app/oracle/product/12.2.0/db_1:Y

- Shutdown pluggable database:The ALTER PLUGGABLE DATABASE command can be used from the CDB or the PDB.


ALTER PLUGGABLE DATABASE pdb1, pdb2 OPEN READ ONLY FORCE;
ALTER PLUGGABLE DATABASE pdb1, pdb2 CLOSE IMMEDIATE;

ALTER PLUGGABLE DATABASE ALL OPEN;
ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;

ALTER PLUGGABLE DATABASE ALL EXCEPT pdb1 OPEN;
ALTER PLUGGABLE DATABASE ALL EXCEPT pdb1 CLOSE IMMEDIATE;

- Pluggable Database (PDB) Automatic Startup, to automatically start PDB's when the CDB is started. The way to achieve this is to use a system trigger on the CDB to start some or all of the PDBs.

CREATE OR REPLACE TRIGGER open_pdbs 
  AFTER STARTUP ON DATABASE 
BEGIN 
   EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN'; 
END open_pdbs;
/

- Query pluggable databases 

SELECT name, open_mode FROM v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           READ WRITE
PDB2                           READ WRITE

-Shutdown & Startup database (this file assume that you set oracle variables on .bash_profile file.)
- to start oracle database and listener
$ vi startdb.sh
#!/bin/bash
echo "Startup Oracle Database"
sqlplus / as sysdba << EOI
startup
EOI
echo "start LISTENER"
lsnrctl start
echo "############### welcome back ##############"

$ chmod +x startdb.sh
$ ./startdb.sh # to startup Database

- to shutdown oracle database and listener
$ vi stopdb.sh
#!/bin/bash
echo "shutdown Oracle Database"
sqlplus / as sysdba << EOI
shutdown immediate
EOI
echo "stop LISTENER"
lsnrctl stop
echo "############### BYE BYE ##############"

$ chmod +x stopdb.sh
$ ./stopdb.sh # to shutdown Database 

- SQL PLUS format 
# rpm -Uvh http://linuxdownload.adobe.com/linux/x86_64//flash-player-npapi-27.0.0.130-release.x86_64.rpm
#  rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64//rlwrap-0.42-1.el6.x86_64.rpm
$ echo "alias sqlplus='rlwrap sqlplus' " >> /home/oracle/.bash_profile

$ vi $ORACLE_HOME/sqlplus/admin/glogin.sql
SET SERVEROUTPUT ON
SET HEADING ON
SET ECHO ON
SET PAGESIZE 50000
SET PAGES 0
SET LINESIZE 80
DEFINE _EDITOR = gedit
SET COLSEP "|"
SET CONCAT "."
SET CONCAT "!"
SET NEWPAGE NONE
SET TAB OFF
SET NULL **NULL**


- Enterprise Manager Express for pluggable database(ex. pdb1): 

 $ sqlplus / as sysdba

SQL> alter session set container=PDB1;
SQL> exec DBMS_XDB_CONFIG.SETHTTPSPORT(5502);

To access EM Express for a non-CDB, CDB, or PDB, enter a URL in the following format in a Web browser, specifying the EM Express port number for the non-CDB, CDB, or PDB you want to manage:

https://el6.example.com:5502/em/







No comments:

Post a Comment