Running Oracle Database XE in the Cloud

By Justin Lokitz

Developer: Cloud Computing

Learn how to build and deploy Oracle Database 10g Express Edition virtual images in the Amazon Elastic Compute Cloud—the "do-it-yourself" way.

Published September 2008

The promise of utility-based computing has been a long time coming. Starting out as a twinkle in the eye of mainframe computers, today there is an array of options to choose from. Whether you are running an Oracle grid using Oracle Real Application Clusters on your own physical, low-cost blade servers or relying on hosted services such as Google Applications Engine or Amazon Web Services, tapping into the power and efficiency of computers configured to give you what you need when you need it, it is a complete paradigm shift from the "big iron" models of the past. Because there are plenty of great resources for implementing Oracle grid-based systems on physical hardware, this article focuses on ways to implement Oracle technology on "clouds" of virtual servers such as those hosted by Amazon, via the Amazon Elastic Compute Cloud (EC2).

As of Sept. 21, 2008, Oracle officially certifies/supports and licenses many of its products on Amazon Web Services—furthermore, Oracle now supplies free, prebuilt virtual machine templates (or Amazon Machine Images, as Amazon calls them) for Oracle Enterprise Linux, Oracle Database 10g Express Edition (XE), all Oracle Database 11geditions, Oracle Enterprise Manager, and various Oracle Fusion Middleware components. Thus, the steps below will be of interest only to do-it-yourselfers and to people interested in how such templates are built—but knowing OTN readers, that could certainly be a lot of people! (See the Cloud Computing Center on OTN for more information.)

Amazon EC2 Overview

Amazon's Web site states, "Amazon Elastic Compute Cloud (Amazon EC2) is a Web service that provides resizable compute capacity in the cloud. It is designed to make Web-scale computing easier for developers." Diving a little deeper, what Amazon is offering here is a chance to utilize its superior network, server hardware, and expertise and the ability for any subscriber to manage the entire architecture via Web services. Moreover, because the hardware and network being used are dished out in small (and not-so-small), virtualized chunks, you can start with something akin to a single server and scale almost limitlessly without worrying about having to rent more space, buy hardware, or even install software; best of all, you pay only for what you use.

The details can be found here, but the gist is that you can pay as little as 10 cents per hour for a small instance (1.7GB of memory, one EC2 Compute Unit [one virtual core with CPU capacity equivalent to a 1.0GHz-1.2GHz 2007 Opteron or 2007 Xeon processor], 160GB of instance storage, and a 32-bit platform). What's more, as with any other virtualization platform, you can very easily create your own replication, backup, and growth strategies, using virtualized server images rather than physical hardware with installed software.

Implementation Overview

So you want to start a project or do some Oracle Application Express development on the cheap, using a single "server"? No problem. Feel like your Oracle-based project is starting to take off and you're going to need more processing power? This may be your answer.

Although you can come up with plenty of scenarios when considering how to best match the power of Oracle software with the flexibility, or elasticity, of Amazon EC2, by far the easiest, most visible, and most straightforward is simply implementing Oracle Database XE on a small EC2 instance. Because Oracle Database XE provides a relatively encapsulated and uncomplicated installation along with an embedded Web listener and an Oracle Application Express front end, using it is a great way to start. Given these factors, this article provides step-by-step instructions, based on the Amazon EC2 "Getting Started Guide," for implementing Oracle Database Express Edition on Amazon EC2.

Although the instructions this article lays out are meant to step you through each stage of the implementation without requiring a lot of prior experience with Oracle, Linux, or Amazon Web Services, they assume that you are somewhat comfortable with command-line instructions and Oracle and Linux nomenclature. Furthermore, to use the Amazon Web Service command-line tools, you must have access to an SSH client, such as PuTTY (for Windows), as well as an installation of a Java 5-compatible Java Runtime Environment (JRE). You can find instructions for downloading and installing PuTTY here and the Sun JRE here.

Step-by-Step Instructions for Implementing Oracle Database XE on Amazon EC2

Signing Up for Amazon Web Services (EC2 and S3)

To implement the steps presented in this article, you must sign up for three different Amazon accounts: a central Amazon Web Services account, an Amazon Simple Storage Service (S3) account—where your Amazon image will be stored—and an Amazon Elastic Compute Cloud account. Information for all three accounts as well as Amazon's other services can be found here. To create an Amazon Web Services account, start here. Once you have created your Amazon Web Services account, make a note of your account ID. You can find it by moving your cursor over the Your Web Services Account button and selecting the Account Activity link on the menu that appears. At the top of this page, just under the Account Activity title, you should see an Account Number label followed by a hyphenated number, such as 4952-1993-3132. This is your Amazon Web Services account ID and will also serve as your EC2 user ID (with the hyphens removed: 495219933132).

Signing Up for Amazon S3

Although most of this article deals with the installation and configuration of Oracle Database Express Edition on an Amazon EC2 instance, one of the most important steps is the creation and storage of an Amazon Machine Image on another service called Amazon Simple Storage Service (S3). Like the internals of Oracle Database, Amazon EC2 uses the notion of an instance, which means that a stored physical image can be used only when it is loaded in memory. Otherwise, when an image is not resident in memory, it must be permanently stored on disk somewhere until it is ready to be used again. Because Amazon EC2 offers storage, memory, and computing power only when it is resident in memory (that is, started via a Web service) and does not offer persistent storage when the image/instance is not running, you must create an Amazon S3 account to store your image when it is not running. To learn more about Amazon S3 and/or to sign up for an Amazon S3 account, visit the Amazon S3 home page and click the Sign up for this service button in the upper right corner. If you do not already have an Amazon Web Services account, you will be prompted to create one as part of the sign-up process.

Signing Up for Amazon EC2

Once you have created an Amazon S3 account, you will need to create an Amazon EC2 account, where you will do most of the work. To do so, log in to your Amazon Web Services account and click the link to Amazon EC2 in the Browse Web Services section on the left. Once you have been redirected to the EC2 home page, click the Sign Up For Web Service button at the top right of the screen and follow the on-screen instructions.

As soon as you have finished creating the EC2 account, you will need to create a new X.509 secure certificate and an associated key file. You will use these to remotely log in to the EC2 service later. To create a new X.509 certificate, move your cursor over the Your Web Services Account button and select the View Access Key Identifiers link on the menu that appears. In the X.509 Certificate section, click the Create New button. follow the link to create a new X.509 certificate, and save the certificate and the private key. Create an .ec2 directory in your home directory, and save these files to it with the filenames offered by your browser. Once you have completed these steps and have saved these files, you should end up with a PEM-encoded X.509 certificate and a private key file with names similar to those in the examples below:

  • cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem: a PEM-encoded, signed X.509 certificate
  • pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem: an unencrypted, PEM-encoded RSA private key that corresponds to the X.509 certificate above

The X.509 certificate you create will be associated with your account until you generate or upload a new certificate. If you have an existing certificate you would prefer to use, you can come back to the Access Key Identifiers page later and upload that one instead.

Installing the Necessary Tools

Sun Microsystems JRE. Because most of the command-line Tools used to manage Amazon Web Services require Java version 5 or later, you will need to install and configure a Java Runtime Environment (JRE) or a Java Development Kit (JDK). Sun Microsystems provides implementations for a range of platforms, including Linux and Windows, which you can download and install from here if you don't already have one configured.

With a JRE or a JDK installed and configured, set up a JAVA_HOME environmental variable (which will be used by the Amazon Web Service Tools). This variable should be set to the full path of the directory that contains a subdirectory named bin, which, in turn, contains the java (on Linux/UNIX) or the java.exe (on Windows) executable. You may also want to simplify things by adding this directory to your path before other versions of Java.

To temporarily set the JAVA_HOME environmental variable in Windows (from a command prompt) , issue the following command:

C:\> set JAVA_HOME=<PATH>

You can also permanently set the JAVA_HOME environmental variable in Windows by doing the following:

  • 1. From the Start menu, select Settings -> Control Panel.
  • 2. Double-click System.
  • 3. On the Advanced tab, click Environmental Variables.
  • 4. Under User Variables or System Variables, create a new JAVA_HOME variable.
  • 5. Click OK to close.

To confirm your JAVA_HOME environmental variable in Windows (from a command prompt), issue the following command:


 
 
 C:\> %JAVA_HOME%\bin\java version  
java version "1.5.0_14"  
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)  
Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode)
 

PuTTY and Associated Tools. Because most of the implementation covered in this article is done remotely on a Linux instance via SSH, you will need a suitable SSH client. Although most UNIX/Linux distributions come with a built-in SSH client, Windows typically does not. For that reason, if you are using Windows, you must install an SSH client such as PuTTY (which is a great, free SSH client with lots of extras)

Because you will use the PuTTY SSH client as well as the PSCP and PuTTYGen utilities covered in this article, by far the easiest way to set up these Tools is to download the putty.zip file from here. This file contains all the necessary binaries (except PuTTYtel) and also the help files. Once the download is complete

  • 1. Unzip putty.zip into a new directory named putty under C:\Program Files (that is, C:\Program Files\putty).
  • 2. You can run the SSH client by double-clicking putty.exe from the C:\Program Files\putty directory.
  • 3. On the Advanced tab, click Environmental Variables.
  • 4. You may also want to add this to your Windows path, by going through the following steps:
    • 5. a. From the Start menu, select Settings -> Control Panel.
    • b. Double-click System.
    • c. On the Advanced tab, click Environmental Variables.
    • d. Edit the Path system variable, and add ";:\Program Files\putty" o the end (making certain you separate the entry before this PuTTY entry with a semicolon).
    • e. Click OK to close.

EC2 Command-Line Tools

As mentioned earlier, Amazon includes a set of command-line Tools that enable you to manage your Amazon EC2 instance remotely. As before with the PuTTY tools, no installation is necessary for these Tools. As long as you have properly set up your JAVA_HOME environmental variable, you should be able to simply unzip the Amazon EC2 command-line Tools into a new directory.

Once you have unzipped the command-line Tools into a new directory, such as C:\Program Files\EC2, you must set up an environmental variable to tell your system where the Tools can be found. To do this, you will need to set an environmental variable named EC2_HOME that points to the command-line Tools folder (where you unzipped the Tools). Using Windows (from the command prompt), issue the following command:


 
 C:\> set EC2_HOME=<path-to-tools> 
 C:\> set PATH=%PATH%;%EC2_HOME%\bin 
 

Alternatively, as before, you can permanently set the EC2_HOME environmental variable, as a user variable or a system variable, by doing the following:

  • 1. From the Start menu, select Settings -> Control Panel.
  • 2. Double-click System. On the Advanced tab, click Environmental Variables.
  • 3. Under User Variables or System Variables, create a new EC2_HOME variable.
  • 4. Click OK to close.

The command-line Tools will also need access to the private key and the X.509 certificate you generated after signing up for the Amazon EC2 service. To make this simple, you can set up two new environmental variables, named EC2_PRIVATE_KEY and EC2_CERT, that will point to your private key file and X509 certificate, respectively. To set up these environmental variables, issue the following command:


 
 
 C:\> set EC2_PRIVATE_KEY=c:\ec2\pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem 
 C:\> set EC2_CERT=c:\ec2\cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem 
 
 

As with other environmental variables, you can permanently set EC2_PRIVATE_KEY and EC2_CERT in Windows by doing the following:

  • 1. From the Start menu, select Settings -> Control Panel.
  • 2. Double-click System.
  • 3. On the Advanced tab, click Environmental Variables
  • 4. Under User Variables, create a new EC2_PRIVATE_KEY variable and an EC2_CERT variable.
  • 5. Click OK to close.

Finding and Starting an Amazon EC2 Instance

One of the nicest and most time-saving features of Amazon EC2 is the ability to publish, find, reuse, and repurpose Amazon Machine Images (AMIs).

As with most other virtualization sulutions, Amazon makes it very easy to create and use new images. However, where Amazon EC2 is different is that because the images you create are maintained by Amazon and not downloaded onto local servers, you have the choice to share and use images created by you and others, including those created by Amazon. Hence, with a catalog of public AMIs to choose from, one thing we do not have to worry about in this article is installing and configuring an operating system; all we have to do is find one we like.

As I mentioned in the introduction, Oracle is now supplying pre-built AMIs free of charge, so many of the steps described below are now of interest only to people who wish to build their own AMIs. Note however that only the Oracle-provided AMIs are licensable and certified.

Finding an AMI

To find an AMI suitable for use with Oracle Database XE (or anything else), you can simply run an EC2 command-line tools (ec2-describe-images). With Windows, this looks something like this:


 
 
 C:\> ec2-describe-images -o self -o amazon
 IMAGE ami-bd9d78d4 ec2-public-images/demo-paid-AMI.manifest.xml amazon
 available public A79EC0DB i386 machine
 IMAGE ami-26b6534f ec2-public-images/developer-image.manifest.xml amazon
 available public i386 machine
 IMAGE ari-a51cf9cc ec2-public-images/ec2-initrd-2.6.21.7-2.fc8xen.i386.mani
 fest.xml amazon available public i386 ramdisk
 
 IMAGE ari-b31cf9da ec2-public-images/ec2-initrd-2.6.21.7-2.fc8xen.x86_64.ma
 nifest.xml amazon available public x86_64 ramdisk
 
 IMAGE aki-a71cf9ce ec2-public-images/ec2-vmlinuz-2.6.21.7-2.fc8xen.i386.man
 ifest.xml amazon available public i386 kernel
 
 IMAGE aki-b51cf9dc ec2-public-images/ec2-vmlinuz-2.6.21.7-2.fc8xen.x86_64.m
 anifest.xml amazon available public x86_64 kernel
 
 IMAGE ami-f51aff9c ec2-public-images/fedora-8-i386-base-v1.06.manifest.xml
 amazon available public i386 machine aki-a71cf9ce ari-a51c
 f9cc
 IMAGE ami-f21aff9b ec2-public-images/fedora-8-x86_64-base-v1.06.manifest.xm
 l amazon available public x86_64 machine aki-b51cf9dc
 ari-b31cf9da
 IMAGE ami-a21affcb ec2-public-images/fedora-core-6-x86_64-base-v1.06.manife
 st.xml amazon available public x86_64 machine aki-a53adfcc
 ari-a23adfcb
 .....
 
 

As you can see, there are plenty of premade public AMIs to choose from. The one we will use in this article is the image with the ID ami-f51aff9c and the name ec2-public-images/fedora-8-i386-base-v1.06.manifest.xml. This AMI is one that already comes preloaded with the Fedora 8 Linux distribution.

Generating a Key Pair

Because it is easiest to start with a public instance for making your own and because the public instances listed with the commands above do not have passwords, you will need a public/private key pair to log in to the instance; half of this key pair will be embedded into your instance, allowing you to log in securely without a password, using the other half of the key pair. As you create more-advanced, customized AMIs, you can choose from a wide array of authentication options. However, in this case, we will use a simple key pair with the unique name gsg-keypair (you can choose any name you will remember). To generate a new key pair with the name gsg-keypair, using the command-line Tools for Windows, simply run the ec2-add-keypair command-line tools:


 
 
 C:\> ec2-add-keypair gsg-keypair 
 KEYPAIR gsg-keypair 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f 
 -----BEGIN RSA PRIVATE KEY-----
 MIIEoQIBAAKCAQBuLFg5ujHrtm1jnutSuoO8Xe56LlT+HM8v/xkaa39EstM3/aFxTHgElQiJLChp
 HungXQ29VTc8rc1bW0lkdi23OH5eqkMHGhvEwqa0HWASUMll4o3o/IX+0f2UcPoKCOVUR+jx71Sg
 5AU52EQfanIn3ZQ8lFW7Edp5a3q4DhjGlUKToHVbicL5E+g45zfB95wIyywWZfeW/UUF3LpGZyq/
 ebIUlq1qTbHkLbCC2r7RTn8vpQWp47BGVYGtGSBMpTRP5hnbzzuqj3itkiLHjU39S2sJCJ0TrJx5
 i8BygR4s3mHKBj8l+ePQxG1kGbF6R4yg6sECmXn17MRQVXODNHZbAgMBAAECggEAY1tsiUsIwDl5
 91CXirkYGuVfLyLflXenxfI50mDFms/mumTqloHO7tr0oriHDR5K7wMcY/YY5YkcXNo7mvUVD1pM
 ZNUJs7rw9gZRTrf7LylaJ58kOcyajw8TsC4e4LPbFaHwS1d6K8rXh64o6WgW4SrsB6ICmr1kGQI7
 3wcfgt5ecIu4TZf0OE9IHjn+2eRlsrjBdeORi7KiUNC/pAG23I6MdDOFEQRcCSigCj+4/mciFUSA
 SWS4dMbrpb9FNSIcf9dcLxVM7/6KxgJNfZc9XWzUw77Jg8x92Zd0fVhHOux5IZC+UvSKWB4dyfcI
 tE8C3p9bbU9VGyY5vLCAiIb4qQKBgQDLiO24GXrIkswF32YtBBMuVgLGCwU9h9HlO9mKAc2m8Cm1
 jUE5IpzRjTedc9I2qiIMUTwtgnw42auSCzbUeYMURPtDqyQ7p6AjMujp9EPemcSVOK9vXYL0Ptco
 xW9MC0dtV6iPkCN7gOqiZXPRKaFbWADp16p8UAIvS/a5XXk5jwKBgQCKkpHi2EISh1uRkhxljyWC
 iDCiK6JBRsMvpLbc0v5dKwP5alo1fmdR5PJaV2qvZSj5CYNpMAy1/EDNTY5OSIJU+0KFmQbyhsbm
 rdLNLDL4+TcnT7c62/aH01ohYaf/VCbRhtLlBfqGoQc7+sAc8vmKkesnF7CqCEKDyF/dhrxYdQKB
 gC0iZzzNAapayz1+JcVTwwEid6j9JqNXbBc+Z2YwMi+T0Fv/P/hwkX/ypeOXnIUcw0Ih/YtGBVAC
 DQbsz7LcY1HqXiHKYNWNvXgwwO+oiChjxvEkSdsTTIfnK4VSCvU9BxDbQHjdiNDJbL6oar92UN7V
 rBYvChJZF7LvUH4YmVpHAoGAbZ2X7XvoeEO+uZ58/BGKOIGHByHBDiXtzMhdJr15HTYjxK7OgTZm
 gK+8zp4L9IbvLGDMJO8vft32XPEWuvI8twCzFH+CsWLQADZMZKSsBasOZ/h1FwhdMgCMcY+Qlzd4
 JZKjTSu3i7vhvx6RzdSedXEMNTZWN4qlIx3kR5aHcukCgYA9T+Zrvm1F0seQPbLknn7EqhXIjBaT
 P8TTvW/6bdPi23ExzxZn7KOdrfclYRph1LHMpAONv/x2xALIf91UB+v5ohy1oDoasL0gij1houRe
 2ERKKdwz0ZL9SWq6VTdhr/5G994CK72fy5WhyERbDjUIdHaK3M849JJuf8cSrvSb4g==
 -----END RSA PRIVATE KEY-----
 
 

This creates a private key that must be copied and saved to a local file. To do this, open your favorite text editor (Notepad or TextPad for Windows works great) and create a new document named id_rsa-gsg-keypair, copy and paste everything between (and including) the "-----BEGIN RSA PRIVATE KEY-----" and "-----END RSA PRIVATE KEY-----" lines into it, and then save the file to any directory you wish.

If you are using PuTTY on Windows, the key pair you just created will have to be converted to a PuTTY-ready format. To do this:

  • 1. Under the putty directory (into which you unzipped the putty Tools), double-click puttygen.exe to start PuTTYGen.

  • 2. Click File -> Load Private Key.

  • 3. Find the key pair file you created (id_rsa-gsg-keypair).
  • 4. Click OK at the prompt .

  • 5. Click the Save private key button.
  • 6. Save the key as id_rsa-gsg-keypair.ppk.
  • 7. Click Yes when PuTTYgen prompts you about saving the key without a passphrase.

Starting/Running an Instance

Now comes one of the most important steps in the process: starting up the server instance so you can begin to install Oracle Database XE onto it. Although you might figure that there would be a lot of fanfare and complicated procedures to do this, especially considering that this is a public Linux AMI, this step is actually quite easy. To start the Fedora 8 instance you found in a previous step, simply run the ec2-run-instances command-line tools, using the reference to the AMI and the key pair you created:


 
 C:\> ec2-run-instances ami-f51aff9c -k gsg-keypair
 RESERVATION r-7430c31d 924417782495 default
 INSTANCE i-ae0bf0c7 ami-2bb65342 pending gsg-keypair 0 m1.small 
 
 
 2008-03-21T16:19:25+0000 us-east-1a
 
 

(Note: the instance ID in the second field of the output [i-ae0bf0c7 in this example] is a unique identifier for the instance, and you will use it later to manipulate this instance [including terminating it when you are finished].>

As with almost any other server startup, this server instance may take a couple of minutes to start. You can check the status with the ec2-describe-instances command-line tools:


 
 C:\>  ec2-describe-instances i-ae0bf0c7
 RESERVATION r-7430c31d 924417782495 default
 INSTANCE i-ae0bf0c7 ami-2bb65342 ec2-67-202-7-236.compute-1.amazonaws.com ip-10-251-31-162.ec2.internal 
 
 
 running gsg-keypair 0 m1.small 2008-03-21T16:19:25+0000us-east-1a
 
 

(Note: once the instance is started, you can use the ec2-describe-instances command-line tools to find external and internal DNS [network] names. In this example, you would use ec2-67-202-7-236.compute-1.amazonaws.com to reach your instance externally and ip-10-251-31-162.ec2.internal to reach it internally. In other words, if you see this message upon running ec2-describe-instance, your server is running [and you are also paying for time on it].)

Configuring Network Access

To support maximum availability and security, Amazon EC2 offers several command-line Tools that enable you to configure network access and authorization akin to firewall settings. Because you will want to access your instance via SSH and—more than likely—HTTP, you will need to use the ec2-authorize command-line tools to open access to those ports:


 
C:\>  ec2-authorize default -p 22 
PERMISSION     default  ALLOWS  tcp     22      22      FROM    CIDR   0.0.0.0/0 
C:\>  ec2-authorize default -p 8090 
PERMISSION     default  ALLOWS  tcp     8080      8080      FROM    CIDR   0.0.0.0/0
 
 

(Note: this article covers configuring Oracle Database XE to use port 8080. If you would rather use another port, you must authorize access to it by using the ec2-authorize command-line tools as in the above example.)

Using SSH to Connect to Your Instance

With your server started and its SSH port (22 in this example) open, you can now use SSH to remotely log in and access your instance as you would any other remote server. To do so, follow these steps:

  • 1. In the putty directory (into which you unzipped the putty Tools), double-click putty.exe to start PuTTY.
  • 2. Once PuTTY is started, go to Connection -> SSH -> Auth.
  • 3. Under Authentication parameters, click Browse... and select the PuTTY private key file you generated earlier (id_rsa-gsg-keypair.ppk).

  • 4. Go back to the session.
  • 5. For the host name, use your instance's unique external DNS (ec2-67-202-7-236.compute-1.amazonaws.com in this example). You can also pull out and use just the IP address from this. For instance, the IP address for ec2-67-202-7-236.compute-1.amazonaws.com would be 67.202.7.236.
  • 6. Leave port 22 as is.
  • 7. Click the Open button to log in.

This should log you in to your instance, whereby you will have all the standard Linux commands available to you, as you would on any other Fedora Linux server.

Downloading and Installing Oracle Database XE on an Amazon EC2 Instance>

As with any other Oracle implementation, there are plenty of ways you can download and implement Oracle software for your own needs or the needs of your particular project and/or organization. Given that there are many ways to do this, there are just as many best practices you may want to follow to implement exactly what you want or need. This section guides you through a simple implementation of Oracle Database XE on an Amazon EC2 instance. Once you have completed this section, you may want to do your own research and add to these steps, based on your needs and other best practices.

Download and Install Oracle Database XE

To install Oracle, you will first need to get a copy of the Oracle Database XE software to your Linux instance. Although there are plenty of ways do this, the easiest—although possibly the most time consuming—is to log in to OTN, download the Oracle Database XE software for Linux (RPM version), and then copy it to your Linux AMI via an SCP command (or PSCP command on Windows). To do this, once you have downloaded the Oracle DatabaseXE software to the local machine where you are running the EC2 commands and the SSH client, use an SCP command (PSCP on Windows) such as the following:

C:\ pscp -i id_rsa-gsg-keypair.ppk F:\Software\ora10g\xe\oracle-xe-10.2.0.1-1.0.i386.rpm root@ ec2-67-202-7-236.compute-1.amazonaws.com:/home

(Note: this will copy the Oracle Database XE software into the home directory, using the root user's account. You can change this to suit your own needs.)

While the Oracle Database XE software is being copied to your Linux AMI, log in to your Linux instance, using SSH (PuTTY), so that you can make some final preparations (read installations) for its new home. The first preparatory step is to configure a new library called libaio, which is an asynchronous I/O library not necessarily found on all Linux distributions but one that Oracle Database definitely needs. You can do this while logged in to your instance via SSH (PuTTY):

$yum install libaio

This command should immediately check with a couple of mirror sites for the latest and greatest (and most available) libaio library and will proceed to ask you if you want to download and install it (which you do). Here's what the output should look like:


 
 
 Loading "fastestmirror" plugin
 Determining fastest mirrors
 * fedora: mirror.cogentco.com
 * updates: mirror.cogentco.com
 fedora 100% |=========================| 2.1 kB 00:00
 primary.sqlite.bz2 100% |=========================| 4.9 MB 00:00
 updates 100% |=========================| 2.3 kB 00:00
 primary.sqlite.bz2 100% |=========================| 3.0 MB 00:00
 Setting up Install Process
 Parsing package install arguments
 Resolving Dependencies
 --> Running transaction check
 ---> Package libaio.i386 0:0.3.106-3.2 set to be updated
 --> Finished Dependency Resolution
 
 Dependencies Resolved
 ============================================================================
 Package Arch Version Repository Size
 ============================================================================
 Installing:
 libaio i386 0.3.106-3.2 fedora 19 k
 
 Transaction Summary
 ============================================================================
 Install 1 Package(s)
 Update 0 Package(s)
 Remove 0 Package(s)
 
 Total download size: 19 k
 Is this ok [y/N]: y
 Downloading Packages:
 (1/1): libaio-0.3.106-3.2 100% |=========================| 19 kB 00:00
 Running rpm_check_debug
 Running Transaction Test
 Finished Transaction Test
 Transaction Test Succeeded
 Running Transaction
 Installing: libaio ######################### [1/1]
 
 Installed: libaio.i386 0:0.3.106-3.2
 Complete!
 

Once that command has been run and the Oracle Database XE software has been successfully copied to your Linux instance, you can continue the installation by entering the following command at the Linux command prompt:

$ rpm -ivh oracle-xe-10.2.0.1-1.0.i386.rpm

This command first unpacks the Oracle Database XE software and then installs and configures it, based on your input. During the install, the first prompt you get will say something like this: "You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database." Because you are already logged in as root, you can simply type the following at the command prompt:

$ /etc/init.d/oracle-xe configure

With this command entered and run, Oracle Database XE will begin its post-configuration steps and ask you to input your preferred HTTP port (8080 by default), a database listener (1521 by default), and a password to be used for all DBA accounts. Last, you will get a final prompt, asking whether you want to start the Oracle Database XE instance. When all is said and done, you will have Oracle Database XE up and running on your system. Now comes the fun part: customizing your instance.

Customizing Your AMI and Oracle Environments

With Oracle Database XE up and running on your Linux instance, you may want to take some time to really make it your own. One of the things you can do right off the bat is set the path for your users so that you can use SQL*Plus from the command prompt without having to change to the Oracle BIN directory. To do this from the Linux command prompt, enter the following:


 
 
 $ export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
 $ export ORACLE_SID=XE
 $ export PATH=$PATH:$ORACLE_HOME/bin
 

You can also make things really interesting by enabling Oracle Database Express Edition to listen for remote connections (which will allow you—and others—to connect to Oracle Application Express from the internet). To do this from the Linux command prompt, enter this:


 
 $ sqlplus system/password (*where password is your system password)
 $ EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
 

Now you should be able to open a Web browser anywhere and use your instance of Oracle Application Express by navigating to your Amazon EC2 public address, followed by port 8080 (http://ec2-75-101-206-200.compute-1.amazonaws.com:8080/).

If you are familiar with the Oracle Database XE and Oracle Application Express environments, you should be able to customize just about anything you desire.

Creating Your Own Reusable Oracle/Amazon Machine Image

To this point, you have been working on an instance that you have made your own from another public AMI. However, once the instance is terminated, your work will be lost—unless, of course, you take what you have created and register your own AMI. (Or, of course, you can always use the free one supplied by Oracle.) To do this, you will use some simple bundling commands that will apply your keys to your instance, bundle up the entire instance, and then copy it to Amazon S3. Once you have bundled your instance and copied it to S3's permanent storage, you will be able to use it again and again without having to reinstall Oracle Database XE. To create your own AMI, do the following:

  • 1. Open a new command prompt (from Windows), and change directories to the directory where you saved the private key and the X.509 certificate.
  • 2. Copy these to your Amazon Linux instance, using SCP (or PSCP in Windows):
    
     
     
     C:\> pscp -i id_rsa-gsg-keypair.ppk pk-OVELY2MOG3K2VUXVRI3GPZE4457E42LK.pem cert-OVELY2MOG3K2VUXVRI3GPZE4457E42LK.pem
     
     
     root@ec2-75-101-206-200.compute-1.amazonaws.com:/mnt
     
  • 3. Using SSH (PuTTY on Windows), log in to your instance as root and use the ec2-bundle-vul tools to bundle your instance, using the private key (-k), the X.509 certificate (-c), and your AWS account ID as your username (-u, not your AWS Access Key ID)—this may take a few minutes to complete:
    
     
     
     $ ec2-bundle-vul -d /mnt -k /mnt/pk-OVELY2MOG3K2VUXVRI3GPZE4457E42LK.pem -c 
     /mnt/cert-OVELY2MOG3K2VUXVRI3GPZE4457E42LK.pem -u 117080109999 -r i386 
     
     
  • 4. Your newly bundled AMI needs to be uploaded to an existing Amazon S3 account such as the one you created when you initially signed up for Amazon EC2. This step uses the Linux ec2-upload-bundle, which takes a new bucket (what Amazon calls a directory on S3—in this case, we've used oraclexe as the bucket name, although you can call it anything you like) name (-b) as well as your AWS Access Key ID (-a) and AWS Secret Access Key (-s). As before, once you have entered this command, it will take some time to complete:
    
     
     $ ec2-upload-bundle -b oraclexe -m /mnt/image.manifest.xml -a 1HAY961AK34CXHKWNWG2 
     -s LJiWWdBmk7fuaPYOzUtHfxwhCEOgASTmnUXTpxDM 
     
     
  • 5. Once your newly created and bundled AMI has been successfully uploaded to Amazon S3, you will just need to register it with Amazon EC2. Once this command finishes, you will be able to start/stop your instance with your very own AMI ID (which is returned after the ec2-register command-line tools finishes). You do this step from the Windows command prompt, using the command-line tools, as follows: C:\> ec2-register oraclexe/image.manifest.xml IMAGE ami-7daf4b14 (Note: the AMI ID returned in this example is an ID for an actual AMI that was created for this article. Feel free to use it as a reference.)

As mentioned earlier, you have been using a public AMI for your EC2 instance up to now. However, once you have created, uploaded, and registered your instance via Amazon EC2 and S3, you will have something you can call your own: an AMI built to your specifications that can be used by you alone or shared with anyone. The important part is that you understand what the costs are of running Amazon Web Services and that you use your best judgment and best practices when starting your AMI as an instance or publishing it to the world.

Starting, Stopping, and Deregistering Your Amazon Machine Image

With all of the "hard" steps complete, all you have to do now is start and/or stop your instance. If your instance is currently running, you simply use the ec2-terminate-instances command-line tools (from Windows) followed by the instance ID to shut it down. For example, to stop the instance whose ID is i-ae0bf0c7, referenced at the beginning of this article, you would run the following:

C:\> ec2-terminate-instances i-ae0bf0c7

This would terminate the instance with that ID, and if you wanted to start it again, you would have to use the ec2-run-instances command-line tools followed by the new AMI ID created for you (ami-7daf4b14):

C:\> ec2-run-instances ami-7daf4b14 -k gsg-keypair

If you ever felt you wanted to start the entire process over, soup-to-nuts, and wanted to wipe out the AMI and the associated bundle you had created, you would use the following steps:

  • 1. Deregister the AMI you created, using the command-line Tools: C:\> ec2-deregister ami-7daf4b14
  • 2. Remove the bundle from Amazon S3, by logging in to the Linux instance via SSH (PuTTY) and running the following (-b is the bucket name, -a is your Access Key ID, and -s is your AWS Secret Access Key): ec2-delete-bundle -b oraclexe -p image -a 1HAY961AK34CXHKWNWG2 -s LJiWWdBmk7fuaPYOzUtHfxwhCEOgASTmnUXTpxDM
  • 3. And that's it!

Conclusion

Cloud computing services offer a world of potential that, in many cases, cannot be matched by other hosting options. Whether you're looking for vast computing power, unlimited storage, or cheap development servers, it would seem that services such as Amazon's EC2 and S3 offer it all. Although this article describes how you could put Amazon Web Services to good use with an Oracle Database XE instance, it goes without saying that the sky is definitely not the limit.


Justin Lokitz [ justin.lokitz@autodesk.com] is a product manager for Autodesk Inc.