# 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

At this point in time, we are working to automate the third and fourth labs - Install Linux and Create Cluster.
* Complete the first three labs: Hardware Requirements, Software Components and Prepare Host. Do not download Oracle Linux; just the database and cluster software.
* Download and install Vagrant 1.5.1
* Download and unzip http://racattack.org/vagrantfile.zip (note that this file changes frequently as we work on it)
* Open a command prompt and change into the directory where you unzipped vagrantfile.zip
* cd vagrantfile-master\OracleLinux\racattack12cR1
* vagrant up
* vagrant ssh collabn1
* sudo su - oracle -c vncserver
* Run the vnc client of your choice and connect to vnc://192.168.78.51:1
* 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

This project came to you by the RAC Attack Team
Initial version: Alvaro Miranda 14/04

## Getting started

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

### Software used in this implementation

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.
* vagrant 1.5.1
* packer 0.5.2

### OSes that are known to work

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

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:
This version of racattack/oracle65 was created and updated to 14.03.29

### Hardware requirements

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

### Software Components

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

### Vagrant

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

## Introduction to Vagrant - Vagrant 101

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:
* Download a vagrant box
* Create a Vagrantfile
Let's execute some commands with vagrant:

### vagrant box

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:
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

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 :
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

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:
Congratulations, you created and destroyed your first virtual machine with Vagrant.

## RAC Attack Automation
### Architecture

At this point, in the RAC Attack Architecture we are in the first step.
Our Architecture Diagram looks like this:

### Code

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:
* Download the zip file
* Using git

#### Download the zip file

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

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

After downloading the repo locally to your computer, you will end with a structure similar to this:
go to the OracleLinux/racattack12cR1 directory
cd OracleLinux/racattack12cR1
And the structure will be something like this:

## Before we create our first cluster

Now everything is in place, we can check the status of our cluster:
What this out put tell us?
It show are 2 nodes:
It show we will be able to access them over the following network detail:
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.
If we review the output of vagrant status, we also have:
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:
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

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

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

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.
At this stage, the box is being renamed from the template, into a name suitable for us.
Vagrant magic:
Here, in the pre-boot section, is where the shared disk are created. We will review this later.
Booting the virtual machine, and setting hostname
Mounting shared folder
Executing scripts

### Shared disk

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
Let's connect to collabn1 and become root
Let's check the disks.
* udev disk
We have 4 shared disks, sdc,sdd,sde,sdf We have persistent aliases
* OracleASM disks
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

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

* User root, password root
* User grid, password grid
* User oracle, password oracle

## Connecting to the virtual machine

At this moment, you have 2 ways how to connect to the virtual machines
* vagrant ssh collabn1 and then sudo su - to become root.
* 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.

## Congratulations

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

Place your downloaded zip oracle binaries in racattack12cR1/12cR1:
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):
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

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
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:

## Update OS

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

RAC Attack Automation/Advanced uses
RAC_Attack_12c