Saturday, August 18, 2012

Creating an Oracle 11g instance in AWS

This document assumes, that you already have an AWS account and you are able to login using any standard net browser. After logging into AWS (Amazon Web Services) EC2 site, click on Launch Instance button.
NOTE: Starting this instance using this documentation will incur some monthly financial cost.

We'll user the instance ami-117b9778. We can narrow down the earch by typing in some key words. I used Oracle.

We’ll use a specific instance: ami-117b9778 instance store.
We’ll create a “small instance”.
No specific preference for zone.

In the next screen we’ll take default for all values.
Specifically note if you use monitoring, additional charges may apply.
Click on Continue…
At this point, we have chosen our AMI.
We’ll add one “tag information” for our instance…
We are ready to create KEY Pair for our instance. The Key-Pair is used for loggin into our instance with root access. With this set up, we’ll disable userid/password login to root and root access login will only be allowed using PKI key pair.
Note: we’ll be using Putty-SSH telnet to log into this instance as root. We’ll later create additional user-id which will have password enabled.
NOTE: This step is important, as we’ll create key for server and client. Save the client file safely in a directory and note the location/filename.
Give the key-pair a unique name, click on Create & Download your Key Pair button.
Note: You could proceed without key creation and create one later time.
You may be asked to save the file.
I clicked on Save As and chose a specific local location to save the file.
Note that the file type downloaded is PEM.
We have to choose a Security Group. We’ll go with default. We can change the values like port and accessibility later (or you can create a new security group).
We’ll go with default and click on continue…
Review the summary…
You have an opportunity to change your settings however you can also change many of these setting later.
We’ll click on Launch button
This step will take few minutes to launch the instance.

Click on Close to create an Oracle 11g instance. You’ll be returned to EC2 home.
Note: In the My Resources section, both Key Pair and Security Group has been updated.
Click on Instances on left panel to go to your instance page.
Note the instance is in pending state and status is initializing.
This may take some time. Just have some patience… It’ll come through :-)
Once your instance is instantiated, you find the following in your EC2 home.
Note the instance is in running state and status is green check.
Note: The name of the instance is empty. You can edit the name to something that you can recognize, by clicking on the field.

Now our next step is to connect to our instance.
To connect to our newly created AWS instance, we are going to use PUTTY-SSH telnet session.
You can download putty-ssh telnet client from here. I downloaded putty and puttygen from source forge.
PUTTYGEN will be used to generate private key from the PEM file that was downloaded from the KEY-PAIR of aws instance.
Generate Private Key using PUTTYGEN
Run PUTTYGEN by double clicking on the application
Click on LOAD… Note file type of PPK!!!!
Navigate to the directory where the PEM file was saved and select the PEM files (using all file types).
Open the PEM file.
DONOT Click on Generate: this allows you to move cursor over the BLANK space to generate randomized key, this will not work with your instance.
JUST click on SAVE PRIVATE KEY and Save Private Key, ENSURE to change the file type to ppk.
Close the PUTTYGEN application.

Connect to our AWS instance

Now we’ll use the PUTTY (telnet) application to connect to AWS instance.
When you open PUTTY application, you get the following dialog.
From the AWs instance definition (property) use Public DNS address
In our case the value is ec2-107-20-86-85.compute-1.amazonaws.com
Browse to the PPK file that was saved from PUTTYGEN.
Save PUTTY configuration and Open
Type in root and press ENTER
The Oracle 11g instance on AWS is READY to be configured.

Configure Oracle 11g instance

Ready for Oracle configuration…
The password and verification was entered and installation complete.
Check, if Oracle processes are running…
Check ID / GRP ???
1root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$ id
2uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
3root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$ id oracle
4uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba),502(oper),503(asmadmin)
5root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$ groups
6root bin daemon sys adm disk wheel
7root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$
Logged in as ROOT to the linux instance, we’ll attempt to log into database instance.
Just to make sure the database is there, configured and started. We’ll use sqlplus.
1$ ./sqlplus
2Error 6 initializing SQL*Plus
3SP2-0667: Message file sp1.msb not found
4SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
SP2-0750 indicates we have not set ORACLE_HOME value. We’ll do that and try again.
01root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1/
02
03root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$ ./sqlplus
04
05SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 23 22:43:39 2012
06
07Copyright (c) 1982, 2009, Oracle. All rights reserved.
08
09Enter user-name: oracle
10Enter password:
11
12ERROR:
13ORA-12162: TNS:net service name is incorrectly specified
ORA-12162 indicates we have not set ORACLE_SID value. We’ll do that and try again.
01root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$ export ORACLE_SID=orcl
02root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]$ ./sqlplus
03
04SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 23 22:44:37 2012
05
06Copyright (c) 1982, 2009, Oracle. All rights reserved.
07
08Enter user-name: oracle
09Enter password:
10
11ERROR:
12ORA-01034: ORACLE not available
13ORA-27101: shared memory realm does not exist
14Linux Error: 2: No such file or directory
15Process ID: 0
16Session ID: 0 Serial number: 0
Login was successful (in a way) however ORA-01034 indicates that ORACLE database instance is not up and running. At this point we can connect to ORCL instance in NOLOG mode.
1root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin]
2$ ./sqlplus /nolog
3
4SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 23 22:46:15 2012
5
6Copyright (c) 1982, 2009, Oracle. All rights reserved.
7
8SQL>
Nice… We are now connected to ORCL instance of the database. However, the DB instance is not up and providing any service. We’ll try to start the database instance.
1SQL> startup
2
3ORA-01031: insufficient privileges
4
5SQL> exit;
6
7root@domU-12-31-39-03-BD-92:[/u01/app/oracle/product/11.2.0/db_1/bin
The database exists, but we are unable to start the database as root is NOT a member of dba or oper groups. Only members of these groups are authorized (ORA-01031) to start or stop a DB instance.
In the next blog entry, I’ll continue with configuring the database instance and starting the database.
However, before we do that we should also create a non-root user at the OS level and open up the LINUX instance for password login.

We'll continue and connect and work with this DB instance in the following BLOG entry.
http://tsp-inc.blogspot.com/2012/08/experiment-with-new-oracle-instance-in.html

2 comments:

  1. Great post on this, everything was going as expected from this post. However, did you ever post the continuation for this? I've been having problems with privileges/memory/etc. and would appreciate further instructions.

    ReplyDelete
  2. Steve,
    Thank you.
    I followed up in the following entry...
    http://tsp-inc.blogspot.com/2012/08/experiment-with-new-oracle-instance-in.html

    Hope this helps.
    Sudhakar B.

    ReplyDelete