How to Get Started with Amazon EC2 (Oracle 11g XE example)

Apr 4, 2011 / By Alex Gorbachev

Tags: ,

I’ve just published Oracle Database 11g Express Edition Amazon EC2 image (AMI) but most of you have never used Amazon EC2… Not until now! This is a guide to walk you thorough the process of getting your very first EC2 instance up and running. Buckle up — it’s going to be awesome!

    1. Go to Amazon Web Services and open an account. You could use one that you buy your books with.
    2. Go to AWS Management Console for EC2 and sign up for Amazon EC2. You will need your credit card for this. You will not be charged anything unless you are either start using EC2 instances or allocate EBS storage and other related items. The sign-up page shows you all the pricing. You will especially like “Free tier for new AWS customers” section that gives you 750 hours of Micro instance uptime, 10 GB of EBS storage some bandwidth and few small goodies. This mean that you will not be charged anything in the beginning of your experiments. They will also do phone verification — I can’t remember I’ve seen it last time so it must be reasonable new. Works for cell phones too. Activation usually takes just few minutes and you’ll get an email confirmation and you get access to EC2, VPC, S3 and SNS. Direct link to AWS Management Console for EC2
    3. Now you can launch your first instance. So let’s start Oracle 11g XE beta image that I published just recently. Click “Launch Instance” then select “Community AMIs” tab. It will start loading AMIs list and it will take ages so don’t wait for it to finish and search for “pythian” – you will get pythian-oel-5.6-64bit-Oracle11gXE-beta image with AMI ID ami-e231cc8b the latest at the time of this writing.

      Select that image.

  1. On the next tab choose instance size. It’s enough to use Micro instance to start playing with Oracle 11g XE but be prepared that Micro instance doesn’t guarantee any CPU capacity so it might be “bursty” but, hey — it’s free or costs peanuts if you run out of free time. You could also choose an availability zone closer to you.
  2. On the next screen leave everything by default. You could select what to do when you shutdown the instance from inside the instance. Stop will keep your instance and EBS storage allocated and you can start it and all your changes will persist. However, you will be charged for allocated EBS storage (if you go beyond free 10GB) but it’s very little. “Terminate” will actually release EBS storage if you shutdown your instance. Note that you can always stop and terminate instances from AWS Management Console. I usually leave option on “Stop” to avoid accidental data loss. You can skip defining any tags — this is optional metadata so you can orient better in your instances. I recommend you at least specify a descriptive name to make sure you clearly distinguish multiple running instances later.
  3. If you didn’t have a Key Pair created in the past, you will do that at the next step. This is basically public / private key pair and you get to download private part — save it and keep it safe and don’t share this .pem file with anybody. Someone with access to it can gain root access to your images! You can always create more than one Key Pair by the way.
  4. Next, you will need to either select an existing Security Group or create a new one. Default security group doesn’t fit us because you want to open other ports to access you 11g XE database. You can keep default group and only access by SSH if local access from SQL*Plus command prompt is all you need. It’s also the safest way but for your playground, you might want more flexibility. For 11gXE instance you will probably want SSH access (port 22), SQL*Net access (port 1521) and APEX access (port 8080). I also like to open ICMP for ping. Be sure you understand what you are doing if you will be placing any sensitive data there. I also open it to the world (source 0.0.0.0/0) so anybody who knows the passwords or have correct shard keys setup, can get on your instance. You can limit it to your current IP only (and you can change the policy online if you IP changes later — use AWS Management Console). There are bunch of site that would tell you your public IP (providing you don’t use a proxy coming from another IP) like this one. To limit access from that IP only enter it in the source as xxx.xxx.xxx.xxx/32. Of course, you can enter subnets too if you know what I’m talking about.
  5. That’s it — all that’s left is click the “Launch” button.
  6. You will then see your image as “pending” in the console and usually just seconds later it switches into “running” state. Note that it will take a minute or so to boot and launch sshd daemon so you can connect via SSH. You can also check console log by choosing “Get System Log” from the context menu (it does take few minutes usually so it will come back empty until then). The easiest way to connect is to choose “Connect” from the context menu — it will present you instructions to connect as root using the .pam key file you downloaded when creating your Key Pair earlier on. Note that if you are on Unix, you will need to set proper permission for your key to ensure safeguarding — chmod 600 AlexG.pem.

    You can also get the public IP alias from instance details as “Public DNS” – just select and instance and scroll details in the bottom pane. For that particular image, I also enable public key authentication so you can simply add your public key to oracle’s ~/.ssh/authorized_keys file — it’s already there with correct permissions. This way I don’t have to go via root every time.
    If you are a Windows user using Putty, you can convert your .pem file into Putty Private Key (.ppk) file following Marcin’s comment.
  7. Database and listener will auto-start. You can open 11g XE web interface. In my example it’s http://ec2-50-17-156-24.compute-1.amazonaws.com:8080/apex/apex_admin for Administration. Note that it’s not SSL connection so you don’t want to use it for any sensitive data unless you reconfigure to https. This is also the time you want to change passwords from default ones.
  8. You can access your database over SQL*Net via sqlplus, SQL Developer or any other tool.
  9. You will see the instance and EBS volume attached in your AWS Management Console. If you stop the instance, you will see that the EBS volume is still attached so you data is still there when you start it. If you terminate the instance, all you changes and data will be gone since the EBS volume will be detached and deleted. You can, however, launch another instance as many time as you want from the same AMI. Just make sure you change the passwords after the launch!

That’s all — you can now start playing with Oracle 11g XE without paying a penny (or very little), without consuming any resources on your own laptop/desktop and have as many of them running as you want. And you can always start from scratch if you screw something up.

10 Responses to “How to Get Started with Amazon EC2 (Oracle 11g XE example)”

  • [...] you never used Amazon EC2 before, see detailed step-by-step guide on how to get started with EC2 on the example of this 11g XE [...]

  • Well done Alex.
    One more information for Putty users you need to convert AWS key (pem file) into Putty private key (ppk) using PuTTYgen.
    Load pem file to that tool using Load button and save it as private ppk key which can be used in Putty.

    regards,
    Marcin

  • Alexis Gil Gonzales says:

    Alex,

    I just tried “your” AMI and likes this one.
    As I mentioned before, I installed 11g XE on an Amazon vanilla linux AMI, which is a bit more compact (8GB) than the OEL-based one, but the memory footprint is better in the latter.

    I initially wanted to use the firstboot scripts (you have some on the Amazon AMI’s /etc/init.d ) so that it installs XE on the first boot. But then I thought, “is it worth the hassle ?” XE limitations are pretty clear so customisability is not relevant here.

    I’d rather make further stability tests on this one (eg the 404′s). (

    Greetings,

    Alexis

  • Greg says:

    Thank you for putting out the AMI and this quick and easy starting guide. I fired the thing up and I am getting 404s left and right. Maybe it’s a beta thing…

    Greg

  • Alejandro says:

    Hey! Thanks for the post, it worked nice and smooth but what’s the password for sys and system? Probably is better the same AMI but let the /etc/init.d/oracle-xe configuration for the final user.

    Cheers!

  • Joe says:

    First of all, thanks for the great tutorial.

    I’m up and running in ec2 using this AMI, but I have one problem. I can SSH to the server just fine, but I cannot tnsping the oracle instance. I am using windows/putty. I set up tunneling…source port 1521 to destination ec2-##-##-###-###.compute-1.amazonaws.com:1521. Shouldn’t I be able to open a cmd prompt and tnsping ec2-##-##-###-###.compute-1.amazonaws.com successfully? Keep getting TNS:operation timed out. I must be missing a step. Thanks in advance.

  • You need to configure Security Groups properly in AWS (see step 7). My image already has iptables setup with this port open so shouldn’t be a problem there. Of course, ensure that listener is up and running.

    I think you probably didn’t setup Security Group properly but there might be other reasons too.

  • [...] another easy-to-follow guide to this process was published back in April by Alex Gorbachev here: http://www.pythian.com/news/22045/how-to-get-started-with-amazon-ec2-oracle-11g-xe-example/, which may suit your needs – although it is based on an AMI with a beta release of 11gXE [...]

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>