Install Oracle Express in Amazon AWS


I took this configuration out of my Project.net installation as some of you may want to run Oracle express in Amazon for other things, the main reason that this was a little tricky is that the project software needs a constant host name and therefore the Oracle needs a little help ūüôā

Launch an instance, and connect.  You need to change the host name, to do this.

vi /etc/sysconfig/network

Change the host name line to

HOSTNAME= A FQDN

The network needs to be restarted

cd /etc/init.d

./network restart

Download the oracle xe express database from the Oracle web site, I have yet to figure out how to do this via a command line in Linux, so download via a web browser and then upload to the server, this can be done via the pscp.exe that is shipped with putty, there are loads of tutorials on the net that will tell you how to do this.

Once uploaded and as per usual I have created a software folder, and uploaded the rpm to this folder.

cd ~

mkdir software

You need a swap space on the server to allow Oracle to be installed this can be found at survivalguides create swap space written by yours truly.

Install Oracle XE via RPM or DEB depending on your Linux distribution

cd ~/software

service iptables stop

rpm -i oracle-xe-10.2.0.1-1.0.i386.rpm

Run “/etc/init.d/oracle-xe configure” to configure Oracle
Specify the HTTP port that will be used for Oracle Application Express [8080]:8080
Specify a port that will be used for the database listener [1521]:1521
Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. (* make sure you remember this password *)
Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]: y

vi /etc/profile

Insert the following lines at the bottom

export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

export ORACLE_HOMEexport ORACLE_SID=XEexport NLS_LANG=AMERICAN.AL32UTF8

export PATH=$PATH:$ORACLE_HOME/bin

You need to run the profile to get the variables

. /etc/profile

Note the space between . /

It is also worth adding these lines to the .bashrc file in the home directory

service oracle-xe stop

Again an Amazon quirk is the localhost name so add the host name that was created at the start of the procedure to the hosts file.

vi /etc/hosts

service oracle-xe start

If you get the following error

Failed to start Oracle Net Listener using /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/tnslsnr and Oracle Express Database using /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlplus.

Use

yum -y install glibc.i686

To test that this is a connection to the database use the standard Oracle test command

tnsping xe

You can also use the sqlplus client

sqlplus sys/(password for oracle)@xe as sysdba

This should give you an SQL prompt.

exit

This will get you out of the sqlplus client.

Once the server is restarted this will stop working, again another Amazon little gotya, this is because the IP address changes and so can the host name. To get around this you need to change the tnsnames.ora file to match the new name of the server.

vi /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/tnsnames.ora

My tns file looks like this

# tnsnames.ora Network Configuration File:

XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = project.acme.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

This is a read only file so you will need to use

:wq!

To save the file

You also need to change the listener.ora file as this also contains the host name of the server.

vi /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora 

My file looks like this

# listener.ora Network Configuration File:

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server)
(PROGRAM = extproc)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = project.acme.com)(PORT = 1521))
)
)

DEFAULT_SERVICE_LISTENER = (XE)

This is a read only file so you will need to use

:wq!

To save the file

You need to create the following file, to recreate the hosts file every time the server is rebooted, this will allow the oracle to work properly.

The script file I called createhostfile.ksh and the contents is

#!/bin/bash
getip=`/sbin/ifconfig eth0 | grep ‘inet addr’ | awk ‘{print $2}’ | sed -e ‘s/.*://’`
newhost=”${getip}¬†project.acme.com
rm -f /etc/hosts
echo “127.0.0.1 localhost localhost.localdomain” > /etc/hosts
echo $newhost >> /etc/hosts

Note that I called my server project, you will need to replace this with what you have call your server.

To create the file

cd /etc

vi createhostfile.ksh

paste the script above

chmod 755 createhostfile.ksh

Now we can change the oracle-xe file that is used to start and stop oracle.

vi /etc/init.d/oracle-xe

After all of the comment insert the following line

/etc/createhostfile.ksh

This will call the host file creating every time that oracle is started.

Advertisements

One Comment on “Install Oracle Express in Amazon AWS”

  1. […] Install a Linux server and install Oracle as per the Survival Guides Install Oracle Express on Amazon AWS […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s