Why Amazon Linux? It's easy and it's pre configured with most of what you need. Both cloud wise and for other things. It also gets good reviews as a production OS.
No, Oracle 11g XE on Amazon Linux this is not supported by Oracle. But then again, you will receive no official support on Oracle 11g XE by Oracle on any OS...
I have not validated if every step described below is necessary, by I reasoned that the standard install steps will stand, even if they upgrade the default Amazon Linux AMI.
If you have no experience with Linux or Amazon EC2, I think you will be better off with a more verbose installation guide than this is!
Create the Instance
If I am unclear (or just a tad abbreviated), just follow this documentation at any time.
- Launch new instance, and choose "Basic Amazon Linux AMI YYYY.MM"
- Choose instance type micro, set or create key pairs and set or create security group (everything else, just keep default)
Your are done creating the instance.
Connect to the Instance
I use PuTTY, for alternatives or a more elaborate description of how to connect with PuTTY, see this documentation. I assume you have PuTTY suite (with PuTTYGen) installed.
You also have to check that port 22 is open for the security group associated with the image.
- Start PuTTYGen
- Load the .pem file created from then key pair in use with the instance (switch to "all files" to see it)
- Click Save Private Key, and Yes
- Exit PuTTYGen
- Start PuTTY
- Copy Public DNS from EC2 Console
- Paste Public DNS into Host Name in PuTTY Configuration
- On left side, go to Connection -> SSH -> Auth and browse to the location of the previously generated ppk-file
- Back to Session, give it a name in "Saved Sessions" and Save
- Click Open and Yes in the dialog
- Connect as ec2-user
You are done connecting to your new instance.
This you can do on your host machine, or the newly created instance. I will describe how for the newly created instance (less work for me, but also less secure for you!).
- Log in as ec2-user
Configure root user:
- sudo su - root
- passwd <new password>
- exit
- su - root
- <new password>
- id
- su - root
- vi ./.bash_profile
- export EC2_PRIVATE_KEY=/root/pk-<your pk>.pem
- export EC2_CERT=/root/cert-<your pem>.pem
- export EC2_URL=https://ec2.<region>.amazonaws.com
I use eu-west-1 as region. You should now be able to issue
- ec2-describe-availability-zones
And receive a list of zones.
First, create and attach a new volume (30Gb) to the instance:
- su - root
- ec2-describe-instances
- Take a not of the instance id and availability zone
- ec2-create-volume --size 30 --availability-zone <zoneSameAsTheInstance>
- Take a note of the volume created
- ec2-attach-volume <yourVolumeId>
-i <yourInstanceId> -d <yourDeviceName> - Like this: ec2-attach-volume vol-xxxxxx -i i-xxxxxx -d /dev/sdf
- ec2-describe-volumes
- mkfs -t ext3 /dev/sdf
- tune2fs -m0 /dev/sdf
- mkdir /u01
- mount /dev/sdf /u01
- vi /etc/fstab
- Add the following line:
- /dev/sdf /u01 auto defaults,noatime 0 0
- dd if=/dev/zero of=/home/swapfile bs=1024 count=2097152
- mkswap /home/swapfile
- vi /etc/fstab
- Add the following line:
- /home/swapfile swap swap defaults 0 0
Set host name for the server:
- vi /etc/sysconfig/network
- HOSTNAME=<yourHostName>
- :wq
- vi /etc/hosts
- Add <yourHostName> to the line containing 127.0.0.1
- :wq
- shutdown -r now
Configure Instance for Oracle 11g XE
Since we can't use yum oracle-validated on the Amazon Linux, we will have to do this the hard way.
Create oracle user++:
- su - root
- groupadd oinstall
- groupadd dba
- useradd -g oinstall -G dba,oinstall oracle
- passwd oracle
- chown oracle:oinstall /u01
- yum install binutils-2.*
- yum install compat-libstdc++-33*
- yum install elfutils-libelf-0.*
- yum install elfutils-libelf-devel-*
- yum install gcc-4.*
- yum install gcc-c++-4.*
- yum install glibc-2.*
- yum install glibc-common-2.*
- yum install glibc-devel-2.*
- yum install glibc-headers-2.*
- yum install ksh-2*
- yum install libaio-0.*
- yum install libaio-devel-0.*
- yum install libgcc-4.*
- yum install libstdc++-4.*
- yum install libstdc++-devel-4.*
- yum install make-3.*
- yum install sysstat-7.*
- yum install unixODBC-2.*
- yum install unixODBC-devel-2.*
- /sbin/sysctl -a | grep fs.suid_dumpable
- /sbin/sysctl -a | grep fs.aio-max-nr
- /sbin/sysctl -a | grep fs.file-max
- /sbin/sysctl -a | grep kernel.shmall
- /sbin/sysctl -a | grep kernel.shmmax
- /sbin/sysctl -a | grep kernel.shmmni
- /sbin/sysctl -a | grep kernel.sem
- /sbin/sysctl -a | grep net.ipv4.ip_local_port_range
- /sbin/sysctl -a | grep net.core.rmem_default
- /sbin/sysctl -a | grep net.core.rmem_max
- /sbin/sysctl -a | grep net.core.wmem_default
- /sbin/sysctl -a | grep net.core.wmem_max
Compare it to:
- fs.suid_dumpable = 1
- fs.aio-max-nr = 1048576
- fs.file-max = 6815744
- kernel.shmall = 2097152
- kernel.shmmax = 536870912
- kernel.shmmni = 4096
- kernel.sem = 250 32000 100 128
- net.ipv4.ip_local_port_range = 9000 65500
- net.core.rmem_default = 262144
- net.core.rmem_max = 4194304
- net.core.wmem_default = 262144
- net.core.wmem_max = 1048586
In my image, I had to add the following lines to sysctl.conf:
- vi /etc/sysctl.conf
- # Added by a Monkey
- fs.suid_dumpable = 1
- fs.aio-max-nr = 1048576
- fs.file-max = 6815744
- kernel.shmmni = 4096
- kernel.sem = 250 32000 100 128
- net.ipv4.ip_local_port_range = 9000 65500
- net.core.rmem_default = 262144
- net.core.rmem_max = 4194304
- net.core.wmem_default = 262144
- net.core.wmem_max = 1048586
Well, obviously not the first bullet point ;)
- vi /etc/security/limits.conf
- oracle soft nproc 2047
- oracle hard nproc 16384
- oracle soft nofile 1024
- oracle hard nofile 65536
- oracle soft stack 10240
- /sbin/sysctl -p
Downloading and Installing Oracle 11g XE
Create download directory:
- su - oracle
- mkdir /u01/download
- cd /u01/download
- Log into oracle.com on your HOST machine with a REAL browser
- Find download on oracle.com
- Accept licence agreement
- Click link to download
- Capture and copy request (network tab in Chrome will give you that):
http://download.oracle.com/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip?AuthParam=<somestring> - Paste it into ssh session:
- wget http://download.oracle.com/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip?AuthParam=<someString> -O oracle-xe-11.2.0-1.0.x86_64.rpm.zip
- And the file will be downloaded
Installing is much easier:
- su - root
- unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
- cd /u01/download/Disk1
- rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
- /etc/init.d/oracle-xe configure
- Accept the defaults (unless you know what you are doing!)
And you are done installing Oracle 11g XE! If you want to test APEX, just open port 8080 in the security group in the AWS EC2 Console, and use the public dns for the instance to reach it.
Configure Oracle User Environment
Just a touch if you are going to use oracle user in ssh later:
- su - oracle
- cat /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
- <copy the lines below into the .bash_profile>
- export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
- export ORACLE_SID=XE
- export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
- export PATH=$ORACLE_HOME/bin:$PATH
- cd
- vi .bash_profile
- <paste the lines above>
- :wq
Tying it Up
At this point, you should restart to verify that everything works, create a new AMI based on the current state of the instance, enable ssh connect with oracle user, reconfigure swap space, etc, etc.Remember not to use EBS storage for anything you really care for, data should be backed up in a safe manner (as you normally would do anyway).