Oracle, Oracle Database March 15, 2014 13

Installing Oracle Database 12c R1 on Linux 6 with ASM

database-12cIn previous article we covered operating system installation: Installing Oracle Linux 6 and preparing for Oracle Software installations. It is a prerequisite for this tutorial. In this tutorial we will use this OS as a seed for our Oracle Database 12c installation.

Oracle Database 12c introduces a new multi-tenant architecture that makes it easy to deploy and manage database clouds. For more information please visit Oracle Website.

This tutorial is for educational purposes only.

Installation plan:

  1. Cloning Oracle Enterprise Linux form a seed
  2. Creating virtual hard disks for ASM
  3. Altering network configuration and hostname on Linux server
  4. Setting up environment variables for OS accounts: grid and oracle
  5. Installing Oracle ASM packages
  6. Creating ASM disk volumes
  7. Downloading and installing Oracle Grid Infrastructure software
  8. Creating ASM disk groups
  9. Installing Oracle database software
  10. Creating Oracle database instance with multi-tenant database
  11. Connecting to container database CDB and pluggable database PDB
  12. Patching a database – System Patch Update – 12.1.0.1.2

Let’s roll…

First let’s clone our seed virtual image and create a new server, next we will alter it’s IP address and hostname and eventually we will create virtual disks to simulate ASM storage.

1. Cloning virtual host from a seed

Cloning a host in Oracle VirtualBox is an easy task and involves the fallowing steps:

2. Creating virtual disks to simulate ASM storage disks

Automatic Storage Management (ASM) is a feature that has be introduced in Oracle 10g to simplify the storage of Oracle datafiles, controlfiles, logfiles and backups.

 We create 3 virtual disks CRSDISK1 (2GB), DATADISK1(50GB) & FRADISK1(50GB). These disk will be dynamically allocated types, which means it will not allocate entire 2/50/50GB of the physical disk space at the moment of creation, but will extend according to virtual host demand.

1. CRSDISK1 (2GB) – for CRSVOL1 asm volume – CRS asm disk group, where Cluster Ready Services (CRS) files are stored. CRS provides many system management services and interacts with the vendor clusterware to coordinate cluster membership information.

2. DATADISK1 (50GB) – disk for DATAVOL1 asm volume – DATA asm disk group. Here database will keep all datafiles, control files, log files …

3. FRADISK1 (50GB) – disk for FRAVOL1 asm volume – FRA asm disk group, for database Fast Recovery Area (FRA) files. For example: database backup files, copy of database control files.

3. Altering network configuration and hostname on Linux server

  • Power up virtual machine and connect to server (for example using putty)

TIP: To power up virtual machine you may use VirtualBox GUI or the following command;

user@host:~$ VBoxManage startvm <VM_NAME> --type headless

neo@zion:~$ VBoxManage startvm DB_12c_ZEUS --type headless

Our new OS has seed’s IP (192.168.2.130) and hostname (demo) settings. Let’s alter it.

  • Login to OS and and edit “/etc/sysconfig/network” as root user
#Change HOSTNAME 
NETWORKING=yes
HOSTNAME=zeus
GATEWAY=192.168.2.1
  • Update /etc/hosts file:

Make sure that hosts file have right entries (remove or comment out lines with ipv6), make sure there is correct IP and hostname, edit /etc/hosts as root:

127.0.0.1       localhost.localdomain  localhost
192.168.2.120   zeus.zion.local    zeus
  • Alter HWADDR and IP address, edit /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
#HWADDR=00:33:E1:44:FA:D8# comment out or remove this line
IPADDR=192.168.2.120
PREFIX=24
GATEWAY=192.168.2.1
DNS1=198.43.12.22
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
ONBOOT=yes

Reboot the server to apply changes.

4. Setting up environment variables for OS accounts: grid and oracle

  • Login to system as a regular user and sudo to “oracle” account,
[neo@zion ~]$ su – oracle
[oracle@zion ~]$ cp ~/.bash_profile ~/.bash_profile_bkp 
[oracle@zion ~]$ echo > ~/.bash_profile 
[oracle@zion ~]$ vi ~/.bash_profile
  • paste below code to /home/oracle/.bash_profile file
# ---------------------------------------------------
# .bash_profile
# ---------------------------------------------------
# OS User: oracle
# Application: Oracle Database Software Owner
# Version: Oracle 12c Release 1
# ---------------------------------------------------
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# ---------------------------------------------------
# ORACLE_SID
# ---------------------------------------------------
# Specifies the Oracle system identifier (SID)
ORACLE_SID=ZIONDB; export ORACLE_SID
# ---------------------------------------------------
# ORACLE_UNQNAME
# ---------------------------------------------------
# Set ORACLE_UNQNAME equal to the database unique
# name.
# ---------------------------------------------------
ORACLE_UNQNAME=ZIONDB; export ORACLE_UNQNAME
# ---------------------------------------------------
# JAVA_HOME
# ---------------------------------------------------
JAVA_HOME=/usr/bin/java; export JAVA_HOME
# ---------------------------------------------------
# ORACLE_BASE
# ---------------------------------------------------
# Specifies the base of the Oracle directory structure
# for Optimal Flexible Architecture (OFA) compliant
# database software installations.
# ---------------------------------------------------
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
# ---------------------------------------------------
# ORACLE_HOME
# ---------------------------------------------------
# Directory containing the Oracle Database software.
# ---------------------------------------------------
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1; 
export ORACLE_HOME
# ---------------------------------------------------
# ORACLE_TERM
# ---------------------------------------------------
# Defines a terminal definition. If not set, it
# defaults to the value of your TERM environment
# variable. Used by all character mode products.
# ---------------------------------------------------
ORACLE_TERM=xterm; export ORACLE_TERM
# ---------------------------------------------------
# NLS_DATE_FORMAT
# ---------------------------------------------------
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"
export NLS_DATE_FORMAT
# ---------------------------------------------------
# TNS_ADMIN
# ---------------------------------------------------
# Specifies the directory containing the Oracle Net
# Services configuration files like listener.ora,
# tnsnames.ora, and sqlnet.ora.
# ---------------------------------------------------
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
# ---------------------------------------------------
# PATH
# ---------------------------------------------------
# Used by the shell to locate executable programs;
# must include the $ORACLE_HOME/bin directory.
# ---------------------------------------------------
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
export PATH
# ---------------------------------------------------
# LD_LIBRARY_PATH
# ---------------------------------------------------
# Specifies the list of directories that the shared
# library loader searches to locate shared object
# libraries at runtime.
# ---------------------------------------------------
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
# ---------------------------------------------------
# CLASSPATH
# ---------------------------------------------------
# Specifies the directory or list of directories that
# contain compiled Java classes.
# ---------------------------------------------------
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
# ---------------------------------------------------
# THREADS_FLAG
# ---------------------------------------------------
# All the tools in the JDK use green threads as a
# default. To specify that native threads should be
# used, set the THREADS_FLAG environment variable to
# "native". You can revert to the use of green
# threads by setting THREADS_FLAG to the value
# "green".
# ---------------------------------------------------
THREADS_FLAG=native; export THREADS_FLAG
# ---------------------------------------------------
# TEMP, TMP, and TMPDIR
# ---------------------------------------------------
export TEMP=/tmp
export TMPDIR=/tmp
# ---------------------------------------------------
# UMASK
# ---------------------------------------------------
# Set the default file mode creation mask
# (umask) to 022 to ensure that the user performing
# the Oracle software installation creates files
# with 644 permissions.
# ---------------------------------------------------
umask 022
  • Login to system as a regular user and sudo to “grid” account,
[oracle@zeus ~]$ logout
[neo@zeus ~]$ sudo su - grid
[sudo] password for neo:
[grid@zeus ~]$ cp ~/.bash_profile ~/.bash_profile_bkp 
[grid@zeus ~]$ echo > ~/.bash_profile 
[grid@zeus ~]$ vi ~/.bash_profile
  • Paste below code to /home/grid/.bash_profile file
# ---------------------------------------------------
# .bash_profile
# ---------------------------------------------------
# OS User: grid
# Application: Oracle Grid Infrastructure
# Version: Oracle 12c Release 1
# ---------------------------------------------------
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# ---------------------------------------------------
# ORACLE_SID
# ---------------------------------------------------
# Specifies the Oracle system identifier (SID)
# for the Automatic Storage Management (ASM)instance
# running on this node.
# ---------------------------------------------------
ORACLE_SID=+ASM; export ORACLE_SID
# ---------------------------------------------------
# JAVA_HOME
# ---------------------------------------------------
# Specifies the directory of the Java SDK and Runtime
# Environment.
# ---------------------------------------------------
JAVA_HOME=/usr/bin/java; export JAVA_HOME
# ---------------------------------------------------
# ORACLE_BASE
# ---------------------------------------------------
# Specifies the base of the Oracle directory structure
# for Optimal Flexible Architecture (OFA) compliant
# installations. The Oracle base directory for the
# grid installation owner is the location where
# diagnostic and administrative logs, and other logs
# associated with Oracle ASM and Oracle Clusterware
# are stored.
# ---------------------------------------------------
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
# ---------------------------------------------------
# ORACLE_HOME
# ---------------------------------------------------
# Specifies the directory containing the Oracle
# Grid Infrastructure software. For grid
# infrastructure for a cluster installations, the Grid
# home must not be placed under one of the Oracle base
# directories, or under Oracle home directories of
# Oracle Database installation owners, or in the home
# directory of an installation owner. During
# installation, ownership of the path to the Grid
# home is changed to root. This change causes
# permission errors for other installations.
# ---------------------------------------------------
ORACLE_HOME=/u01/app/12.1.0/grid; export ORACLE_HOME
# ---------------------------------------------------
# ORACLE_TERM
# ---------------------------------------------------
ORACLE_TERM=xterm; export ORACLE_TERM
# ---------------------------------------------------
# TNS_ADMIN
# ---------------------------------------------------
# Specifies the directory containing the Oracle Net
# Services configuration files like listener.ora,
# tnsnames.ora, and sqlnet.ora.
# ---------------------------------------------------
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
# ---------------------------------------------------
# PATH
# ---------------------------------------------------
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
export PATH
# ---------------------------------------------------
# TEMP, TMP, and TMPDIR
export TEMP=/tmp
export TMPDIR=/tmp
# ---------------------------------------------------
# UMASK
# ---------------------------------------------------
umask 022
  • Create Oracle software home directories:
[root@zion ~]# 
mkdir -p /u01/app/oracle 
mkdir -p /u01/app/grid
mkdir -p /u01/app/12.1.0/grid

chown -R grid:oinstall /u01
chown oracle:oinstall /u01/app/oracle

chmod -R 775 /u01

Set Resource Limits for the Oracle Software Installation Users

To improve the performance of the software on Linux systems, you must increase the following resource limits for the Oracle software owner users ( grid). For oracle user it has been automatically setup by the oracle-rdbms-server-11gR2-preinstall package. To apply these settings, run the following as root:

  • Add the following lines to the /etc/security/limits.conf file (the following example is for grid account):
#as root
[root@test-host ~]# cat >> /etc/security/limits.conf <<EOF 
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
EOF
  •  Add or edit the following line in the /etc/pam.d/login file, if it does not exist:
[root@test-host ~]# cat >> /etc/pam.d/login <<EOF  
session required pam_limits.so  
EOF

Depending on your shell environment, make the following changes to the default shell startup file, to change ulimit setting for all Oracle installation owners (note that these examples show the users oracle and grid):

  • For the Bourne, Bash, or Korn shell, add the following lines to the /etc/profile file by running the following command:
[root@test-host ~]# cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ] || [ \$USER = "grid" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
  • For the C shell (csh or tcsh), add the following lines to the /etc/csh.login file by running the following command:
[root@test-host ~]# cat >> /etc/csh.login <<EOF 
if ( \$USER == "oracle" || \$USER == "grid" )
 then
 limit maxproc 16384
 limit descriptors 65536
endif
EOF

 5. Installing Oracle ASM packages

Oracle Linux is up and running. Now we check whether oracleasm package is installed:

[root@zeus ~]# rpm -qa | grep oracleasm
oracleasm-support-2.1.8-1.el6.x86_64
[root@zeus ~]#

As we see, oracleasm-support package has been installed when we were building our seed OS Linux 6.

  • NOTE: The oracleasm kernel driver is built into the Unbreakable Enterprise Kernel for Oracle Linux 6 and does not need to be installed manually.

Installing Oracle ASMLib package is still required though.

Getting Oracle ASMLib via the Unbreakable Linux Network (Subscription required)

Non-subscribers are free to use the similar package built for RHEL on their Enterprise Linux machines.

Go to Oracle Technology Network and download oracleasmlib package for  RHEL6 (64bit)

  • copy package to oracle server to /tmp directory and install it as root:
[root@zeus ~]# rpm -Uvh /tmp/oracleasmlib-2.0.4-1.el6.x86_64.rpm
warning: oracleasmlib-2.0.4-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                ########################################### [100%]
   1:oracleasmlib           ########################################### [100%]
  • Configuring and load the ASM kernel module (as root user).
[root@zeus ~]# oracleasm configure -i
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting <ENTER> without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
[root@zeus ~]#

The script completes the following tasks:

  • Creates the /etc/sysconfig/oracleasm configuration file
  • Creates the /dev/oracleasm mount point
  • Mounts the ASMLib driver file system

Enter the following command to load the oracleasm kernel module:

[root@zeus ~]# /usr/sbin/oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module "oracleasm": oracleasm
Configuring "oracleasm" to use device physical block size
Mounting ASMlib driver filesystem: /dev/oracleasm
[root@zeus ~]#

6. Creating ASM disk volumes

Let’s check the available disks in OS (remember, we have created three additional disks for ASM in our virtual system)

[root@zeus ~]# fdisk -l | grep "Disk /dev/sd"
Disk /dev/sda: 32.2 GB, 32212254720 bytes ##This is our system disk
Disk /dev/sdb: 2147 MB, 2147483648 bytes
Disk /dev/sdc: 53.7 GB, 53687091200 bytes
Disk /dev/sdd: 53.7 GB, 53687091200 bytes
[root@zeus ~]#

We see three disks available for ASM disks:

  • Disk /dev/sdb: 2147 MB
  • Disk /dev/sdc: 53.7 GB
  • Disk /dev/sdd: 53.7 GB

First, new partitions have to be created to be able to use those disks as ASM disks;

  • Disk /dev/sdb (hit: n, p, 1, ENTER, ENTER, w – to apply changes)
[root@zeus ~]# fdisk /dev/sdb

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): <ENTER>
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261): <ENTER>
Using default value 261

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
  •  Disks: /dev/sdb
[root@zeus ~]# fdisk /dev/sdc

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6527, default 1): <ENTER>
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527): <ENTER>
Using default value 6527

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
  • Repeat the same action for disk:  /dev/sdd (fdisk /dev/sdd)

System restart is not required, however after so many changes we may reboot it .

Here is the final output:

[root@zeus ~]# fdisk -l | grep "/dev/s"
Disk /dev/sda: 32.2 GB, 32212254720 bytes # SYSTEM DISK
/dev/sda1   *           1          64      512000   83  Linux
/dev/sda2              64        3917    30944256   8e  Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes
/dev/sdb1               1         261     2096451   83  Linux

Disk /dev/sdc: 53.7 GB, 53687091200 bytes
/dev/sdc1               1        6527    52428096   83  Linux

Disk /dev/sdd: 53.7 GB, 53687091200 bytes
/dev/sdd1               1        6527    52428096   83  Linux

We observe new partitions:

  • Disk /dev/sdb1: 2147MB –> reserved for CRSVOL1
  • Disk /dev/sdc1: 53.7 GB –> reserved for DATAVOL1
  • Disk /dev/sdd1: 53.7 GB –> reserved for FRAVOL1

Creating ASM disks:

[root@zeus ~]# oracleasm createdisk CRSVOL1 /dev/sdb1
Writing disk header: done
Instantiating disk: done

[root@zeus ~]# oracleasm createdisk DATAVOL1 /dev/sdc1
Writing disk header: done
Instantiating disk: done

[root@zeus ~]# oracleasm createdisk FRAVOL1 /dev/sdd1
Writing disk header: done
Instantiating disk: done

#Listing ASM disks:
[root@zeus ~]# oracleasm listdisks
CRSVOL1
DATAVOL1
FRAVOL1
[root@zeus ~]#
  •  Test disks discovery 
[root@zeus ~]# oracleasm-discover
Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
[ASM Library - Generic Linux, version 2.0.4 (KABI_V2)]
Discovered disk: ORCL:CRSVOL1 [4192902 blocks (2146765824 bytes), maxio 256]
Discovered disk: ORCL:DATAVOL1 [104856192 blocks (53686370304 bytes), maxio 256]
Discovered disk: ORCL:FRAVOL1 [104856192 blocks (53686370304 bytes), maxio 256]
[root@zeus ~]#

7. Downloading and installing Oracle Grid Infrastructure software

You would have to download Oracle Database 12c Release 1 Grid Infrastructure (12.1.0.1.0) for Linux x86-64 – here

  • Copy zip files to oracle server to /tmp directory using WinSCP (here’s how, Point 3)
  • Run Xming (on desktop) to be able to run GUI Oracle Installer (here’s how, Point 2.)
  • login as a regular user, use putty with X11 forwarding enabled (here is how Point 5.)

NOTE: At this point we have to switch to “grid” account to run grid installation. However password still remains unknown. We use sudo command to switch from a regular account (neo) to grid, and then xauth command to set our session cookies for X11 forwarding to work, here is how:

[neo@zeus ~]$ xauth list
zeus.zion.local/unix:10  MIT-MAGIC-COOKIE-1  879d14bbe3076bc698ec35a1b40cf710

[neo@zeus ~]$ sudo su - grid
[sudo] password for neo:

#Add magic cookie to our grid session
[grid@zeus ~]$ xauth add zeus.zion.local/unix:10  MIT-MAGIC-COOKIE-1  879d14bbe3076bc698ec35a1b40cf710
xauth:  creating new authority file /home/grid/.Xauthority

[grid@zeus ~]$ export DISPLAY=localhost:10.0
[grid@zeus ~]$
  • next, unzip zip packages to /home/grid/stage directory and run the Oracle Universal Installer:
[grid@zeus ~]$ for i in /tmp/linuxamd64_12c_grid_*.zip; do unzip $i -d /home/grid/stage; done

[grid@zeus ~]$ cd /home/grid/stage/grid
[grid@zeus]$ ./runInstaller 
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB.   Actual 21921 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3967 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2099-01-12_10-39-91PM. Please wait ...

Oracle Universal Installer is starting…

  • After successful installation we should see ASM instance processes running:
[grid@zeus ~]$ ps -ef | grep grid
grid      4444     1  0 Mar12 ?        00:00:00 /u01/app/12.1.0/grid/bin/tns.
grid      4598     1  0 Mar12 ?        00:00:50 /u01/app/12.1.0/grid/bin/css.
grid      4612     1  0 Mar12 ?        00:00:08 /u01/app/12.1.0/grid/bin/o..
grid      4728     1  0 Mar12 ?        00:00:20 asm_pmon_+ASM
grid      4730     1  0 Mar12 ?        00:00:15 asm_psp0_+ASM
grid      4732     1  4 Mar12 ?        00:32:06 asm_vktm_+ASM
grid      4736     1  0 Mar12 ?        00:00:03 asm_gen0_+ASM
grid      4738     1  0 Mar12 ?        00:00:02 asm_mman_+ASM
grid      4742     1  0 Mar12 ?        00:00:05 asm_diag_+ASM
grid      4744     1  0 Mar12 ?        00:00:59 asm_dia0_+ASM
grid      4746     1  0 Mar12 ?        00:00:02 asm_dbw0_+ASM
grid      4748     1  0 Mar12 ?        00:00:02 asm_lgwr_+ASM
grid      4750     1  0 Mar12 ?        00:00:06 asm_ckpt_+ASM
grid      4752     1  0 Mar12 ?        00:00:02 asm_smon_+ASM
grid      4754     1  0 Mar12 ?        00:00:02 asm_lreg_+ASM
grid      4756     1  0 Mar12 ?        00:00:11 asm_rbal_+ASM
grid      4758     1  0 Mar12 ?        00:00:19 asm_gmon_+ASM
grid      4760     1  0 Mar12 ?        00:00:08 asm_mmon_+ASM
grid      4762     1  0 Mar12 ?        00:00:14 asm_mmnl_+ASM
grid      4775     1  0 Mar12 ?        00:00:00 oracle+ASM (DESCRIPTION=
grid     25183     1  0 Mar12 ?        00:01:40 /u01/app/12.1.0/grid/bin...
grid     25288     1  0 Mar12 ?        00:07:12 /u01/app/12.1.0/grid/bin...
grid     25300     1  0 Mar12 ?        00:00:02 /u01/app/12.1.0/grid/bin...
grid     25327 25300  0 Mar12 ?        00:00:00 /u01/app/12.1.0/grid/bin/ev
  •  we can also check the status running crsctl tool
[grid@zeus ~]$ crsctl status resource -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.CRS.dg
               ONLINE  ONLINE       zeus                     STABLE
ora.DATA.dg
               ONLINE  ONLINE       zeus                     STABLE
ora.FRA.dg
               ONLINE  ONLINE       zeus                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       zeus                     STABLE
ora.asm
               ONLINE  ONLINE       zeus                     Started,STABLE
ora.ons
               OFFLINE OFFLINE      zeus                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       zeus                     STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       zeus                     STABLE
ora.ziondb.db
      1        ONLINE  ONLINE       zeus                     Open,STABLE
--------------------------------------------------------------------------------
[grid@zeus ~]$

8. Creating ASM disk groups

Next we create ASM disk groups for Oracle Database (later seen as +DATA and +FRA).

[grid@zeus ~]$ asmca &

 ASM Configuration Assistant is starting…

9. Installing Oracle database software

At this point, we are ready to get started with Oracle Database installation. First we are going to install Oracle Database software only.

Download Oracle Database software installation packages from Oracle Technology Network

Oracle Database 12c Release 1 (12.1.0.1.0) for Linux x86-64

  • Download linuxamd64_12c_database_1of2.zip
  • Download linuxamd64_12c_database_2of2.zip

Copy zip files to oracle server /tmp directory and login to server as a regular user, switch to an oracle account and set magic cookies for your session:

[neo@zeus ~]$ xauth list
zeus.zion.local/unix:10  MIT-MAGIC-COOKIE-1  a8ca3289a167d700f1cc2877fa63fd81
[neo@zeus ~]$ sudo su - oracle
[sudo] password for neo:

[oracle@zeus ~]$ xauth add zeus.zion.local/unix:10  MIT-MAGIC-COOKIE-1  a8ca3289a167d700f1cc2877fa63fd81
xauth:  creating new authority file /home/oracle/.Xauthority

[oracle@zeus ~]$ xauth list
zeus.zion.local/unix:10  MIT-MAGIC-COOKIE-1  a8ca3289a167d700f1cc2877fa63fd81
[oracle@zeus ~]$ export DISPLAY=localhost:10.0
[oracle@zeus ~]$
  • Unzip Oracle Database Software installation packages and run the Oracle Universal Installer as an oracle user:
[oracle@zeus ~]$ for i in /tmp/linuxamd64_12c_database_*.zip; do unzip $i -d /home/oracle/stage; done

[oracle@zeus ~]$ cd /home/oracle/stage/database/
[oracle@zeus database]$ ./runInstaller

Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB.   Actual 16180 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3966 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2044-33-21_11-81-55AM. Please wait ...

 10. Creating Oracle database instance with multi-tenant database

  • First we configure dedicated listener “LISTENER_ZIONDB”, running netca (Oracle Net Services Configuration)
[oracle@zeus ~]$ netca &
  • Run dbca (Database Creation Assistant) as an oracle user to create a database
[oracle@zeus ]$ dbca &

Hint: Place control files on ASM disks +DATA and +FRA. Initialization parameters section.

("+DATA/{DB_UNIQUE_NAME}/control01.ctl", "+FRA/{DB_UNIQUE_NAME}/control02.ctl")

Our database is up and running!

We have just created our multitenant container database (CDB) – ZIONDB and first pluggable database (PDB): PDB01

We can now login to Enterprise Manager Database Express 12c

  • URL: https://database_host:5500/em

If you are facing error: “Security token does not match. You must login again…”

2014-03-14_001758

You may try using Internet Explorer or Firefox, should work.

More information – intro to Oracle Database 12c: EM Database Express:

http://www.oracle.com/technetwork/database/manageability/emx-intro-1965965.html

11. Connecting to container database CDB and pluggable database PDB

  • Login to database host and switch to oracle account, run sqlplus
[neo@zeus ~]$ sudo su - oracle
[sudo] password for neo: 

[oracle@zeus ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Mar 14 17:32:42 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> select name from v$database;

NAME
---------
ZIONDB

--Switching between containers

SQL> COLUMN name FORMAT A25
SQL> SELECT name, pdb FROM   v$services ORDER BY name; 

NAME			  PDB
------------------------- ------------------------------
SYS$BACKGROUND		  CDB$ROOT
SYS$USERS		  CDB$ROOT
ZIONDBXDB		  CDB$ROOT
pdb01.zion.local	  PDB01
ziondb.zion.local	  CDB$ROOT

SQL> SHOW CON_NAME

CON_NAME
------------------------------
CDB$ROOT

SQL> ALTER SESSION SET container = PDB01;
Session altered.

SQL> show con_name

CON_NAME
------------------------------
PDB01

SQL> exit;
  •  Connecting to Oracle Database 12c – Oracle SQL Developer:

Tutorial: Managing Pluggable Databases (PDBs) Oracle SQL Developer

UPDATE: 12. Patching a database – System Patch Update – 12.1.0.1.2

Prerequisites:

1. Download and install latest Java SE Development Kit  on your database host.

As root user:

rpm -Uvh /u01/app/stage/java/jdk-7u51-linux-x64.rpm

2. update OPatch to the latest version: Patch # 6880880 (select platform Linux-x86-64)

If Oracle is running with ASM copy new version of OPatch to ORACLE_HOME of grid and oracle users.

3. Patch database (Patch available at Oracle Support)

We will run commands as a grid and root user, we apply GRID INFRASTRUCTURE SYSTEM PATCH 12.1.0.1.2.

  • A database with ASM (our option):

Patch 17735306: GRID INFRASTRUCTURE SYSTEM PATCH 12.1.0.1.2 – This patch will patch your grid and database homes.

  • Database without ASM / Grid Infra installed:

Patch 17552800: DATABASE PATCH SET UPDATE 12.1.0.1.2

Let’s patch:

  • Create a ocm response file ($/u01/app/12.1.0/grid/OPatch/ocm/bin/emocmrsp)
export JAVA_HOME=/usr/java/latest/
cd $ORACLE_HOME/OPatch/ocm/bin/
./emocmrsp -no_banner -output /u01/app/oraInventory/ocm.rsp
  • close all pluggable databases:
[oracle@zeus ~]$ sqlplus / as sysdba

SQL> alter pluggable database all close;
  • Unzip the patch as grid home owner.
$ unzip p17735306_121010_Linux-x86-64.zip -d /u01/app/stage

The Opatch utility has automated the patch application for the Oracle Grid Infrastructure (GI) home and the Oracle RAC database homes. It operates by querying existing configurations and automating the steps required for patching each Oracle RAC database home of same version and the GI home.

The utility must be executed by an operating system (OS) user with root privileges, and it must be executed on each node in the cluster if the GI home or Oracle RAC database home is in non-shared storage.

  • Apply a system patch. As root user, execute the following command
$ sudo su -
# export PATH=$PATH:/u01/app/12.1.0/grid/OPatch
# opatchauto apply /u01/app/stage/17735306 -ocmrf /u01/app/oraInventory/ocm.rsp

OPatch Automation Tool
Copyright (c) 2013, Oracle Corporation.  All rights reserved.
OPatchauto version : 12.1.0.1.2
OUI version        : 12.1.0.1.0
Running from       : /u01/app/12.1.0/grid
opatchauto log file: /u01/app/12.1.0/grid/cfgtoollogs/opatchauto/17735306/opatch_gi_2066-01-01_00-54-38_deploy.log
Parameter Validation: Successful
...

Apply Summary:
Following patch(es) are successfully installed:
GI Home: /u01/app/12.1.0/grid: 17077442, 17303297, 17552800
RAC Home: /u01/app/oracle/product/12.1.0/db_1: 17077442, 17552800

opatchauto succeeded.
  • Open pluggable databases
[oracle@zeus OPatch]$ sqlplus / as sysdba

SQL> alter pluggable database all open;

UPDATE:

Patch 18705901(Linux x86-64): GRID INFRASTRUCTURE SYSTEM PATCH 12.1.0.1.4 is available.

Download Patch from Oracle Support and upload on database host.

  • Unzip the patch as grid home owner.
$ unzip p18705901_121010_Linux-x86-64.zip -d /u01/app/stage
  • Run OPatch in analyze mode first to determine conflicting patches
$ opatchauto apply /u01/app/stage/18705901/ -ocmrf /u01/app/oraInventory/ocm.rsp -analyze

If there is no one-off patches which needs to be rollback, continue and  apply the patch.

  • Apply patch. As a root user, execute the following commands
$ sudo su -
[root@zeus stage]$ export PATH=$PATH:/u01/app/12.1.0/grid/OPatch
[root@zeus stage]$ opatchauto apply /u01/app/stage/18705901/ -ocmrf /u01/app/oraInventory/ocm.rsp
OPatch Automation Tool
Copyright (c) 2013, Oracle Corporation.  All rights reserved.

OPatchauto version : 12.1.0.1.2
OUI version        : 12.1.0.1.0
Running from       : /u01/app/12.1.0/grid
...
Parameter Validation: Successful

Grid Infrastructure home:
/u01/app/12.1.0/grid
RAC home(s):
/u01/app/oracle/product/12.1.0/db_1

Configuration Validation: Successful

Patch Location: /u01/app/stage/18705901
Grid Infrastructure Patch(es): 17077442 17303297 18522516
RAC Patch(es): 17077442 18522516

Patch Validation: Successful

Stopping RAC (/u01/app/oracle/product/12.1.0/db_1) ... Successful
Following database(s) were stopped and will be restarted later during the session: ziondb

Applying patch(es) to "/u01/app/oracle/product/12.1.0/db_1" ...
Patch "/u01/app/stage/18705901/17077442" applied to "/u01/app/oracle/product/12.1.0/db_1" with warning.
Patch "/u01/app/stage/18705901/18522516" applied to "/u01/app/oracle/product/12.1.0/db_1" with warning.

Stopping CRS ... Successful

Applying patch(es) to "/u01/app/12.1.0/grid" ...
Patch "/u01/app/stage/18705901/17077442" applied to "/u01/app/12.1.0/grid" with warning.
Patch "/u01/app/stage/18705901/17303297" applied to "/u01/app/12.1.0/grid" with warning.
Patch "/u01/app/stage/18705901/18522516" applied to "/u01/app/12.1.0/grid" with warning.

Starting CRS ... Successful

Starting RAC (/u01/app/oracle/product/12.1.0/db_1) ... Successful

Apply Summary:

opatchauto ran into some warnings during patch installation (Please see log file for details):
GI Home: /u01/app/12.1.0/grid: 17077442, 17303297, 18522516
RAC Home: /u01/app/oracle/product/12.1.0/db_1: 17077442, 18522516

opatchauto succeeded.

Execute patch post-installation steps:

NOTE: It is recommended the Post Install step be run on all pluggable databases; however, the following command (SQL> alter pluggable database PDB_NAME open ) could be substituted to only open certain PDBs in the multitenant database. Doing so will result in the Post Install step only being run on the CDB and opened PDB’s. To update a pluggable database at a later date (skipped or newly plugged in), open the database using the alter pluggable database command mentioned previously and rerun the datapatch utility.

  • Run the Datapatch Utility for Multitenant (CDB/PDB)
[oracle@zeus ~]$ sqlplus / as sysdba

SQL> alter pluggable database all open;
SQL> quit
[oracle@zeus ~]$ cd $ORACLE_HOME/OPatch
[oracle@zeus OPatch]$ ./datapatch -verbose

SQL Patching tool version 12.1.0.1.0 on Thu Jul 31 11:20:07 2014
Copyright (c) 2014, Oracle.  All rights reserved.

Connecting to database...OK
Determining current state...
Currently installed SQL Patches:
  PDB CDB$ROOT:
  PDB PDB$SEED:
  PDB PDB01:
Currently installed C Patches: 18522516
Adding patches to installation queue and performing prereq checks...
Installation queue:
  For the following PDBs: CDB$ROOT PDB$SEED PDB01
    Nothing to roll back
    The following patches will be applied: 18522516
Installing patches...
...
...
SQL Patching tool complete ...

Patching complete.

You may also like:

Upgrade Oracle Database 12c with ASM 12.1.0.1 to 12.1.0.2

Cheers!!