Oracle have pre-installed images on Amazon EC2. The following are steps to get a database up and running using the pre-installed image.
1. Bring up server using ami-8d97bcf9 - Oracle 11.2 Standard Edition EBS backed.
(See Reference 1 below)
a. attach 2 EBS disks, one for the database and one for the flash recovery. I
attach at /dev/sdf and /dev/sdg respectively.
b. logon to server via ssh and reply to meesage up to where it asks to create a database.
c. logon to server via another ssh session and initialise the EBS disks:
mkfs -t ext3 /dev/sdf
tune2fs -m0 /dev/sdf
mkdir /u02
mount /dev/sdf /u02
mkfs -t ext3 /dev/sdg
tune2fs -m0 /dev/sdg
mkdir /u03
mount /dev/sdg /u03
d. Back to the first orginal ssh session and continue to create the database
use /dev/sdf for database and mount on /u02
and /dev/sdg for flash recovery and mount on /u03
2. Enable SCP so we can transfer in files:
vi /etc/ssh/sshd_config
uncomment line:
Subsystem sftp /usr/libexe/openssh/sftp-server
restart ssh:
/etc/init.d/sshd restart
3. To build the automation scripts need Ruby 1.8.7 (required for Amazon interface
right_aws) need to upgrade from the supplied Ruby 1.8.5.
a. Setup Oracle public repository as none defined. (See Reference 2 below)
cd /etc/yum.repos.d/
wget http://public-yum.oracle.com/public-yum-el5.repo
vi /etc/yum.repos.d/public-yum-el5.repo and set 'enabled=0' parameter to
'enabled=1' for the Oracle Linux Version 5.4 repository
b. Setup epel repository (See Reference 3 below)
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
c. Install pre-requsites for Ruby 1.8.7 install (See Reference 4 below)
yum install zlib-devel
yum install openssl-devel
d. Install Ruby 1.8.7 from source.
cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p357.tar.gz
tar xvzf ruby-1.8.7*.tar.gz
cd ruby-1.8.7*
./configure --enable-shared --enable-pthread
make
make install
cd ext/zlib
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib64
cd ../../
make
make install
cd ext/openssl
ruby extconf.rb
make
make install
cd ../../
ruby -v
e. Make Ruby 1.8.7 default ruby implementation so can be accessed at startup
mv /usr/bin/ruby /usr/bin/ruby_old
ln -s /usr/local/src/ruby-1.8.7-p357/ruby /usr/bin/ruby
f. Install Ruby Gems
cd /usr/local/src
wget http://rubyforge.org/frs/download.php/75711/rubygems-1.8.15.tgz
tar xvzf rubygem*.tgz
cd rubygem*
ruby setup.rb
gem install rubygems-update
update_rubygems
g. Install right_aws the Ruby Amazon AWS Interface
gem install right_aws
4. Setup Automation Scripts
a. Use scp to copy
cloud_init.rb
settings.rb
config_listener.rb
to /root
NOTE: Verify in cloud_init.rb the lines for ubuntu are commented out and the
lines for centos/redhat are uncommented
b. Go to directory /etc/rc.d/init.d and add a file called cloud_init containing:
#!/bin/sh
#
# chkconfig: - 98 01
# description: initialize cloud requirements for application
# NOTE: parameter on config_listener.rb is ORACLE_HOME
#
ruby /root/cloud_init.rb
ruby /root/config_listener.rb /u01/app/oracle/product/11.2.0/db_1
c. Don't forget to make it executable
chmod a+x cloud_init
d. Setup the cloud_in to run at startup. It is level 98 because Oracle starts at
level 99.
chkconfig --level 345 cloud_init on
5. Create the oracle image:
a. shutdown the database and listener (under user oracle)
su - oracle
/u01/app/oracle/product/11.2.0/db_1/bin/dbshut
lsnrctl stop
b. Update the listener config file so the config_listener.ora script works at startup
vi /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
change 'HOST = ip.999.999.999.999' to 'HOST =
'
NOTE: ip.999.999.999.999 will be actual ip address of server
c. Update the oracle user bash profile so that it can also be updated by the
startup script to the correct address
vi /home/oracle/.bash_profile
change
export ORACLE_HOSTNAME=ec2-999-999-999-999.eu-west-1.compute.amazonaws.com
to
export ORACLE_HOSTNAME=
NOTE: ec2-999-999-999-999 will be actual ip address of server
d. Go back to the root user and umount and detach the EBS disks.
umount /u02
umount /u03
detach using the AWS console or other tools.
rm -r /u02
rm -r /u03
e. Create an image called oracle-YYMMDD where YYYMMDD is current date
References
1. http://databasesincloud.wordpress.com/2012/01/25/desaster-recovery-in-the-cloud-part-2/
2. http://www.oracle.com/technetwork/topics/linux/yum-repository-setup-085606.html
3. http://gembuls.wordpress.com/2011/02/12/how-to-install-epel-repository-on-centos/
4. http://www.xelacomp.com/blog/02-09-2011/install-ruby-187-rubygems-and-passenger-centos5-64-bit
Scripts can be found at
settings.rb
Cloud_init.rb
config_listener.rb