RAC Attack - Oracle Cluster Database at Home/RAC Attack Automation

Whether you're a participant who has already done the early labs dozens of times or an instructor who's teaching a session that focuses on a later lab, it is often useful to skip earlier labs and focus on later labs in the RAC Attack curriculum. Code to automate the RAC Attack labs is currently being developed and tested.


This page will contain instructions for automatically building a standard RAC Attack environment.

Quick Start edit

At this point in time, we are working to automate the third and fourth labs - Install Linux and Create Cluster.

  1. Complete the first three labs: Hardware Requirements, Software Components and Prepare Host. Do not download Oracle Linux; just the database and cluster software.
  2. Download and install Vagrant 1.5.1
  3. Download and unzip http://racattack.org/vagrantfile.zip (note that this file changes frequently as we work on it)
  4. Open a command prompt and change into the directory where you unzipped vagrantfile.zip
  5. cd vagrantfile-master\OracleLinux\racattack12cR1
  6. vagrant up
  7. vagrant ssh collabn1
  8. sudo su - oracle -c vncserver
  9. Run the vnc client of your choice and connect to vnc://192.168.78.51:1
  10. discuss issues at http://racattack.org/list or https://github.com/racattack/vagrantfile/issues

You can now skip to Connecting to the virtual machine

Credits edit

This project came to you by the RAC Attack Team


Initial version: Alvaro Miranda 14/04


Getting started edit

For this implementation, we will be using Vagrant, to manage VirtualBox and automate the deployment.

Software used in this implementation edit

Besides the software listed in RAC_Attack_12c/Software_Components for SSH, VNC and Grid and Database component, the following software have been used and tested in this implementation.

OSes that are known to work edit

This implementation has been tested with the following operating systems:

  • Windows 7 Professional 64 bit
  • OracleLinux 6.5 64 bit
  • Apple Mac OS X 10.9.2

OS used in the guest machine edit

The OS used in the guest machine is Oracle Linux 6.5 + updates.

The version of the box used reflect the day when the box was created and updated:

alvaros-mini:oracle65 alvarom$ vagrant box outdated --global

* 'racattack/oracle65' (v14.03.29) is up to date

alvaros-mini:oracle65 alvarom$

This version of racattack/oracle65 was created and updated to 14.03.29


Hardware requirements edit

  1. Please review RAC_Attack_12c/Hardware_Requirements and check you meet the minimum hardware requirements.

Software Components edit

  1. Go to RAC_Attack_12c/Software_Components and ensure you have all the Software Components listed there.



Vagrant edit

For this lab, you need vagrant, go to www.vagrantup.com/downloads.html , download and install vagrant software.

Introduction to Vagrant - Vagrant 101 edit

On this lab, we will use vagrant, however it is left to the reader visit the Vagrant documentation in order to learn what other features can be useful outside this lab.


From why-vagrant page:

Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.


Once the software is installed, a normal deployment goes like this:


  1. Download a vagrant box
  2. Create a Vagrantfile



Let's execute some commands with vagrant:


alvaros-mini:~ alvarom$ vagrant --help
 Usage: vagrant [options] <command> [<args>]
 -v, --version Print the version and exit.
 -h, --help Print this help.

alvaros-mini:~ alvarom$ vagrant --version
Vagrant 1.5.1

alvaros-mini:~ alvarom$ vagrant box list

alvaros-mini:~ alvarom$


vagrant box edit

A vagrant box is a virtual machine template with configurations made specifically for vagrant. In order to create a box, you need to follow the steps listed at base box documentation

The box used in the lab has been created using packer version 0.5.2

Since vagrant 1.5.x you can download boxes from the internet with a simple command:

vagrant box add racattack/oracle65

This will download the base box used for this lab.

At this point, the box racattack/oracle65 is in your system, and you can use it.

Vagrantfile edit

Vagrant file is where the automation starts, it will include information about what box to use, from where get it, and will execute the customization listed in the Vagrantfile

According to vagrantfile documentation, Vagrantfile is:

The primary function of the Vagrantfile is to describe the type of machine required for a project, and how to configure and provision these machines. Vagrantfiles are called Vagrantfiles because the actual literal filename for the file is Vagrantfile (casing doesn't matter).

Vagrant is meant to run with one Vagrantfile per project, and the Vagrantfile is supposed to be committed to version control. This allows other developers involved in the project to check out the code, run vagrant up, and be on their way. Vagrantfiles are portable across every platform Vagrant supports.

The syntax of Vagrantfiles is Ruby, but knowledge of the Ruby programming language is not necessary to make modifications to the Vagrantfile, since it is mostly simple variable assignment. In fact, Ruby isn't even the most popular community Vagrant is used within, which should help show you that despite not having Ruby knowledge, people are very successful with Vagrant.

To create a new Vagrantfile, you can :


vagrant init racattack/oracle65


This will create a simple Vagrantfile on the directory where we are executing this command.


Let's enumerate what we have learned so far:


To download a vagrant box

  • vagrant box add racattack/oracle65


To list the boxes in our system

  • vagrant box list


To create an initial Vagrantfile

  • vagrant init racattack/oracle65


Other commands that we will be using are:


To start/create a new vm

  • vagrant up

To connect to a vm

  • vagrant ssh

To reboot a vm

  • vagrant reload


To stop a vm

  • vagrant halt

To check status of a vm

  • vagrant status



To delete a vm

  • vagrant destroy

lab: create test1 vm edit

In this lab, we will create a simple test1 vm.


  • vagrant box add racattack/oracle65
  • vagrant box list
  • mkdir test1
  • cd test1
  • vagrant init racattack/oracle65
  • vagrant up
  • vagrant reload
  • vagrant halt
  • vagrant destroy

Below the output on my test machine:

alvaros-mini:~ alvarom$ vagrant box add racattack/oracle65
==> box: Loading metadata for box 'racattack/oracle65'
    box: URL: https://vagrantcloud.com/racattack/oracle65                                                                                                                                     
==> box: Adding box 'racattack/oracle65' (v14.03.29) for provider: virtualbox
    box: Downloading: https://vagrantcloud.com/racattack/oracle65/version/1/provider/virtualbox.box                                                                                           
==> box: Successfully added box 'racattack/oracle65' (v14.03.29) for 'virtualbox'!
alvaros-mini:~ alvarom$ 

alvaros-mini:~ alvarom$ vagrant box list
racattack/oracle65 (virtualbox)
alvaros-mini:~ alvarom$ 

alvaros-mini:~ alvarom$ mkdir test1
alvaros-mini:~ alvarom$ cd test1
alvaros-mini:test1 alvarom$ vagrant init racattack/oracle65
A `Vagrantfile` has been placed in this directory. 
You are now ready to `vagrant up` your first virtual environment! 
alvaros-mini:test1 alvarom$ 


alvaros-mini:test1 alvarom$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'racattack/oracle65'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'racattack/oracle65' is up to date...
==> default: Setting the name of the VM: test1_default_1396308377657_73917
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2200 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Error: Connection timout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/alvarom/test1
alvaros-mini:test1 alvarom$ 


alvaros-mini:test1 alvarom$ vagrant ssh
[vagrant@oracle65-racattack ~]$ id
uid=500(vagrant) gid=500(vagrant) groups=500(vagrant)
[vagrant@oracle65-racattack ~]$ hostname
oracle65-racattack
[vagrant@oracle65-racattack ~]$ sudo su -
[root@oracle65-racattack ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@oracle65-racattack ~]# exit
logout 
[vagrant@oracle65-racattack ~]$ exit
logout
Connection to 127.0.0.1 closed.
alvaros-mini:test1 alvarom$ 


alvaros-mini:test1 alvarom$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'racattack/oracle65' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2200 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Error: Connection timout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/alvarom/test1
==> default: VM already provisioned. Run `vagrant provision` or use `--provision` to force it
alvaros-mini:test1 alvarom$ 

alvaros-mini:test1 alvarom$ vagrant halt
==> default: Attempting graceful shutdown of VM...
alvaros-mini:test1 alvarom$

alvaros-mini:test1 alvarom$ vagrant destroy
default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
alvaros-mini:test1 alvarom$


Congratulations, you created and destroyed your first virtual machine with Vagrant.

RAC Attack Automation edit

Architecture edit

At this point, in the RAC Attack Architecture we are in the first step.

 

Our Architecture Diagram looks like this:


Code edit

The code for this automation implementation can be found at [racattack.org/code]

From the code, we are interested in racattack/vagrantfile repo

To download the code are 2 ways:

  1. Download the zip file
  2. Using git

Download the zip file edit

A zip file with all the files required for this project can be downloaded as: https://github.com/racattack/vagrantfile/archive/master.zip

Download, Unzip

You are done.

Using git edit

If you are familiar with git, you can download a copy of this repo as:

git clone https://github.com/racattack/vagrantfile

If you have github software installed, then you can click on this link

reviewing racattack/vagrantfile edit

After downloading the repo locally to your computer, you will end with a structure similar to this:

.
|-- OracleLinux
| |-- README.md
| `-- racattack12cR1

go to the OracleLinux/racattack12cR1 directory

cd OracleLinux/racattack12cR1

And the structure will be something like this:

.
|-- 12cR1
| |-- <scripts>
| `-- readme.txt
|-- Vagrantfile
`-- stagefiles
| |-- <scripts>
` `-- readme.txt

Before we create our first cluster edit

Now everything is in place, we can check the status of our cluster:


alvaros-mini:racattack12cR1 alvarom$ vagrant status

collabn2 eth1 lanip :192.168.78.52
collabn2 eth2 privip :172.16.100.52
collabn2 dns server role is slave
on first boot shared disks will be created, this will take some time

collabn1 eth1 lanip :192.168.78.51
collabn1 eth2 privip :172.16.100.51
collabn1 dns server role is master
Current machine states:
collabn2 not created (virtualbox)
collabn1 not created (virtualbox)
This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
alvaros-mini:racattack12cR1 alvarom$

What this out put tell us?

It show are 2 nodes:

collabn2 not created (virtualbox)
collabn1 not created (virtualbox)

It show we will be able to access them over the following network detail:

collabn2 eth1 lanip :192.168.78.52
collabn2 eth2 privip :172.16.100.52
collabn1 eth1 lanip :192.168.78.51
collabn1 eth2 privip :172.16.100.51

This mean, we will move from single node, to 2 node.

This also mean, we are one step closer in the RAC Attack Architecture.

 

The scripts provided in stagefiles/*.sh will do all the configuration required for a Oracle RAC Cluster.

racattack12cR1
`-- stagefiles
| `-- <scripts>

If we review the output of vagrant status, we also have:

collabn2 dns server role is slave
collabn1 dns server role is master

This mean, when we provision our lab, collabn1 will be a dns server master and collabn2 will be a dns server slave.

Other piece of information is:

on first boot shared disks will be created, this will take some time

This is, on the first execution of vagrant up Vagrant, using our Vagrantfile will setup everything we need to have for a correct installation of an Oracle RAC 12cR1.

At this point you can do vagrant up to create your very first 2 node rac cluster using this project.

vagrant up edit

vagrant up command, will read Vagrantfile and will create what is in this file.

This project Vagrantfile have been tested, and improved, and does all the OS requirement to have an Oracle RAC 12cR1 installation, free of issues.

Order matters edit

Vagrant execute the scripts and create the machines top to bottom, so for advances uses, we may end installing software, or doing some tasks after the provisioning, so for that, we need all the nodes up and running, so we will be doing collabn2 first, then collabn1. In this way, once collabn1 is up and running, we can be sure all is up and ready.

Review of vagrant up output edit

Let's review the output.

A sample vagrant up log can be found on the project page at https://github.com/racattack/vagrantfile/blob/master/OracleLinux/vagrant-up.log in case you want to review, before executing your own run.

At this stage, the base box is imported.

==> collabn2: Importing base box 'kikitux/oracle65-racattack'...


At this stage, the box is being renamed from the template, into a name suitable for us.

==> collabn2: Setting the name of the VM: collabn2.1404011431

Vagrant magic:

==> collabn2: Clearing any previously set network interfaces...
==> collabn2: Preparing network interfaces based on configuration...

Here, in the pre-boot section, is where the shared disk are created. We will review this later.

==> collabn2: Running 'pre-boot' VM customizations...

Booting the virtual machine, and setting hostname

==> collabn2: Booting VM...
==> collabn2: Waiting for machine to boot. This may take a few minutes...
==> collabn2: Setting hostname...

Mounting shared folder

==> collabn2: Mounting shared folders...
collabn2: /vagrant => /Users/alvarom/racattack12cR1
collabn2: /media/sf_12cR1 => /Users/alvarom/racattack12cR1/12cR1
collabn2: /media/stagefiles => /Users/alvarom/racattack12cR1/stagefiles

Executing scripts

==> collabn2: Running provisioner: shell...

Shared disk edit

In order to be closer to the RAC Attack 12cR1 Architecture, we need to have shared disks.


This implementation, performs automatically on the first boot the RacAttack Create_Virtualbox_Shared_Storage steps

Let's check collabn1

alvaros-mini:racattack12cR1 alvarom$ vagrant status
collabn2 running (virtualbox)
collabn1 running (virtualbox)

Let's connect to collabn1 and become root

alvaros-mini:racattack12cR1 alvarom$ vagrant ssh collabn1 
[vagrant@collabn1 ~]$ sudo su -  
[root@collabn1 ~]#

Let's check the disks.

  • udev disk
[root@collabn1 ~]# ls -al /dev/asm* /dev/sd*
lrwxrwxrwx 1 root root 4 Apr 1 01:35 /dev/asmdisk1 -> sdc1
lrwxrwxrwx 1 root root 4 Apr 1 01:35 /dev/asmdisk2 -> sdd1
lrwxrwxrwx 1 root root 4 Apr 1 01:35 /dev/asmdisk3 -> sde1
lrwxrwxrwx 1 root root 4 Apr 1 01:35 /dev/asmdisk4 -> sdf1
brw-rw---- 1 root disk 8, 0 Apr 1 01:35 /dev/sda
brw-rw---- 1 root disk 8, 1 Apr 1 01:35 /dev/sda1
brw-rw---- 1 root disk 8, 2 Apr 1 01:35 /dev/sda2
brw-rw---- 1 root disk 8, 3 Apr 1 01:35 /dev/sda3
brw-rw---- 1 root disk 8, 16 Apr 1 01:35 /dev/sdb
brw-rw---- 1 root disk 8, 32 Apr 1 01:35 /dev/sdc
brw-rw---- 1 grid asmadmin 8, 33 Apr 1 01:35 /dev/sdc1
brw-rw---- 1 root disk 8, 48 Apr 1 01:35 /dev/sdd
brw-rw---- 1 grid asmadmin 8, 49 Apr 1 01:35 /dev/sdd1
brw-rw---- 1 root disk 8, 64 Apr 1 01:35 /dev/sde
brw-rw---- 1 grid asmadmin 8, 65 Apr 1 01:35 /dev/sde1
brw-rw---- 1 root disk 8, 80 Apr 1 01:35 /dev/sdf
brw-rw---- 1 grid asmadmin 8, 81 Apr 1 01:35 /dev/sdf1
[root@collabn1 ~]#

We have 4 shared disks, sdc,sdd,sde,sdf We have persistent aliases


  • OracleASM disks
[root@collabn1 ~]# ls -al /dev/oracleasm/disks/
total 0
drwxr-xr-x 1 root root 0 Apr 1 01:35 .
drwxr-xr-x 4 root root 0 Apr 1 01:35 ..
brw-rw---- 1 grid asmadmin 8, 33 Apr 1 01:35 ASMDISK1
brw-rw---- 1 grid asmadmin 8, 49 Apr 1 01:35 ASMDISK2
brw-rw---- 1 grid asmadmin 8, 65 Apr 1 01:35 ASMDISK3
brw-rw---- 1 grid asmadmin 8, 81 Apr 1 01:35 ASMDISK4
[root@collabn1 ~]#

Shared disk created, permission set. Ready to use.

Once again, this mean we are one step closer to the RAC Attack 12cR1 Architecture:

 

What came included by default edit

On top the detailed description already provided, this Automation script does:

  • Create the required groups, for role separation per Oracle RAC Manual
  • Create user grid
  • Update groups of user oracle
  • Initialize sdb disk for oracle binaries, mount it as /u01
  • Setup DNS Settings for Master node (collabn1) slave (collabn2)
  • Setup ulimit for grid user, for role separation

Default users and password edit

  • User root, password root
  • User grid, password grid
  • User oracle, password oracle

Connecting to the virtual machine edit

At this moment, you have 2 ways how to connect to the virtual machines

  • vagrant ssh collabn1 and then sudo su - to become root.
You can became grid   user as  sudo su - grid from vagrant
You can became oracle user as  sudo su - oracle from vagrant
  • ssh/putty to the ip

You laptop computer is connected to both networks, lan 192.168.78 and priv 172.16.100.51.

So you can ssh directly to the machines.

collabn2 eth1 lanip :192.168.78.52
collabn2 eth2 privip :172.16.100.52

collabn1 eth1 lanip :192.168.78.51
collabn1 eth2 privip :172.16.100.51

Congratulations edit

At this point, you have a 2 node cluster, all ready to work.

This mean, we are 100% with the RAC Attack 12cR1 Architecture, congratulations.

 

What's next edit

Place your downloaded zip oracle binaries in racattack12cR1/12cR1:


12cR1/linuxamd64_12c_grid_1of2.zip
12cR1/linuxamd64_12c_grid_2of2.zip 
12cR1/linuxamd64_12c_database_1of2.zip
12cR1/linuxamd64_12c_database_2of2.zip

Configure VNC session, or use X11, from: RAC_Attack_12c/VNC_Server_Setup

Configure VNC Server with the oracle account (passwords won't be displayed):

[root@collabn1 ~]# su - oracle
[oracle@collabn1 ~]$ vncserver :1

You will require a password to access your desktops.

Password: racattack
Verify: racattack
xauth:  creating new authority file /home/oracle/.Xauthority

New 'collabn1.racattack:1 (oracle)' desktop is collabn1.racattack:1

Creating default startup script /home/oracle/.vnc/xstartup
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/collabn1.racattack:1.log

Open a vncviewer on your laptop and fill the ip address of collabn1 followed by :1.


 

Enter the password racattack when prompted:

 

The graphical interface is ready for the Grid Infrastructure Installation.

 


When you get to the interface setup of Grid Infrastructure, please have in mind that the interfaces, due Vagrant requirement are different than the 12cR1 book:

When ready to configure the networks, you need to:

Click on Identify Network Interfaces...

Check that the correct addresses are set:

  • eth0 is marked as Do Not Use
  • eth1 is marked as Public
  • eth2 is marked as Private

Click OK to close the Identify Network Interfaces window.

Finally, click Next

Now you can go to the RAC Attack 12cR1 book, and start from RAC_Attack_12c/Prepare_for_GI_install

Update base box edit

As today, the version of racattack/oracle65 is 14.03.29

This is the base box, the box used to create new guest machines.

When a new guest machine is created, that is on the first time you run vagrant up, or when you want to recreate your system after running vagrant detroy

In order to validate if you are in the latest version available, use command vagrant box outdated --global

alvaros-mini:racattack12cR1 alvarom$ vagrant box outdated --global
* 'racattack/oracle65' (v14.03.29) is up to date
alvaros-mini:racattack12cR1 alvarom$

This will check the version of the base box installed.


When a new version came out, the command to update the base box is vagrant box update

Example output:

alvaros-mini:racattack12cR1 alvarom$ vagrant box update
==> default: Checking for updates to 'racattack/oracle65'
default: Version constraints: >= 0
default: Provider: virtualbox
==> default: Box 'racattack/oracle65' (v14.03.29) is running the latest version.

Update OS edit

If you require to update the OS of the guest machines, the machines are configured to use public-yum from oracle.

This mean you can update executing yum update

For more information about yum please visit http://docs.oracle.com/cd/E37670_01/E37355/html/ol_about_yum.html

RAC Attack Automation/Advanced uses edit

RAC Attack Automation/Advanced uses


RAC_Attack_12c