miércoles, 8 de abril de 2020

Install ODB 12c in RAC on LX7

Oracle Database 12c Release 2 (12.2) RAC On Oracle Linux 7 Using VirtualBox

This article describes the installation of Oracle Database 12c Release 2 (12.2 64-bit) RAC on Linux (Oracle Linux 7 64-bit) using VirtualBox (5.1) with no additional shared disk devices.
  • Introduction
  • Download Software
  • VirtualBox Installation
  • VirtualBox Network Setup
  • Virtual Machine Setup
  • Guest Operating System Installation
  • Oracle Installation Prerequisites
    • Automatic Setup
    • Manual Setup
    • Additional Setup
  • Install Guest Additions
  • Create Shared Disks
  • Clone the Virtual Machine
  • Install the Grid Infrastructure
  • Install the Database Software
  • Create a Database
  • Check the Status of the RAC



Introduction

One of the biggest obstacles preventing people from setting up test RAC environments is the requirement for shared storage. In a production environment, shared storage is often provided by a SAN or high-end NAS device, but both of these options are very expensive when all you want to do is get some experience installing and using RAC. A cheaper alternative is to use virtualization to fake the shared storage.
Using VirtualBox you can run multiple Virtual Machines (VMs) on a single server, allowing you to run both RAC nodes on a single machine. In addition, it allows you to set up shared virtual disks, overcoming the obstacle of expensive shared storage.
Virtual RAC
Before you launch into this installation, here are a few things to consider.
  • The finished system includes the host operating system, two guest operating systems, two sets of Oracle Grid Infrastructure (Clusterware + ASM) and two Database instances all on a single server. As you can imagine, this requires a significant amount of disk space, CPU and memory.
  • Following on from the last point, the VMs will each need at least 4G of RAM, preferably more if you don't want the VMs to swap like crazy. Don't assume you will be able to run this on a small PC or laptop. You won't.
  • This procedure provides a bare bones installation to get the RAC working. There is no redundancy in the Grid Infrastructure installation or the ASM installation. To add this, simply create double the amount of shared disks and select the "Normal" redundancy option when it is offered. Of course, this will take more disk space.
  • During the virtual disk creation, I always choose not to preallocate the disk space. This makes virtual disk access slower during the installation, but saves on wasted disk space. The shared disks must have their space preallocated.
  • This is not, and should not be considered, a production-ready system. It's simply to allow you to get used to installing and using RAC.
  • The Single Client Access Name (SCAN) should be defined in the DNS or GNS and round-robin between one of 3 addresses, which are on the same subnet as the public and virtual IPs. Prior to 11.2.0.2 it could be defined as a single IP address in the "/etc/hosts" file, which is wrong and will cause the cluster verification to fail, but it allowed you to complete the install without the presence of a DNS. This does not seem to work for 11.2.0.2 onward.
  • The virtual machines can be limited to 2Gig of swap, which causes a prerequisite check failure, but doesn't prevent the installation working. If you want to avoid this, define 3+Gig of swap.
  • This article uses the 64-bit versions of Oracle Linux and Oracle 12c Release 2.
  • When doing this installation on my server, I split the virtual disks on to different physical disks ("/u02", "/u03", "/u04"). This is not necessary, but makes things run a bit faster.
This procedure should run successfully on a Linux and Windows host. Where applicable, I've included both the Linux and Windows commands to be run on the host, so pick the relevant ones.
 Although I have completed this installation with 4G VMs, it was chronically slow. I would suggest using as much memory as possible, without making the host OS swap.

Download Software

Download the following software.
Depending on your version of VirtualBox and Oracle Linux, there may be some slight variation in how the screen shots look.

VirtualBox Installation

First, install the VirtualBox software. On RHEL and its clones you do this with the following type of command as the root user. On windows, just run the ".exe".
# rpm -Uvh VirtualBox*.rpm
The package name will vary depending on the host distribution you are using. Once complete, VirtualBox is started from the menu.

VirtualBox Network Setup

We need to make sure a host-only network is configured and check/modify the IP range for that network. This will be the public network for our RAC installation.
  • Start VirtualBox from the menu.
  • Select the "File > Preferences" menu option.
  • Click "Network" in the left pane and click the "Host-only Networks" tab.
  • Click the "Adds new host-only network" button on the right size of the screen. Depending on the host OS, a network called "vboxnet0" or "VirtualBox Host-Only Ethernet Adapter" will be created.
    Host-Only Networks
    Click the "Edits selected host-only network." button on the right size of the screen.
  • If you want to use a different subnet for your public addresses you can change the network details here. Just make sure the subnet you choose doesn't match any real subnets on your network. I've decided to stick with the default, which for me is "192.168.56.X".
    Host-Only Network Details
  • Use the "OK" buttons to exit out of this screen.
  • Click the "NAT Networks" tab. If you don't have a NAT network defined, click the "+" button. You shouldn't need to configure this.
  • Click the "OK" button to close the preferences dialog.

Virtual Machine Setup

Now we must define the two virtual RAC nodes. We can save time by defining one VM, then cloning it when it is installed.
Start VirtualBox and click the "New" button on the toolbar. Enter the name "ol7-122-rac1", OS "Linux" and Version "Oracle (64 bit)", then click the "Next" button.
New VM Wizard - Name and Operating System
Enter "4096" as the base memory size, then click the "Next" button. Use more memory if you have enough physical memory on your machine as it will make the process much quicker!
New VM Wizard - Memory Size
Accept the default option to create a new virtual hard disk by clicking the "Create" button.
New VM Wizard - Hard Drive
Acccept the default hard drive file type by clicking the "Next" button.
Create Virtual Hard Drive - Hard Drive File Type
Acccept the "Dynamically allocated" option by clicking the "Next" button.
Create Virtual Hard Drive - Storage on Physical Hard Drive
Accept the default location and set the size to "50G", then click the "Create" button. If you can spread the virtual disks onto different physical disks, that will improve performance.
Create Virtual Hard Drive - File Location And Size
The "ol7-122-rac1" VM will appear on the left hand pane. Scroll down the details on the right and click on the "Network" link.
VirtualBox - Console
Make sure "Adapter 1" is enabled, set to "NAT", then click on the "Adapter 2" tab.
VirtualBox - Network Adapter 1
Make sure "Adapter 2" is enabled, set to "Host-only Adapter", then click on the "Adapter 3" tab.
VirtualBox - Network Adapter 2
Make sure "Adapter 3" is enabled, set to "Internal Network", then click on the "System" section.
VirtualBox - Network Adapter 3
Move "Hard Disk" to the top of the boot order and uncheck the "Floppy" option, then click the "OK" button.
VirtualBox - System Settings
The virtual machine is now configured so we can start the guest operating system installation.

Guest Operating System Installation

With the new VM highlighted, click the "Start" button on the toolbar. On the "Select start-up disk" screen, choose the relevant Oracle Linux ISO image and click the "Start" button.
VirtualBox - Select start-up disk
If a "Select start-up disk" screen doesn't appear, use the "Devices > Optical Drives > Choose disk image..." menu option to select the relevant ISO image, then restart the VM using the "Machine > Reset" menu option.
The resulting console window will contain the Oracle Linux boot screen.
Oracle Linux Boot
Continue through the Oracle Linux 7 installation as you would for a basic server. A general pictorial guide to the installation can be found here. More specifically, it should be a server installation with a minimum of 4G+ swap, firewall disabled, SELinux set to permissive and the following package groups installed:
  • Server with GUI
  • Hardware Monitoring Utilities
  • Large Systems Performance
  • Network file system client
  • Performance Tools
  • Compatibility Libraries
  • Development Tools
To be consistent with the rest of the article, the following information should be set during the installation.
  • hostname: ol7-122-rac1.localdomain
  • enp0s3 (eth0): DHCP (Connect Automatically)
  • enp0s8 (eth1): IP=192.168.56.101, Subnet=255.255.255.0, Gateway=192.168.56.1, DNS=192.168.56.1, Search=localdomain (Connect Automatically)
  • enp0s9 (eth2): IP=192.168.1.101, Subnet=255.255.255.0, Gateway=<blank>, DNS=<blank>, Search=<blank> (Connect Automatically)
You are free to change the IP addresses to suit your network, but remember to stay consistent with those adjustments throughout the rest of the article. Likewise, in this article I will refer to the network adapters as enp0s3, enp0s8 and enp0s9, In previous Linux versions they would have been eth0, eth1 and eth2 respectively.

Oracle Installation Prerequisites

Perform either the Automatic Setup or the Manual Setup to complete the basic prerequisites. The Additional Setup is required for all installations.

Automatic Setup

If you plan to use the "oracle-database-server-12cR2-preinstall" package to perform all your prerequisite setup, issue the following command.
# yum install oracle-database-server-12cR2-preinstall -y
 Earlier versions of Oracle Linux required manual setup of the Yum repository by following the instructions at http://public-yum.oracle.com.
It is probably worth doing a full update as well, but this is not strictly speaking necessary.
# yum update -y

Manual Setup

If you have not used the "oracle-database-server-12cR2-preinstall" package to perform all prerequisites, you will need to manually perform the following setup tasks.
Add the following lines to the "/etc/sysctl.conf" file, or in a file called "/etc/sysctl.d/98-oracle.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
Run one of the following commands to change the current kernel parameters, depending on which file you edited.
/sbin/sysctl -p
# Or
/sbin/sysctl -p /etc/sysctl.d/98-oracle.conf
Add the following lines to a file called "/etc/security/limits.d/oracle-database-server-12cR2-preinstall.conf" file.
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
In addition to the basic OS installation, the following packages must be installed whilst logged in as the root user. This includes the 64-bit and 32-bit versions of some packages.
# From Public Yum or ULN
yum install binutils -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install ksh -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install libstdc++-devel.i686 -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libXext -y
yum install libXext.i686 -y
yum install libXtst -y
yum install libXtst.i686 -y
yum install libX11 -y
yum install libX11.i686 -y
yum install libXau -y
yum install libXau.i686 -y
yum install libxcb -y
yum install libxcb.i686 -y
yum install libXi -y
yum install libXi.i686 -y
yum install make -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel -y
yum install zlib-devel -y
yum install zlib-devel.i686 -y
Create the new groups and 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
#groupadd -g 54330 racdba

useradd -u 54321 -g oinstall -G dba,oper oracle
You could define the additional groups and assign them to the "oracle" users. The would allow you to assign the individual groups during the installation. For this installation I've just used the "dba" group.
groupadd -g 54324 backupdba
groupadd -g 54325 dgdba
groupadd -g 54326 kmdba
groupadd -g 54327 asmdba
groupadd -g 54328 asmoper
groupadd -g 54329 asmadmin
groupadd -g 54330 racdba

useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,asmdba,asmoper,asmadmin,racdba oracle

Additional Setup

The following steps must be performed, whether you did the manual or automatic setup.
Perform the following steps whilst logged into the "ol7-122-rac1" virtual machine as the root user.
Set the password for the "oracle" user.
passwd oracle
Apart form the localhost address, the "/etc/hosts" file can be left blank, but I prefer to put the addresses in for reference.
127.0.0.1       localhost.localdomain   localhost
# Public
192.168.56.101   ol7-122-rac1.localdomain        ol7-122-rac1
192.168.56.102   ol7-122-rac2.localdomain        ol7-122-rac2
# Private
192.168.1.101   ol7-122-rac1-priv.localdomain   ol7-122-rac1-priv
192.168.1.102   ol7-122-rac2-priv.localdomain   ol7-122-rac2-priv
# Virtual
192.168.56.103   ol7-122-rac1-vip.localdomain    ol7-122-rac1-vip
192.168.56.104   ol7-122-rac2-vip.localdomain    ol7-122-rac2-vip
# SCAN
#192.168.56.105   ol7-122-scan.localdomain ol7-122-scan
#192.168.56.106   ol7-122-scan.localdomain ol7-122-scan
#192.168.56.107   ol7-122-scan.localdomain ol7-122-scan
 The SCAN address is commented out of the hosts file because it must be resolved using a DNS, so it can round-robin between 3 addresses on the same subnet as the public IPs. The DNS can be configured on the host machine using BIND or Dnsmasq, which is much simpler. If you are using Dnsmasq, put the RAC-specific entries in the hosts machines "/etc/hosts" file, with the SCAN entries uncommented, and restart Dnsmasq.
Make sure the "/etc/resolv.conf" file includes a nameserver entry that points to the correct nameserver. Also, if the "domain" and "search" entries are both present, comment out one of them. For this installation my "/etc/resolv.conf" looked like this.
#domain localdomain
search localdomain
nameserver 192.168.56.1
The changes to the "resolv.conf" will be overwritten by the network manager, due to the presence of the NAT interface. For this reason, this interface should now be disabled on startup. You can enable it manually if you need to access the internet from the VMs. Edit the "/etc/sysconfig/network-scripts/ifcfg-enp0s3" (eth0) file, making the following change. This will take effect after the next restart.
ONBOOT=no
There is no need to do the restart now. You can just run the following command. Remember to amend the adapter name if yours are named differently.
# ifdown enp0s3
# #ifdown eth0
At this point, the networking for the first node should look something like the following. Notice that enp0s3 (eth0) has no associated IP address because it is disabled.
# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:f6:88:78  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.101  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::cf8d:317d:534:17d9  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:82:06:32  txqueuelen 1000  (Ethernet)
        RX packets 574  bytes 54444 (53.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 547  bytes 71219 (69.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.101  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::9a9a:f249:61d1:5447  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:2e:2c:cf  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 29  bytes 4250 (4.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 68  bytes 5780 (5.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 5780 (5.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:4a:12:2f  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# 
With this in place and the DNS configured the SCAN address is being resolved to all three IP addresses.
# nslookup ol7-122-scan
Server:  192.168.56.1
Address: 192.168.56.1#53

Name: ol7-122-scan.localdomain
Address: 192.168.56.105
Name: ol7-122-scan.localdomain
Address: 192.168.56.106
Name: ol7-122-scan.localdomain
Address: 192.168.56.107

#
Change the setting of SELinux to permissive by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.
SELINUX=permissive
If you have the Linux firewall enabled, you will need to disable or configure it, as shown here or here. The following is an example of disabling the firewall.
# systemctl stop firewalld
# systemctl disable firewalld
Make sure NTP (Chrony on OL7/RHEL7) is enabled.
# systemctl enable chronyd
# systemctl restart chronyd
# chronyc -a 'burst 4/4'
# chronyc -a makestep
Create the directories in which the Oracle software will be installed.
mkdir -p /u01/app/12.2.0.1/grid
mkdir -p /u01/app/oracle/product/12.2.0.1/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01/
Log in as the "oracle" user and add the following lines at the end of the "/home/oracle/.bash_profile" file.
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP

export ORACLE_HOSTNAME=ol7-122-rac1.localdomain
export ORACLE_UNQNAME=CDBRAC
export ORACLE_BASE=/u01/app/oracle
export GRID_HOME=/u01/app/12.2.0.1/grid
export DB_HOME=$ORACLE_BASE/product/12.2.0.1/db_1
export ORACLE_HOME=$DB_HOME
export ORACLE_SID=cdbrac1
export ORACLE_TERM=xterm
export BASE_PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$BASE_PATH

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

alias grid_env='. /home/oracle/grid_env'
alias db_env='. /home/oracle/db_env'
Create a file called "/home/oracle/grid_env" with the following contents.
export ORACLE_SID=+ASM1
export ORACLE_HOME=$GRID_HOME
export PATH=$ORACLE_HOME/bin:$BASE_PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
Create a file called "/home/oracle/db_env" with the following contents.
export ORACLE_SID=cdbrac1
export ORACLE_HOME=$DB_HOME
export PATH=$ORACLE_HOME/bin:$BASE_PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
Once the "/home/oracle/.bash_profile" has been run, you will be able to switch between environments as follows.
$ grid_env
$ echo $ORACLE_HOME
/u01/app/12.2.0.1/grid
$ db_env
$ echo $ORACLE_HOME
/u01/app/oracle/product/12.2.0.1/db_1
$
We've made a lot of changes, so it's worth doing a reboot of the VM at this point to make sure all the changes have taken effect.
# shutdown -r now

Install Guest Additions

Click on the "Devices > Install Guest Additions" menu option at the top of the VM screen. If you get the option to auto-run take it. If not, then run the following commands.
cd /media/VBOXADDITIONS*
sh ./VBoxLinuxAdditions.run
Add the "oracle" user into the "vboxsf" group so it has access to shared drives.
# usermod -G oinstall,dba,vboxsf oracle
# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(vboxsf)
#
Unzip the database software (but not the grid software) on the host machine.
unzip linuxx64_12201_database.zip
Create a shared folder (Devices > Shared Folders) on the virtual machine, pointing to the directory on the host where the Oracle software was unzipped. Check the "Auto-mount" and "Make Permanent" options before clicking the "OK" button.
Shared Folders
The VM will need to be restarted for the guest additions to be used properly. The next section requires a shutdown so no additional restart is needed at this time. Once the VM is restarted, the shared folder called "/media/sf_12.2.0.1" will be accessible by the "oracle" user.

Create Shared Disks

Shut down the "ol7-122-rac1" virtual machine using the following command.
# shutdown -h now
On the host server, create 4 sharable virtual disks and associate them as virtual media using the following commands. You can pick a different location, but make sure they are outside the existing VM directory.
$ mkdir -p /u04/VirtualBox/ol7-122-rac
$ cd /u04/VirtualBox/ol7-122-rac
$
$ # Create the disks and associate them with VirtualBox as virtual media.
$ VBoxManage createhd --filename asm1.vdi --size 20480 --format VDI --variant Fixed
$ VBoxManage createhd --filename asm2.vdi --size 20480 --format VDI --variant Fixed
$ VBoxManage createhd --filename asm3.vdi --size 20480 --format VDI --variant Fixed
$ VBoxManage createhd --filename asm4.vdi --size 20480 --format VDI --variant Fixed
$
$ # Connect them to the VM.
$ VBoxManage storageattach ol7-122-rac1 --storagectl "SATA" --port 1 --device 0 --type hdd --medium asm1.vdi --mtype shareable
$ VBoxManage storageattach ol7-122-rac1 --storagectl "SATA" --port 2 --device 0 --type hdd --medium asm2.vdi --mtype shareable
$ VBoxManage storageattach ol7-122-rac1 --storagectl "SATA" --port 3 --device 0 --type hdd --medium asm3.vdi --mtype shareable
$ VBoxManage storageattach ol7-122-rac1 --storagectl "SATA" --port 4 --device 0 --type hdd --medium asm4.vdi --mtype shareable
$
$ # Make shareable.
$ VBoxManage modifyhd asm1.vdi --type shareable
$ VBoxManage modifyhd asm2.vdi --type shareable
$ VBoxManage modifyhd asm3.vdi --type shareable
$ VBoxManage modifyhd asm4.vdi --type shareable
If you are using a Windows host, you will have to modify the paths, but the process is the same.
C:
mkdir C:\VirtualBox\ol7-122-rac
cd C:\VirtualBox\ol7-122-rac

"c:\Program Files\Oracle\VirtualBox\VBoxManage" createhd --filename asm1.vdi --size 20480 --format VDI --variant Fixed
"c:\Program Files\Oracle\VirtualBox\VBoxManage" createhd --filename asm2.vdi --size 20480 --format VDI --variant Fixed
"c:\Program Files\Oracle\VirtualBox\VBoxManage" createhd --filename asm3.vdi --size 20480 --format VDI --variant Fixed
"c:\Program Files\Oracle\VirtualBox\VBoxManage" createhd --filename asm4.vdi --size 20480 --format VDI --variant Fixed

"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac1 --storagectl "SATA" --port 1 --device 0 --type hdd --medium asm1.vdi --mtype shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac1 --storagectl "SATA" --port 2 --device 0 --type hdd --medium asm2.vdi --mtype shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac1 --storagectl "SATA" --port 3 --device 0 --type hdd --medium asm3.vdi --mtype shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac1 --storagectl "SATA" --port 4 --device 0 --type hdd --medium asm4.vdi --mtype shareable

"c:\Program Files\Oracle\VirtualBox\VBoxManage" modifyhd asm1.vdi --type shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" modifyhd asm2.vdi --type shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" modifyhd asm3.vdi --type shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" modifyhd asm4.vdi --type shareable
Start the "ol7-122-rac1" virtual machine by clicking the "Start" button on the toolbar. When the server has started, log in as the root user so you can configure the shared disks. The current disks can be seen by issuing the following commands.
# cd /dev
# ls sd*
sda  sda1  sda2  sdb  sdc  sdd  sde
#
Use the "fdisk" command to partition the disks sdb to sde. The following output shows the expected fdisk output for the sdb disk.
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x14a4629c.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#
In each case, the sequence of answers is "n", "p", "1", "Return", "Return" and "w".
Once all the disks are partitioned, the results can be seen by repeating the previous "ls" command.
# cd /dev
# ls sd*
sda  sda1  sda2  sdb  sdb1  sdc  sdc1  sdd  sdd1  sde  sde1
#
Configure your UDEV rules, as shown here.
Add the following to the "/etc/scsi_id.config" file to configure SCSI devices as trusted. Create the file if it doesn't already exist.
options=-g
The SCSI ID of my disks are displayed below.
# /usr/lib/udev/scsi_id -g -u -d /dev/sdb1
1ATA_VBOX_HARDDISK_VB189c7a69-689f61b0
# /usr/lib/udev/scsi_id -g -u -d /dev/sdc1
1ATA_VBOX_HARDDISK_VBc4ae174e-fc756d12
# /usr/lib/udev/scsi_id -g -u -d /dev/sdd1
1ATA_VBOX_HARDDISK_VBa4e03079-ae751cbd
# /usr/lib/udev/scsi_id -g -u -d /dev/sde1
1ATA_VBOX_HARDDISK_VBf00747dc-10252f06
#
Using these values, edit the "/etc/udev/rules.d/99-oracle-asmdevices.rules" file adding the following 4 entries. All parameters for a single entry must be on the same line.
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB189c7a69-689f61b0", SYMLINK+="oracleasm/asm-disk1", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBc4ae174e-fc756d12", SYMLINK+="oracleasm/asm-disk2", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBa4e03079-ae751cbd", SYMLINK+="oracleasm/asm-disk3", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBf00747dc-10252f06", SYMLINK+="oracleasm/asm-disk4", OWNER="oracle", GROUP="dba", MODE="0660"
Load updated block device partition tables.
# /sbin/partprobe /dev/sdb1
# /sbin/partprobe /dev/sdc1
# /sbin/partprobe /dev/sdd1
# /sbin/partprobe /dev/sde1
Test the rules are working as expected.
# /sbin/udevadm test /block/sdb/sdb1
Reload the UDEV rules.
# /sbin/udevadm control --reload-rules
The disks should now be visible and have the correct ownership using the following command. If they are not visible, your UDEV configuration is incorrect and must be fixed before you proceed.
# ls -al /dev/oracleasm/*
lrwxrwxrwx. 1 root root 7 Mar  6 17:41 /dev/oracleasm/asm-disk1 -> ../sdb1
lrwxrwxrwx. 1 root root 7 Mar  6 17:41 /dev/oracleasm/asm-disk2 -> ../sdc1
lrwxrwxrwx. 1 root root 7 Mar  6 17:41 /dev/oracleasm/asm-disk3 -> ../sdd1
lrwxrwxrwx. 1 root root 7 Mar  6 17:41 /dev/oracleasm/asm-disk4 -> ../sde1
#
The symbolic links are owned by root, but the devices they point to now have the correct ownership.
# ls -al /dev/sd*1
brw-rw----. 1 root   disk 8,  1 Apr 25 14:11 /dev/sda1
brw-rw----. 1 oracle dba  8, 17 Apr 25 14:11 /dev/sdb1
brw-rw----. 1 oracle dba  8, 33 Apr 25 14:11 /dev/sdc1
brw-rw----. 1 oracle dba  8, 49 Apr 25 14:11 /dev/sdd1
brw-rw----. 1 oracle dba  8, 65 Apr 25 14:11 /dev/sde1
#
The shared disks are now configured for the grid infrastructure.

Clone the Virtual Machine

Do not use VirtualBox to clone VM, as it will also attempt to clone the shared disks, which is not what we want. Instead we must manually clone the VM.
Shut down the "ol7-122-rac1" virtual machine using the following command.
# shutdown -h now
 You may get errors if you create the virtual disk in the default location VirtualBox will use to create the VM. If that happens, rename the folder holding the new virtual disk and go through the creation process of the new VM again.
Manually clone the "ol7-122-rac1.vdi" disk using the following commands on the host server.
$ # Linux
$ mkdir -p /u03/VirtualBox/ol7-122-rac2
$ VBoxManage clonehd /u01/VirtualBox/ol7-122-rac1/ol7-122-rac1.vdi /u03/VirtualBox/ol7-122-rac2/ol7-122-rac2.vdi

Rem Windows
mkdir "C:\VirtualBox\ol7-122-rac2"
"c:\Program Files\Oracle\VirtualBox\VBoxManage" clonehd "C:\VirtualBox\ol7-122-rac1\ol7-122-rac1.vdi" "C:\VirtualBox\ol7-122-rac2\ol7-122-rac2.vdi"
Create the "ol7-122-rac2" virtual machine in VirtualBox in the same way as you did for "ol7-122-rac1", with the exception of using an existing "ol7-122-rac2.vdi" virtual hard drive.
New VM Wizard - Hard Drive
Remember to add the three network adaptor as you did on the "ol7-122-rac1" VM. When the VM is created, attach the shared disks to this VM.
$ # Linux : Switch to the shared storage location and attach them.
$ cd /u04/VirtualBox/ol7-122-rac
$
$ VBoxManage storageattach ol7-122-rac2 --storagectl "SATA" --port 1 --device 0 --type hdd --medium asm1.vdi --mtype shareable
$ VBoxManage storageattach ol7-122-rac2 --storagectl "SATA" --port 2 --device 0 --type hdd --medium asm2.vdi --mtype shareable
$ VBoxManage storageattach ol7-122-rac2 --storagectl "SATA" --port 3 --device 0 --type hdd --medium asm3.vdi --mtype shareable
$ VBoxManage storageattach ol7-122-rac2 --storagectl "SATA" --port 4 --device 0 --type hdd --medium asm4.vdi --mtype shareable


Rem Windows : Switch to the shared storage location and attach them.
C:
cd C:\VirtualBox\ol7-122-rac

"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac2 --storagectl "SATA" --port 1 --device 0 --type hdd --medium asm1.vdi --mtype shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac2 --storagectl "SATA" --port 2 --device 0 --type hdd --medium asm2.vdi --mtype shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac2 --storagectl "SATA" --port 3 --device 0 --type hdd --medium asm3.vdi --mtype shareable
"c:\Program Files\Oracle\VirtualBox\VBoxManage" storageattach ol7-122-rac2 --storagectl "SATA" --port 4 --device 0 --type hdd --medium asm4.vdi --mtype shareable
Start the "ol7-122-rac2" virtual machine by clicking the "Start" button on the toolbar. Ignore any network errors during the startup.
Log in to the "ol7-122-rac2" virtual machine as the "root" user so we can reconfigure the network settings to match the following.
  • hostname: ol7-122-rac2.localdomain
  • enp0s3 (eth0): DHCP (*Not* Connect Automatically)
  • enp0s8 (eth1): IP=192.168.56.102, Subnet=255.255.255.0, Gateway=192.168.56.1, DNS=192.168.56.1, Search=localdomain (Connect Automatically)
  • enp0s9 (eth2): IP=192.168.1.102, Subnet=255.255.255.0, Gateway=<blank>, DNS=<blank>, Search=<blank> (Connect Automatically)
Amend the hostname in the "/etc/hostname" file.
ol7-122-rac2.localdomain
Unlike previous Linux versions, we shouldn't have to edit the MAC address associated with the network adapters, but we will have to alter their IP addresses.
Edit the "/etc/sysconfig/network-scripts/ifcfg-enp0s8" (eth1), amending only the IPADDR settings as follows and deleting the UUID entry.
IPADDR=192.168.56.102
Edit the "/etc/sysconfig/network-scripts/ifcfg-enp0s9" (eth2), amending only the IPADDR settings as follows and deleting the UUID entry.
IPADDR=192.168.1.102
Restart the virtual machines.
# shutdown -r now
At this point, the networking for the second node should look something like the following. Notice that enp0s3 (eth0) has no associated IP address because it is disabled.
# ifconfig
enp0s3 : flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:dc:7c:74  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.102  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:fed9:c89a  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:d9:c8:9a  txqueuelen 1000  (Ethernet)
        RX packets 197  bytes 19460 (19.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 178  bytes 27171 (26.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.102  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a00:27ff:feb4:6bf  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:b4:06:bf  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 30  bytes 4112 (4.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 4  bytes 420 (420.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 420 (420.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

#
Edit the "/home/oracle/.bash_profile" file on the "ol7-122-rac2" node to correct the ORACLE_SID and ORACLE_HOSTNAME values.
export ORACLE_SID=cdbrac2
export ORACLE_HOSTNAME=ol7-122-rac2.localdomain
Also, amend the ORACLE_SID setting in the "/home/oracle/db_env" and "/home/oracle/grid_env" files.
Restart the "ol7-122-rac2" virtual machine and start the "ol7-122-rac1" virtual machine. When both nodes have started, check they can both ping all the public and private IP addresses using the following commands.
ping -c 3 ol7-122-rac1
ping -c 3 ol7-122-rac1-priv
ping -c 3 ol7-122-rac2
ping -c 3 ol7-122-rac2-priv
Check the SCAN address is still being resolved properly on both nodes.
# nslookup ol7-122-scan
Server:  192.168.56.1
Address: 192.168.56.1#53

Name: ol7-122-scan.localdomain
Address: 192.168.56.105
Name: ol7-122-scan.localdomain
Address: 192.168.56.106
Name: ol7-122-scan.localdomain
Address: 192.168.56.107

#
At this point the virtual IP addresses defined in the "/etc/hosts" file will not work, so don't bother testing them.
Check the UDEV rules are working on both machines.
# ls -al /dev/oracleasm/*
lrwxrwxrwx. 1 root root 7 Sep 18 08:19 /dev/oracleasm/asm-disk1 -> ../sdb1
lrwxrwxrwx. 1 root root 7 Sep 18 08:19 /dev/oracleasm/asm-disk2 -> ../sdc1
lrwxrwxrwx. 1 root root 7 Sep 18 08:19 /dev/oracleasm/asm-disk3 -> ../sdd1
lrwxrwxrwx. 1 root root 7 Sep 18 08:19 /dev/oracleasm/asm-disk4 -> ../sde1
#
Prior to 11gR2 we would probably use the "runcluvfy.sh" utility in the clusterware root directory to check the prerequisites have been met. If you are intending to configure SSH connectivity using the installer this check should be omitted as it will always fail. If you want to setup SSH connectivity manually, then once it is done you can run the "runcluvfy.sh" with the following command.
/mountpoint/clusterware/runcluvfy.sh stage -pre crsinst -n ol7-122-rac1,ol7-122-rac2 -verbose
If you get any failures be sure to correct them before proceeding.
The virtual machine setup is now complete.
Before moving forward you should probably shut down your VMs and take snapshots of them. If any failures happen beyond this point it is probably better to switch back to those snapshots, clean up the shared drives and start the grid installation again. An alternative to cleaning up the shared disks is to back them up now using zip and just replace them in the event of a failure.
$ # Linux
$ cd /u04/VirtualBox/ol7-122-rac
$ zip PreGrid.zip *.vdi

Rem Windows
C:
cd C:\VirtualBox\ol7-122-rac
zip PreGrid.zip *.vdi

Install the Grid Infrastructure

Make sure both virtual machines are started. The GI is now an image installation, so perform the following on the first node as the "oracle" user.
export SOFTWARE_LOCATION=/media/sf_12.2.0.1/
cd /u01/app/12.2.0.1/grid
unzip -q $SOFTWARE_LOCATION/linuxx64_12201_grid_home.zip
Install the following package from the grid home as the "root" user on all nodes.
su -
# Local node.
cd /u01/app/12.2.0.1/grid/cv/rpm
rpm -Uvh cvuqdisk*

# Remote node.
scp ./cvuqdisk* root@ol7-122-rac2:/tmp
ssh root@ol7-122-rac2 rpm -Uvh /tmp/cvuqdisk*
exit
If you were planning on using the AFD Driver (the new ASMLib) you would configure the shared disks using the asmcmd command as shown below. We are using UDEV, so this is not necessary.
# !!!! I did not do this! !!!!
su -

# Set environment.
export ORACLE_HOME=/u01/app/12.2.0.1/grid
export ORACLE_BASE=/tmp

# Mark disks.
$ORACLE_HOME/bin/asmcmd afd_label DISK1 /dev/oracleasm/asm-disk1 --init
$ORACLE_HOME/bin/asmcmd afd_label DISK2 /dev/oracleasm/asm-disk2 --init
$ORACLE_HOME/bin/asmcmd afd_label DISK3 /dev/oracleasm/asm-disk3 --init
$ORACLE_HOME/bin/asmcmd afd_label DISK4 /dev/oracleasm/asm-disk4 --init

# Test Disks.
$ORACLE_HOME//bin/asmcmd afd_lslbl /dev/oracleasm/asm-disk1
$ORACLE_HOME//bin/asmcmd afd_lslbl /dev/oracleasm/asm-disk2
$ORACLE_HOME//bin/asmcmd afd_lslbl /dev/oracleasm/asm-disk3
$ORACLE_HOME//bin/asmcmd afd_lslbl /dev/oracleasm/asm-disk4

# unset environment.
unset ORACLE_BASE

exit
Configure the Grid Infrastructure by running the following as the "oracle" user.
I could have run the configuration in silent mode using this edited response file (grid_config.rsp) with the following command.
cd /u01/app/12.2.0.1/grid
./gridSetup.sh -silent -responseFile /tmp/grid_config.rsp
Instead, here's the interactive configuration.
cd /u01/app/12.2.0.1/grid
./gridSetup.sh
Select the "Configure Oracle Grid Infrastructure for a New Cluster" option, then click the "Next" button.
Grid - Select Configuration Option
Accept the "Configure an Oracle Standalone Cluster" option by clicking the "Next" button.
Grid - Select Cluster Configuration
Enter the cluster name "ol7-122-cluster", SCAN name "ol7-122-scan" and SCAN port "1521", then click the "Next" button.
Grid - Grid Plug and Play Information
On the "Cluster Node Information" screen, click the "Add" button.
Grid - Cluster Node Information
Enter the details of the second node in the cluster, then click the "OK" button.
Grid - Add Cluster Node Information
Click the "SSH connectivity..." button and enter the password for the "oracle" user. Click the "Setup" button to configure SSH connectivity, and the "Test" button to test it once it is complete. Once the test is complete, click the "Next" button.
Grid - SSH Connectivity
Check the public and private networks are specified correctly. If the NAT interface is displayed, remember to mark it as "Do Not Use". Click the "Next" button.
Grid - Network Interfaces
Accept the "Configure ASM using block devices" option by clicking the "Next" button.
Grid - Storage Option Information
Select the "No" option, as we don't want to create a separate disk group for the GIMR in this case. Click the "Next" button.
Grid - Grid Infrastructure Management Repository Options
Set the redundancy to "External", click the "Change Discovery Path" button and set the path to "/dev/oracleasm/*". Return to the main screen and select all 4 disks. Uncheck the "Configure Oracle ASM Filter Driver" option, then click the "Next" button.
Grid - Create ASM Disk Group
Enter the credentials and click the "Next" button.
Grid - Specify ASM Password
Accept the default IPMI option by clicking the "Next" button.
Grid - Failure Isolation Support
Don't register with EM. Click the "Next" button.
Grid - Specify Management Option
We are using a single user and group manage both ASM add the database, so set the groups to "dba" and click the "Next" button. Accept the warnings on the subsequent dialog by clicking the "Yes" button.
Grid - Privileged Operating System Groups
Enter the Oracle Base location "/u01/app/oracle" and click the "Next" button. We have already pre-created directories for the later database installation, so ignore the subsequent warning about the Oracle Base not being empty by clicking the "Yes" button.
Grid - Specify Installation Location
Accept the default inventory directory by clicking the "Next" button.
Grid - Create Inventory
If you want the root scripts to run automatically, enter the relevant credentials. I prefer to run them manually. Click the "Next" button.
Grid - Root Script Execution Configuration
Wait while the prerequisite checks complete. If you have any issues use the "Fix & Check Again" button. Once possible fixes are complete, check the "Ignore All" checkbox and click the "Next" button. It is likely the "Physical Memory" and "Network Time Protocol (NTP)" tests will fail for this type of installation. This is OK.
Grid - Perform Prerequisite Checks
If you are happy with the summary information, click the "Install" button.
Grid - Summary
Wait while the installation takes place.
Grid - Install Product
When prompted, run the configuration scripts on each node.
Grid - Execute Configuration Scripts
The output from the "orainstRoot.sh" file should look something like that listed below.
# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
#
The output of the "root.sh" will vary a little depending on the node it is run on. Example output can be seen here (Node1Node2).
Once the scripts have completed, return to the "Execute Configuration Scripts" screen on "ol7-122-rac1" and click the "OK" button.
Grid - Execute Configuration Scripts
Wait for the configuration assistants to complete.
Grid - Configuration Assistants
If any of the configuration steps fail you should check the specified log to see if the error is a show-stopper or not. The only error I received was for time sychronization (PRVG-13606. .
PRVG-13606 : chrony daemon is not synchronized with any external time source on node ...
Provided you don't have any show-stoppers, it is safe to ignore the errors by clicking "Next" button.
Click the "Close" button to exit the installer.
Grid - Finish
The grid infrastructure installation is now complete. We can check the status of the installation using the following commands.
$ grid_env
$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       ol7-122-rac1             STABLE
               ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.DATA.dg
               ONLINE  ONLINE       ol7-122-rac1             STABLE
               ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       ol7-122-rac1             STABLE
               ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.chad
               ONLINE  ONLINE       ol7-122-rac1             STABLE
               ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.net1.network
               ONLINE  ONLINE       ol7-122-rac1             STABLE
               ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.ons
               ONLINE  ONLINE       ol7-122-rac1             STABLE
               ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.proxy_advm
               OFFLINE OFFLINE      ol7-122-rac1             STABLE
               OFFLINE OFFLINE      ol7-122-rac2             STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       ol7-122-rac2             169.254.137.110 192.
                                                             168.1.102,STABLE
ora.asm
      1        ONLINE  ONLINE       ol7-122-rac1             Started,STABLE
      2        ONLINE  ONLINE       ol7-122-rac2             Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       ol7-122-rac1             STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       ol7-122-rac2             Open,STABLE
ora.ol7-122-rac1.vip
      1        ONLINE  ONLINE       ol7-122-rac1             STABLE
ora.ol7-122-rac2.vip
      1        ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.qosmserver
      1        ONLINE  ONLINE       ol7-122-rac1             STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       ol7-122-rac2             STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       ol7-122-rac2             STABLE
--------------------------------------------------------------------------------
$
At this point it is probably a good idea to shutdown both VMs and take snapshots. Remember to make a fresh zip of the ASM disks on the host machine, which you will need to restore if you revert to the post-grid snapshots.
$ cd /u04/VirtualBox/ol7-122-rac
$ zip PostGrid.zip *.vdi

Install the Database Software

Make sure the "ol7-122-rac1" and "ol7-122-rac2" virtual machines are started, then login to "ol7-122-rac1" as the oracle user and start the Oracle installer. Check that all services are up using "crsctl stat res -t", as described before.
I could have run the OUI in silent mode using this edited response file (db_install.rsp) with the following command.
$ db_env
$ cd /media/sf_12.2.0.1/database
$ ./runInstaller -silent -ignoreSysPrereqs -showProgress -responseFile /tmp/db_install.rsp
Instead, here's the interactive view.
$ db_env
$ cd /media/sf_12.2.0.1/database
$ ./runInstaller
Uncheck the security updates checkbox and click the "Next" button and "Yes" on the subsequent warning dialog.
DB - Configure Security Updates
Select the "Install database software only" option, then click the "Next" button.
DB - Select Installation Option
Accept the "Oracle Real Application Clusters database installation" option by clicking the "Next" button.
DB - Grid Installation Options
Make sure both nodes are selected, then click the "Next" button.
DB - Node Selection
Select the "Enterprise Edition" option, then click the "Next" button.
DB - Select Database Edition
Enter "/u01/app/oracle" as the Oracle base and "/u01/app/oracle/product/12.2.0.1/db_1" as the software location, then click the "Next" button.
DB - Specify Installation Location
Select the desired operating system groups, then click the "Next" button. In this case we are only using the "dba" group.
DB - Privileged Operating System Groups
Wait for the prerequisite check to complete. If there are any problems either click the "Fix & Check Again" button, or check the "Ignore All" checkbox and click the "Next" button.
DB - Perform Prerequisite Checks
If you are happy with the summary information, click the "Install" button.
DB - Summary
Wait while the installation takes place.
DB - Install Product
When prompted, run the configuration script on each node. When the scripts have been run on each node, click the "OK" button.
DB - Execute Configuration Scripts
Click the "Close" button to exit the installer.
DB - Finish
Shutdown both VMs and take snapshots. Remember to make a fresh zip of the ASM disks on the host machine, which you will need to restore if you revert to the post-db snapshots.
$ cd /u04/VirtualBox/ol7-122-rac
$ zip PostDB.zip *.vdi

Create a Database

Make sure the "ol7-122-rac1" and "ol7-122-rac2" virtual machines are started, then login to "ol7-122-rac1" as the oracle user and start the Database Creation Asistant (DBCA).
I could have run the DBCA in silent mode using this edited response file (dbca.rsp) with the following command.
db_env
dbca -silent -responseFile /tmp/dbca.rsp
Instead, here's the interactive view.
$ db_env
$ dbca
Select the "Create Database" option and click the "Next" button.
DBCA - Database Operation
Select the "Typical configuration" option. Enter the container database name (cdbrac), pluggable database name (pdb1) and administrator password. Click the "Next" button.
DBCA - Creation Mode
Wait for the prerequisite checks to complete. If there are any problems either fix them, or check the "Ignore All" checkbox and click the "Next" button. If there are no problems you will go directly to the summary screen.
If you are happy with the summary information, click the "Finish" button.
DBCA - Summary
Wait while the database creation takes place.
DBCA - Progress Page
If you want to modify passwords, click the "Password Management" button. When finished, click the "Close" button.
DBCA - Finish
The RAC database creation is now complete.

Check the Status of the RAC

There are several ways to check the status of the RAC. The srvctl utility shows the current configuration and status of the RAC database.
$ srvctl config database -d cdbrac
Database unique name: cdbrac
Database name: cdbrac
Oracle home: /u01/app/oracle/product/12.2.0.1/db_1
Oracle user: oracle
Spfile: +DATA/CDBRAC/PARAMETERFILE/spfile.306.938083453
Password file: +DATA/CDBRAC/PASSWORD/pwdcdbrac.285.938081999
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: 
Disk Groups: DATA
Mount point paths: 
Services: 
Type: RAC
Start concurrency: 
Stop concurrency: 
OSDBA group: dba
OSOPER group: 
Database instances: cdbrac1,cdbrac2
Configured nodes: ol7-122-rac1,ol7-122-rac2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services: 
Database is administrator managed
$

$ srvctl status database -d cdbrac
Instance cdbrac1 is running on node ol7-122-rac1
Instance cdbrac2 is running on node ol7-122-rac2
$
The V$ACTIVE_INSTANCES view can also display the current status of the instances.

$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Mar 8 11:04:42 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> SELECT inst_name FROM v$active_instances;


INST_NAME
--------------------------------------------------------------------------------
ol7-122-rac1.localdomain:cdbrac1
ol7-122-rac2.localdomain:cdbrac2

SQL>

Upgrading to Oracle 18c - 11g to 18c

Upgrading to Oracle Database 18c (Non-CDB) - 11g to 18c

This article provides an overview of upgrading an existing non-CDB database to Oracle 18c. Upgrades can be very complicated, so you must always read the upgrade manual, and test thoroughly before considering an upgrade of a production environment.
This article also includes the conversion of the upgraded database to a pluggable database. You don't have to do this step if you want a non-CDB instance.
Remember, 18c is essentially 12.2.0.2, so the possible upgrade options will be similar to those described in upgrading to Oracle Database 12c.
  • Assumptions
  • Prerequisities
  • Install 18c Software
  • Run preupgrade.jar
  • Perform Pre-Upgrade Actions
  • Upgrade the Database
  • Perform Post-Upgrade Actions
  • Create New Container Database (CDB)
  • Convert Non-CDB to PDB
  • Final Steps


Assumptions

This article is focused on upgrading a non-CDB database. If your starting point is a database using the multitenant architecture, you should be reading one of the following articles instead.
This article assumes your source database is of a version supported for direct upgrade to 18c.
11.2.0.3, 11.2.0.4, 12.1.0.1, 12.1.0.2, 12.2.0.1
In this example we are doing an upgrade from 11.2 to 18c. The process is very similar for all supported versions, but the pre-upgrade and post-upgrade fixup actions may vary a little.
It's important to have backups of everything before you start! Some of these steps are destructive, and if something goes wrong you have no alternative but to restore from backups and start again.
Remember, this article is not a replacement for reading the upgrade documentation. Each upgrade has the potential to be different, depending on what options are installed.

Prerequisities

Make sure you have all the OS prerequisites in place by running the 18c preinstall package. On Oracle Linux you can do this by installing the preinstall package. It probably makes sense to update the remaining packages also.
yum install -y oracle-database-preinstall-18c
yum update -y

Install 18c Software

You can read about the installation process in more detail here, but for this example I'll keep it brief. The following commands will perform a silent installation of the 18c software.
export ORACLE_HOME=$ORACLE_BASE/product/18.0.0/dbhome_1
export SOFTWARE_DIR=/u01/software
export ORA_INVENTORY=/u01/app/oraInventory

mkdir -p ${ORACLE_HOME}
cd $ORACLE_HOME

/bin/unzip -oq ${SOFTWARE_DIR}/LINUX.X64_180000_db_home.zip

./runInstaller -ignorePrereq -waitforcompletion -silent                        \
    -responseFile ${ORACLE_HOME}/install/response/db_install.rsp               \
    oracle.install.option=INSTALL_DB_SWONLY                                    \
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         \
    UNIX_GROUP_NAME=oinstall                                                   \
    INVENTORY_LOCATION=${ORA_INVENTORY}                                        \
    SELECTED_LANGUAGES=en,en_GB                                                \
    ORACLE_HOME=${ORACLE_HOME}                                                 \
    ORACLE_BASE=${ORACLE_BASE}                                                 \
    oracle.install.db.InstallEdition=EE                                        \
    oracle.install.db.OSDBA_GROUP=dba                                          \
    oracle.install.db.OSBACKUPDBA_GROUP=dba                                    \
    oracle.install.db.OSDGDBA_GROUP=dba                                        \
    oracle.install.db.OSKMDBA_GROUP=dba                                        \
    oracle.install.db.OSRACDBA_GROUP=dba                                       \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 \
    DECLINE_SECURITY_UPDATES=true
Run the root scripts when prompted.
As a root user, execute the following script(s):
        1. /u01/app/oracle/product/18.0.0/dbhome_1/root.sh
At this point you should also patch the new Oracle home, but in this case we will forgo that step to keep things simple.

Run preupgrade.jar

Download the latest "preupgrade.jar" file from MOS 884522.1. If you don't have MOS access you can miss out the next step.
Put the latest "preupgrade.jar" into the 18c Oracle home.
export ORACLE_HOME=$ORACLE_BASE/product/18.0.0/dbhome_1
cd $ORACLE_HOME/rdbms/admin
unzip -o /u01/software/preupgrade_181_cbuild_5_lf.zip
Make sure you are using the original Oracle home and run the "preupgrade.jar".
export ORACLE_SID=db11g
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1

$ORACLE_BASE/product/18.0.0/dbhome_1/jdk/bin/java -jar $ORACLE_BASE/product/18.0.0/dbhome_1/rdbms/admin/preupgrade.jar TERMINAL TEXT
Here is the output from an example run against an 11.2 database.
$ $ORACLE_BASE/product/18.0.0/dbhome_1/jdk/bin/java -jar $ORACLE_BASE/product/18.0.0/dbhome_1/rdbms/admin/preupgrade.jar TERMINAL TEXT
Report generated by Oracle Database Pre-Upgrade Information Tool Version
18.0.0.0.0 Build: 5 on 2018-11-24T10:21:34

Upgrade-To version: 18.0.0.0.0

=======================================
Status of the database prior to upgrade
=======================================
      Database Name:  DB11G
     Container Name:  Not Applicable in Pre-12.1 database
       Container ID:  Not Applicable in Pre-12.1 database
            Version:  11.2.0.4.0
         Compatible:  11.2.0.4.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  14
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  EE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Oracle Workspace Manager               [to be upgraded]  VALID
  OLAP Analytic Workspace                [to be upgraded]  VALID
  Oracle Enterprise Manager Repository   [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Spatial                         [to be upgraded]  VALID
  Expression Filter                      [to be upgraded]  VALID
  Rule Manager                           [to be upgraded]  VALID
  Oracle OLAP API                        [to be upgraded]  VALID

==============
BEFORE UPGRADE
==============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  1.  Update NUMERIC INITIALIZATION PARAMETERS to meet estimated minimums.
      This action may be done now or when starting the database in upgrade mode
      using the 18.0.0.0.0 ORACLE HOME.

       Parameter                                 Currently  18.0.0.0.0 minimum
       ---------                                 ---------  ------------------
       processes                                       150                 300

      The database upgrade process requires certain initialization parameters
      to meet minimum values.  The Oracle upgrade process itself has minimum
      values which may be higher and are marked with an asterisk.  After
      upgrading, those asterisked parameter values may be reset if needed.

  2.  Remove the EM repository.

      - Copy the $ORACLE_HOME/rdbms/admin/emremove.sql script from the target
      18.0.0.0.0 ORACLE_HOME into the source 11.2.0.4.0 ORACLE_HOME.

      Step 1: If database control is configured, stop EM Database Control,
      using the following command

        $> emctl stop dbconsole

      Step 2: Connect to the database using the SYS account AS SYSDBA

        SET ECHO ON;
        SET SERVEROUTPUT ON;
        @emremove.sql

      Without the set echo and serveroutput commands, you will not be able to
      follow the progress of the script.

      The database has an Enterprise Manager Database Control repository.

      Starting with Oracle Database 12c, the local Enterprise Manager Database
      Control does not exist anymore. The repository will be removed from your
      database during the upgrade.  This step can be manually performed before
      the upgrade to reduce downtime.

  3.  Remove OLAP Catalog by running the 11.2.0.4.0 SQL script
      $ORACLE_HOME/olap/admin/catnoamd.sql script.

      The OLAP Catalog component, AMD, exists in the database.

      Starting with Oracle Database 12c, the OLAP Catalog (OLAP AMD) is
      desupported and will be automatically marked as OPTION OFF during the
      database upgrade if present. Oracle recommends removing OLAP Catalog
      (OLAP AMD) before database upgrade.  This step can be manually performed
      before the upgrade to reduce downtime.

  4.  Upgrade Oracle Application Express (APEX) manually before the database
      upgrade.

      The database contains APEX version 3.2.1.00.12. Upgrade APEX to at least
      version 5.1.3.00.05.

      Starting with Oracle Database Release 18, APEX is not upgraded
      automatically as part of the database upgrade. Refer to My Oracle Support
      Note 1088970.1 for information about APEX installation and upgrades.

  5.  (AUTOFIXUP) Gather stale data dictionary statistics prior to database
      upgrade in off-peak time using:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Dictionary statistics do not exist or are stale (not up-to-date).

      Dictionary statistics help the Oracle optimizer find efficient SQL
      execution plans and are essential for proper upgrade timing. Oracle
      recommends gathering dictionary statistics in the last 24 hours before
      database upgrade.

      For information on managing optimizer statistics, refer to the 11.2.0.4
      Oracle Database Performance Tuning Guide.

  6.  Directly grant ADMINISTER DATABASE TRIGGER privilege to the owner of the
      trigger or drop and re-create the trigger with a user that was granted
      directly with such. You can list those triggers using "SELECT OWNER,
      TRIGGER_NAME FROM DBA_TRIGGERS WHERE TRIM(BASE_OBJECT_TYPE)='DATABASE'
      AND OWNER NOT IN (SELECT GRANTEE FROM DBA_SYS_PRIVS WHERE
      PRIVILEGE='ADMINISTER DATABASE TRIGGER')"

      There is one or more database triggers whose owner does not have the
      right privilege on the database.

      The creation of database triggers must be done by users granted with
      ADMINISTER DATABASE TRIGGER privilege. Privilege must have been granted
      directly.

  7.  (AUTOFIXUP) Gather statistics on fixed objects prior the upgrade.

      None of the fixed object tables have had stats collected.

      Gathering statistics on fixed objects, if none have been gathered yet, is
      recommended prior to upgrading.

      For information on managing optimizer statistics, refer to the 11.2.0.4
      Oracle Database Performance Tuning Guide.

  INFORMATION ONLY
  ================
  8.  To help you keep track of your tablespace allocations, the following
      AUTOEXTEND tablespaces are expected to successfully EXTEND during the
      upgrade process.

                                                 Min Size
      Tablespace                        Size     For Upgrade
      ----------                     ----------  -----------
      SYSAUX                             510 MB       720 MB
      SYSTEM                             740 MB      1183 MB
      TEMP                                29 MB       150 MB
      UNDOTBS1                            70 MB       446 MB

      Minimum tablespace sizes for upgrade are estimates.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database DB11G
  which are identified above as BEFORE UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following

    SQL>@/u01/app/oracle/cfgtoollogs/db11g/preupgrade/preupgrade_fixups.sql

=============
AFTER UPGRADE
=============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  9.  Upgrade the database time zone file using the DBMS_DST package.

      The database is using time zone file version 14 and the target 18.0.0.0.0
      release ships with time zone file version 31.

      Oracle recommends upgrading to the desired (latest) version of the time
      zone file.  For more information, refer to "Upgrading the Time Zone File
      and Timestamp with Time Zone Data" in the 18.0.0.0.0 Oracle Database
      Globalization Support Guide.

  10. (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
      command:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Oracle recommends gathering dictionary statistics after upgrade.

      Dictionary statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans. After a database
      upgrade, statistics need to be re-gathered as there can now be tables
      that have significantly changed during the upgrade or new tables that do
      not have statistics gathered yet.

  11. Gather statistics on fixed objects after the upgrade and when there is a
      representative workload on the system using the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      This recommendation is given for all preupgrade runs.

      Fixed object statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans.  Those
      statistics are specific to the Oracle Database release that generates
      them, and can be stale upon database upgrade.

      For information on managing optimizer statistics, refer to the 11.2.0.4
      Oracle Database Performance Tuning Guide.

  INFORMATION ONLY
  ================
  12. Check the Oracle documentation for the identified components for their
      specific upgrade procedure.

      The database upgrade script will not upgrade the following Oracle
      components:  OLAP Catalog,OWB

      The Oracle database upgrade script upgrades most, but not all Oracle
      Database components that may be installed.  Some components that are not
      upgraded may have their own upgrade scripts, or they may be deprecated or
      obsolete.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database DB11G
  which are identified above as AFTER UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following

    SQL>@/u01/app/oracle/cfgtoollogs/db11g/preupgrade/postupgrade_fixups.sql


==================
PREUPGRADE SUMMARY
==================
  /u01/app/oracle/cfgtoollogs/db11g/preupgrade/preupgrade.log
  /u01/app/oracle/cfgtoollogs/db11g/preupgrade/preupgrade_fixups.sql
  /u01/app/oracle/cfgtoollogs/db11g/preupgrade/postupgrade_fixups.sql

Execute fixup scripts as indicated below:

Before upgrade log into the database and execute the preupgrade fixups
@/u01/app/oracle/cfgtoollogs/db11g/preupgrade/preupgrade_fixups.sql

After the upgrade:

Log into the database and execute the postupgrade fixups
@/u01/app/oracle/cfgtoollogs/db11g/preupgrade/postupgrade_fixups.sql

Preupgrade complete: 2018-11-24T10:21:36
$

Perform Pre-Upgrade Actions

The output from the "preupgrade.jar" lists a number of pre-upgrade recommendations. Some must be manually applied. Others are incorporated into the "preupgrade_fixups.sql" script. In the following example we run all the manual operations as well as the "preupgrade_fixups.sql" script.
# 1) Increase the processes parameter.
sqlplus / as sysdba <<EOF
alter system set processes=300 scope=spfile;
shutdown immediate;
startup;
exit;
EOF

# 2) Remove EM DB Console config.
cp $ORACLE_BASE/product/18.0.0/dbhome_1/rdbms/admin/emremove.sql $ORACLE_HOME/rdbms/admin/emremove.sql
sqlplus / as sysdba <<EOF
SET ECHO ON;
SET SERVEROUTPUT ON;
@$ORACLE_HOME/rdbms/admin/emremove.sql
exit;
EOF

# 3) Remove OLAP catalog.
sqlplus / as sysdba <<EOF
@$ORACLE_HOME/olap/admin/catnoamd.sql
exit;
EOF

# 4) Ignoring the APEX upgrade. This is a junk test instance. Normally APEX would be at latest version.
# 5) Included in AUTOFIXUP.
# 6) This will be unnecessary after removal of EM repository above.
# 7) Included in AUTOFIXUP.

# Recompile invalid objects.
sqlplus / as sysdba <<EOF
@$ORACLE_HOME/rdbms/admin/utlrp.sql

SET SERVEROUTPUT ON;
EXECUTE DBMS_PREUP.INVALID_OBJECTS;
exit;
EOF

# Run preupgrade-fixups.sql script.
sqlplus / as sysdba <<EOF
@/u01/app/oracle/cfgtoollogs/db11g/preupgrade/preupgrade_fixups.sql
exit;
EOF

Upgrade the Database

With the pre-upgrade actions complete we can start the upgrade. Shutdown the source database.
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
Copy the config files from the old to the new Oracle home. You should check the contents of the "listener.ora" file to see if there are any references to the Oracle home path. If there are, amend them.
cp $ORACLE_HOME/network/admin/*.ora $ORACLE_BASE/product/18.0.0/dbhome_1/network/admin

# Add this to $ORACLE_BASE/product/18.0.0/dbhome_1/network/admin/sqlnet.ora
# Need to correct password versions and remove this.
cat >> $ORACLE_BASE/product/18.0.0/dbhome_1/network/admin/sqlnet.ora <<EOF
# This should be temporary while you deal with old passwords.
SQLNET.ALLOWED_LOGON_VERSION_SERVER=11
EOF

cp $ORACLE_HOME/dbs/orapwdb11g $ORACLE_BASE/product/18.0.0/dbhome_1/dbs/
cp $ORACLE_HOME/dbs/spfiledb11g.ora $ORACLE_BASE/product/18.0.0/dbhome_1/dbs/
Switch to the 18c listener.
lsnrctl stop

export ORACLE_HOME=$ORACLE_BASE/product/18.0.0/dbhome_1
export PATH=${ORACLE_HOME}/bin:$PATH

lsnrctl start
Start the database using the 18c Oracle home, ready for the upgrade.
sqlplus / as sysdba <<EOF
startup upgrade;
exit;
EOF
You can run the upgrade using either of the following commands. The second is actually just a shorthand for the former.
# Regular upgrade command.
cd $ORACLE_HOME/rdbms/admin
$ORACLE_HOME/perl/bin/perl catctl.pl catupgrd.sql

# Shorthand command.
$ORACLE_HOME/bin/dbupgrade
Here is the output from an example run against an 11.2 database.
$ $ORACLE_HOME/bin/dbupgrade

Argument list for [/u01/app/oracle/product/18.0.0/dbhome_1/rdbms/admin/catctl.pl]
Run in                c = 0
Do not run in         C = 0
Input Directory       d = 0
Echo OFF              e = 1
Simulate              E = 0
Forced cleanup        F = 0
Log Id                i = 0
Child Process         I = 0
Log Dir               l = 0
Priority List Name    L = 0
Upgrade Mode active   M = 0
SQL Process Count     n = 0
SQL PDB Process Count N = 0
Open Mode Normal      o = 0
Start Phase           p = 0
End Phase             P = 0
Reverse Order         r = 0
AutoUpgrade Resume    R = 0
Script                s = 0
Serial Run            S = 0
RO User Tablespaces   T = 0
Display Phases        y = 0
Debug catcon.pm       z = 0
Debug catctl.pl       Z = 0

catctl.pl VERSION: [18.0.0.0.0]
           STATUS: [Production]
            BUILD: [RDBMS_18.3.0.0.0DBRU_LINUX.X64_180627]


/u01/app/oracle/product/18.0.0/dbhome_1/rdbms/admin/orahome = [/u01/app/oracle/product/18.0.0/dbhome_1]
/u01/app/oracle/product/18.0.0/dbhome_1/bin/orabasehome = [/u01/app/oracle/product/18.0.0/dbhome_1]
catctlGetOrabase = [/u01/app/oracle/product/18.0.0/dbhome_1]

Analyzing file /u01/app/oracle/product/18.0.0/dbhome_1/rdbms/admin/catupgrd.sql

Log file directory = [/tmp/cfgtoollogs/upgrade20181124104231]

catcon::set_log_file_base_path: ALL catcon-related output will be written to [/tmp/cfgtoollogs/upgrade20181124104231/catupgrd_catcon_4970.lst]

catcon::set_log_file_base_path: catcon: See [/tmp/cfgtoollogs/upgrade20181124104231/catupgrd*.log] files for output generated by scripts

catcon::set_log_file_base_path: catcon: See [/tmp/cfgtoollogs/upgrade20181124104231/catupgrd_*.lst] files for spool files, if any


Number of Cpus        = 2
Database Name         = db11g
DataBase Version      = 11.2.0.4.0
catcon::set_log_file_base_path: ALL catcon-related output will be written to [/u01/app/oracle/product/18.0.0/dbhome_1/cfgtoollogs/db11g/upgrade20181124104232/catupgrd_catcon_4970.lst]

catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/product/18.0.0/dbhome_1/cfgtoollogs/db11g/upgrade20181124104232/catupgrd*.log] files for output generated by scripts

catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/product/18.0.0/dbhome_1/cfgtoollogs/db11g/upgrade20181124104232/catupgrd_*.lst] files for spool files, if any


Log file directory = [/u01/app/oracle/product/18.0.0/dbhome_1/cfgtoollogs/db11g/upgrade20181124104232]

Parallel SQL Process Count            = 4
Components in [db11g]
    Installed [APEX APS CATALOG CATJAVA CATPROC CONTEXT JAVAVM ORDIM OWM SDO XDB XML XOQ]
Not Installed [DV EM MGW ODM OLS RAC WK]

------------------------------------------------------
Phases [0-108]         Start Time:[2018_11_24 10:42:33]
------------------------------------------------------
***********   Executing Change Scripts   ***********
Serial   Phase #:0    [db11g] Files:1    Time: 106s
***************   Catalog Core SQL   ***************
Serial   Phase #:1    [db11g] Files:5    Time: 63s
Restart  Phase #:2    [db11g] Files:1    Time: 0s
***********   Catalog Tables and Views   ***********
Parallel Phase #:3    [db11g] Files:19   Time: 18s
Restart  Phase #:4    [db11g] Files:1    Time: 0s
*************   Catalog Final Scripts   ************
Serial   Phase #:5    [db11g] Files:7    Time: 21s
*****************   Catproc Start   ****************
Serial   Phase #:6    [db11g] Files:1    Time: 15s
*****************   Catproc Types   ****************
Serial   Phase #:7    [db11g] Files:2    Time: 12s
Restart  Phase #:8    [db11g] Files:1    Time: 0s
****************   Catproc Tables   ****************
Parallel Phase #:9    [db11g] Files:66   Time: 29s
Restart  Phase #:10   [db11g] Files:1    Time: 0s
*************   Catproc Package Specs   ************
Serial   Phase #:11   [db11g] Files:1    Time: 76s
Restart  Phase #:12   [db11g] Files:1    Time: 0s
**************   Catproc Procedures   **************
Parallel Phase #:13   [db11g] Files:94   Time: 10s
Restart  Phase #:14   [db11g] Files:1    Time: 0s
Parallel Phase #:15   [db11g] Files:117  Time: 23s
Restart  Phase #:16   [db11g] Files:1    Time: 0s
Serial   Phase #:17   [db11g] Files:17   Time: 3s
Restart  Phase #:18   [db11g] Files:1    Time: 0s
*****************   Catproc Views   ****************
Parallel Phase #:19   [db11g] Files:32   Time: 22s
Restart  Phase #:20   [db11g] Files:1    Time: 0s
Serial   Phase #:21   [db11g] Files:3    Time: 10s
Restart  Phase #:22   [db11g] Files:1    Time: 1s
Parallel Phase #:23   [db11g] Files:24   Time: 136s
Restart  Phase #:24   [db11g] Files:1    Time: 0s
Parallel Phase #:25   [db11g] Files:12   Time: 80s
Restart  Phase #:26   [db11g] Files:1    Time: 0s
Serial   Phase #:27   [db11g] Files:1    Time: 0s
Serial   Phase #:28   [db11g] Files:3    Time: 4s
Serial   Phase #:29   [db11g] Files:1    Time: 0s
Restart  Phase #:30   [db11g] Files:1    Time: 0s
***************   Catproc CDB Views   **************
Serial   Phase #:31   [db11g] Files:1    Time: 0s
Restart  Phase #:32   [db11g] Files:1    Time: 1s
Serial   Phase #:34   [db11g] Files:1    Time: 0s
*****************   Catproc PLBs   *****************
Serial   Phase #:35   [db11g] Files:288  Time: 24s
Serial   Phase #:36   [db11g] Files:1    Time: 0s
Restart  Phase #:37   [db11g] Files:1    Time: 0s
Serial   Phase #:38   [db11g] Files:2    Time: 7s
Restart  Phase #:39   [db11g] Files:1    Time: 0s
***************   Catproc DataPump   ***************
Serial   Phase #:40   [db11g] Files:3    Time: 52s
Restart  Phase #:41   [db11g] Files:1    Time: 0s
******************   Catproc SQL   *****************
Parallel Phase #:42   [db11g] Files:13   Time: 95s
Restart  Phase #:43   [db11g] Files:1    Time: 1s
Parallel Phase #:44   [db11g] Files:11   Time: 9s
Restart  Phase #:45   [db11g] Files:1    Time: 0s
Parallel Phase #:46   [db11g] Files:3    Time: 2s
Restart  Phase #:47   [db11g] Files:1    Time: 0s
*************   Final Catproc scripts   ************
Serial   Phase #:48   [db11g] Files:1    Time: 6s
Restart  Phase #:49   [db11g] Files:1    Time: 0s
**************   Final RDBMS scripts   *************
Serial   Phase #:50   [db11g] Files:1    Time: 26s
************   Upgrade Component Start   ***********
Serial   Phase #:51   [db11g] Files:1    Time: 0s
Restart  Phase #:52   [db11g] Files:1    Time: 0s
**********   Upgrading Java and non-Java   *********
Serial   Phase #:53   [db11g] Files:2    Time: 507s
*****************   Upgrading XDB   ****************
Restart  Phase #:54   [db11g] Files:1    Time: 0s
Serial   Phase #:56   [db11g] Files:3    Time: 28s
Serial   Phase #:57   [db11g] Files:3    Time: 6s
Parallel Phase #:58   [db11g] Files:9    Time: 4s
Parallel Phase #:59   [db11g] Files:25   Time: 4s
Serial   Phase #:60   [db11g] Files:4    Time: 6s
Serial   Phase #:61   [db11g] Files:1    Time: 0s
Serial   Phase #:62   [db11g] Files:31   Time: 5s
Serial   Phase #:63   [db11g] Files:1    Time: 0s
Parallel Phase #:64   [db11g] Files:6    Time: 3s
Serial   Phase #:65   [db11g] Files:2    Time: 25s
Serial   Phase #:66   [db11g] Files:3    Time: 86s
****************   Upgrading ORDIM   ***************
Restart  Phase #:67   [db11g] Files:1    Time: 1s
Serial   Phase #:69   [db11g] Files:1    Time: 0s
Parallel Phase #:70   [db11g] Files:2    Time: 47s
Serial   Phase #:71   [db11g] Files:1    Time: 55s
Restart  Phase #:72   [db11g] Files:1    Time: 0s
Parallel Phase #:73   [db11g] Files:2    Time: 12s
Serial   Phase #:74   [db11g] Files:2    Time: 1s
*****************   Upgrading SDO   ****************
Restart  Phase #:75   [db11g] Files:1    Time: 1s
Serial   Phase #:77   [db11g] Files:1    Time: 47s
Serial   Phase #:78   [db11g] Files:1    Time: 1s
Restart  Phase #:79   [db11g] Files:1    Time: 0s
Serial   Phase #:80   [db11g] Files:1    Time: 21s
Restart  Phase #:81   [db11g] Files:1    Time: 0s
Parallel Phase #:82   [db11g] Files:3    Time: 67s
Restart  Phase #:83   [db11g] Files:1    Time: 0s
Serial   Phase #:84   [db11g] Files:1    Time: 5s
Restart  Phase #:85   [db11g] Files:1    Time: 0s
Serial   Phase #:86   [db11g] Files:1    Time: 8s
Restart  Phase #:87   [db11g] Files:1    Time: 1s
Parallel Phase #:88   [db11g] Files:4    Time: 62s
Restart  Phase #:89   [db11g] Files:1    Time: 1s
Serial   Phase #:90   [db11g] Files:1    Time: 0s
Restart  Phase #:91   [db11g] Files:1    Time: 0s
Serial   Phase #:92   [db11g] Files:2    Time: 7s
Restart  Phase #:93   [db11g] Files:1    Time: 0s
Serial   Phase #:94   [db11g] Files:1    Time: 1s
Restart  Phase #:95   [db11g] Files:1    Time: 0s
*******   Upgrading ODM, WK, EXF, RUL, XOQ   *******
Serial   Phase #:96   [db11g] Files:1    Time: 29s
Restart  Phase #:97   [db11g] Files:1    Time: 0s
***********   Final Component scripts    ***********
Serial   Phase #:98   [db11g] Files:1    Time: 2s
*************   Final Upgrade scripts   ************
Serial   Phase #:99   [db11g] Files:1    Time: 231s
*******************   Migration   ******************
Serial   Phase #:100  [db11g] Files:1    Time: 63s
***   End PDB Application Upgrade Pre-Shutdown   ***
Serial   Phase #:101  [db11g] Files:1    Time: 1s
Serial   Phase #:102  [db11g] Files:1    Time: 0s
Serial   Phase #:103  [db11g] Files:1    Time: 123s
*****************   Post Upgrade   *****************
Serial   Phase #:104  [db11g] Files:1    Time: 26s
****************   Summary report   ****************
Serial   Phase #:105  [db11g] Files:1    Time: 1s
***   End PDB Application Upgrade Post-Shutdown   **
Serial   Phase #:106  [db11g] Files:1    Time: 0s
Serial   Phase #:107  [db11g] Files:1    Time: 0s
Serial   Phase #:108  [db11g] Files:1     Time: 31s

------------------------------------------------------
Phases [0-108]         End Time:[2018_11_24 11:22:04]
------------------------------------------------------

Grand Total Time: 2374s

 LOG FILES: (/u01/app/oracle/product/18.0.0/dbhome_1/cfgtoollogs/db11g/upgrade20181122104232/catupgrd*.log)

Upgrade Summary Report Located in:
/u01/app/oracle/product/18.0.0/dbhome_1/cfgtoollogs/db11g/upgrade20181122104232/upg_summary.log

Grand Total Upgrade Time:    [0d:0h:39m:34s]
$
The database is shutdown at the end of the upgrade process, so you need to start it before moving on to the post-upgrade actions.
sqlplus / as sysdba <<EOF
startup
exit;
EOF

Perform Post-Upgrade Actions

The output from the "preupgrade.jar" lists a number of post-upgrade recommendations. Some must be manually applied. Others are incorporated into the "postupgrade_fixups.sql" script. In the following example we run all the manual operations as well as the "postupgrade_fixups.sql" script.
# 9) Time zone file.
sqlplus / as sysdba <<EOF

-- Check current settings.
SELECT * FROM v$timezone_file;

SHUTDOWN IMMEDIATE;
STARTUP UPGRADE;

-- Begin upgrade to the latest version.
SET SERVEROUTPUT ON
DECLARE
  l_tz_version PLS_INTEGER;
BEGIN
  l_tz_version := DBMS_DST.get_latest_timezone_version;

  DBMS_OUTPUT.put_line('l_tz_version=' || l_tz_version);
  DBMS_DST.begin_upgrade(l_tz_version);
END;
/

SHUTDOWN IMMEDIATE;
STARTUP;

-- Do the upgrade.
SET SERVEROUTPUT ON
DECLARE
  l_failures   PLS_INTEGER;
BEGIN
  DBMS_DST.upgrade_database(l_failures);
  DBMS_OUTPUT.put_line('DBMS_DST.upgrade_database : l_failures=' || l_failures);
  DBMS_DST.end_upgrade(l_failures);
  DBMS_OUTPUT.put_line('DBMS_DST.end_upgrade : l_failures=' || l_failures);
END;
/

-- Check new settings.
SELECT * FROM v$timezone_file;

COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A20

SELECT property_name, property_value
FROM   database_properties
WHERE  property_name LIKE 'DST_%'
ORDER BY property_name;

exit;
EOF

# 10) AUTOFIXUP

# 11) Gather fixed object stats.
sqlplus / as sysdba <<EOF
EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
exit;
EOF

# AUTOFIXUP
sqlplus / as sysdba <<EOF
@/u01/app/oracle/cfgtoollogs/db11g/preupgrade/postupgrade_fixups.sql
exit;
EOF
Assuming you didn't hit any problems along the way, your database is upgraded and ready to go now. The following steps are only necessary if you want to convert the non-CDB instance to a pluggable database (PDB).

Create New Container Database (CDB)

There are a number of considerations when creating a container database, but for this example we will keep it simple. The command below creates a new container database (CDB) with no user-defined pluggable databases (PDBs).
# Create new instance.
export SYS_PASSWORD=SysPassword1
export ORACLE_SID=cdb1

dbca -silent -createDatabase                                                    \
     -templateName General_Purpose.dbc                                          \
     -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE           \
     -characterSet AL32UTF8                                                     \
     -sysPassword ${SYS_PASSWORD}                                               \
     -systemPassword ${SYS_PASSWORD}                                            \
     -createAsContainerDatabase true                                            \
     -numberOfPDBs 0                                                            \
     -databaseType MULTIPURPOSE                                                 \
     -automaticMemoryManagement false                                           \
     -totalMemory 2000                                                          \
     -storageType FS                                                            \
     -datafileDestination "/u02/oradata/"                                       \
     -redoLogFileSize 500                                                       \
     -emConfiguration NONE                                                      \
     -ignorePreReqs
For a proper conversion we would have to make sure the CDB had all necessary configuration in place, including options and initialisation parameters. We will ignore the rest of the instance setup to keep it simple.

Convert Non-CDB to PDB

Describe the non-CDB instance and turn it off.
export ORACLE_SID=db11g
sqlplus / as sysdba <<EOF

SHUTDOWN IMMEDIATE;
STARTUP OPEN READ ONLY;

BEGIN
  DBMS_PDB.DESCRIBE(
    pdb_descr_file => '/u01/software/db11g.xml');
END;
/

SHUTDOWN IMMEDIATE;

exit;
EOF
Create a PDB using description of the non-CDB, moving the datafiles into the new location, remembering to run the "noncdb_to_pdb.sql" to clean up before opening the pluggable database.
export ORACLE_SID=cdb1
mkdir -p /u02/oradata/CDB1/pdb1/

sqlplus / as sysdba <<EOF

CREATE PLUGGABLE DATABASE pdb1 USING '/u01/software/db11g.xml'
  MOVE
  FILE_NAME_CONVERT = ('/u02/oradata/db11g/', '/u02/oradata/CDB1/pdb1/');

ALTER SESSION SET CONTAINER=pdb1;

@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

ALTER PLUGGABLE DATABASE OPEN;
ALTER PLUGGABLE DATABASE SAVE STATE;

exit;
EOF

Final Steps

We need to clean up the remains of the non-CDB instance. We can use the DBCA to do this.
dbca -silent -deleteDatabase -sourceDB db11g -sysDBAUserName sys -sysDBAPassword ${SYS_PASSWORD}
We can delete any remaining files.
rm /u01/app/oracle/product/11.2.0.4/db_1/dbs/*db11g*
rm /u01/app/oracle/product/18.0.0/dbhome_1/dbs/*db11g*

rm -Rf $ORACLE_BASE/admin/db11g
rm -Rf /u01/app/oracle/diag/rdbms/db11g
rm -Rf /u02/oradata/db11g
Edit the "/etc/oratab" file as required.

If you are using APEX or ORDS, you probably want to validate them (validate APEXvalidate ORDS).

lunes, 9 de marzo de 2020

DETECTANDO FRAGMENTACION DE INDICES

 Si necesitamos revisar una gran cantidad de Indices se vuelve una tarea tediosa.

A continuación un script que nos permite agilizar este proceso, revisando todos los indices de un equema en particular.

-- by Fabian Crea - DBA ORACLE
prompt -- Drop and create temporary table to hold stats...


drop table my_index_stats
/
create table my_index_stats (
        index_name              varchar2(30),
        height                  number(8),
        del_lf_rows             number(8),
        if_rows                 number(8),
        distinct_keys           number(8),
        rows_per_key            number(10,2),
        blks_gets_per_access    number(10,2)
)
/

prompt -- Save script which we will later use to populate the above table...
insert into my_index_stats
select NAME, HEIGHT, DEL_LF_ROWS,LF_ROWS, DISTINCT_KEYS, ROWS_PER_KEY,
       BLKS_GETS_PER_ACCESS
from   INDEX_STATS
-- Note this open line...

save /tmp/save_index_stats.sql replace

prompt
prompt -- Spool listing with validate commands...
col line1 newline
col line2 newline
col line3 newline
set pagesize 0
set echo off
set termout off
set trimspool on
set feed off
set linesize 200
spool /tmp/validate_indexes.sql
select 'prompt Process table '||owner||'.'||table_name||
       ', index '||index_name||'...' line1,
       'validate index '||owner||'.'||index_name||';' line2,
       '@/tmp/save_index_stats.sql' line3
from   sys.dba_indexes where owner = 'SCOTT'
order  by table_name, index_name
/
spool off
set termout on
set feed on
 


prompt
prompt -- Run script to validate indexes...
@/tmp/validate_indexes.sql

prompt -- Print nice report...
set pagesize 50000
set trimspool on
col height format 99999
col del_rows format 9999999
col rows/key format 999999.9
spool idxfrag.lst
select INDEX_NAME, HEIGHT, DEL_LF_ROWS "DEL_ROWS",LF_ROWS, DISTINCT_KEYS "DIST KEYS",
       ROWS_PER_KEY "ROWS/KEY",
       BLKS_GETS_PER_ACCESS "BLKS/ACCESS"
from   MY_INDEX_STATS
/
spool off

-- Cleanup
drop table my_index_stats
/

prompt
prompt Report is in idxfrag.lst
prompt Done!!!

RMAN - Cuando no se encuentra un archive log --- RMAN-06726: could not locate archived log

  Lo importante en todo esto, es estar dentro del catalogo correspondiente, sino el crosscheck NO FNCIONA !!   oracle backup of logfiles is ...