Wednesday, March 11, 2015

Automated command line setup of Oracle 12c on Centos 6.6 using vagrant and virtualbox .. project ora12base code on github




A little background first ...

All the non-oracle code here is free available via github: https://github.com/dgapitts/ora12base

Although to get this to run you will need to download the oracle software (*.zip and *.rpm) files, which naturally means signing up to oracle.com and agreeing to their EULA.


and now a quick overview of the project ora12base ...

The ora12base project, is a relevantly simple vagrant project to automate setup an Oracle 12c environment running on Centos 6.6.


Here is the Vagrantfile:


~/projects/ora12base $ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :


Vagrant.configure(2) do |config|
 config.vm.box = "opscode_centos-6.6_chef-provisionerless.box"
config.vm.box_url="http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.6_chef-provisionerless.box"
 config.vm.network "public_network", ip: "192.168.0.17"
 config.vm.host_name = "ora12c66"
 config.vm.provider "virtualbox" do |vb|
   vb.memory = "4028"
 end
 config.vm.provision :shell, :path => "provision.sh"
end


Note you can run this with as little as 1024M (1G) of memory, but if you are co-hosting multiple Oracle instances (and possibly ASM), then more memory is better


From your host machine


vagrant up
vagrant ssh


Then run as root the pre-install 12c software (mostly rpm driven):


sudo -i
/vagrant/root_post_vagrant_build.sh


and here are steps this script will perform for you:


[vagrant@ora12c66 ~]$ sudo -i
[root@ora12c66 ~]# cat /vagrant/root_post_vagrant_build.sh
cat /vagrant/root_bash_profile.txt >> ~/.bash_profile


. ~/.bash_profile
groupadd -g 1000 oinstall
useradd -G oinstall -u 2000 oracle


cd /etc/yum.repos.d
wget http://public-yum.oracle.com/public-yum-ol6.repo
wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
yum -y install oracle-rdbms-server-12cR1-preinstall


mkdir -p /u01/product/12.1.0/db_1
mkdir -p /etc/oraInventory
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /etc/oraInventory


cd /vagrant
rpm -ivh redhat-release-6Server-1.noarch.rpm


wget http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
yum -y install rlwrap


Now we can install 12c software as oracle


su - oracle
/vagrant/oracle_post_vagrant_build.sh


and here are steps this script will perform for you:


[root@ora12c66 ~]# su - oracle
[oracle@ora12c66 ~]$ cat /vagrant/oracle_post_vagrant_build.sh
cat /vagrant/oracle_bash_profile.txt >> ~/.bash_profile
. ~/.bash_profile
cp /vagrant/linuxamd64_12c_database_* /tmp
cd /tmp/
unzip linuxamd64_12c_database_1of2.zip
unzip linuxamd64_12c_database_2of2.zip
cd /tmp/database/
./runInstaller -noconfig -silent -responseFile /vagrant/db_install.rsp


[oracle@ora12c66 ~]$ cat /vagrant/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME="`hostname`"
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/etc/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/product/12.1.0/db_1
ORACLE_BASE=/u01
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.BACKUPDBA_GROUP=oinstall
oracle.install.db.DGDBA_GROUP=oinstall
oracle.install.db.KMDBA_GROUP=oinstall
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES


The final step of which is 12c software root.sh commands (i.e. as root again)
/etc/oraInventory/orainstRoot.sh
/u01/product/12.1.0/db_1/root.sh


After checking the installer log, via dbca we can create a 12c database


rm /tmp/linuxamd64_12c_database_*zip
dbca -silent -createDatabase -responseFile  /vagrant/dbca.rsp


and here is the contents of the response file:


[oracle@ora12c66 ~]$ cat /vagrant/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME="`hostname`"
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/etc/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/product/12.1.0/db_1
ORACLE_BASE=/u01
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.BACKUPDBA_GROUP=oinstall
oracle.install.db.DGDBA_GROUP=oinstall
oracle.install.db.KMDBA_GROUP=oinstall
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
[oracle@ora12c66 ~]$ cat /vagrant/dbca.rsp
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
GDBNAME = "orcl12c"
SID = "orcl12c"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "qwe123"
SYSTEMPASSWORD = "qwe123"
SYSMANPASSWORD = "qwe123"
DBSNMPPASSWORD = "qwe123"
CHARACTERSET = "UTF8"
NATIONALCHARACTERSET= "UTF8"


Note if you have issues and need to cleanup after any 12c software failures


rm -Rf /etc/oraInventory/*

rm -Rf /u01/product/12.1.0/db_1/*

No comments:

Post a Comment