Finally, I’ve got everything in place for the big one – installing 11gR2 on my Ubuntu server.
NOTE – if you’ve stumbled across this post in search of instructions for installing Oracle XE 11g on Ubuntu, you can find installation steps here.
As far as the server is concerned, I’ve posted on everything I’ve done since I installed it onto the machine.
The pre-requisites for this Oracle installation were :
Installing the server and setting up ssh
Tunneling X over SSH
I also setup a SAMBA share on the server. This is not directly relevant to the Oracle setup but I’ve included a link to it here as it serves to complete the picture of the state of the server before I started the installation. It also has a section on mounting a USB stick on the server, which may be relevant when it comes to transferring the Oracle files onto the server.
Whilst I’m mentioning links, I should acknowledge the helpful information I got from here and especially here.
Whilst I’m here, I probably don’t need to mention that Oracle isn’t exactly supported on Ubuntu at the time of writing, so I assume that, if you are planning to go down this route, it’s for your own edification and amusement. If your planning to setup a production database environment, then you really should be doing so on a supported OS.
One final, but pertinent point to note is that, like many of my recent adventures with Ubuntu Server, this was achieved after a certain amount of trial and error. I know Oracle pretty well. However, I make no claims to being a linux expert. The steps that follow worked for me. That doesn’t mean that there’s not an easier/better/safer way to do it.
First stop are the pre-checks as recommended in the Oracle Installation Guide.
Once you’re happy that you’ve got the tin to do the job, it’s time to get the software.
Unfortunately, there’s no rpm package for this version, so you need to download 11g release 2 from here.
As I’m running the 32-bit server, I got the Linux x86 version of Oracle Database 11g Release 2 ( 184.108.40.206.1.0)
As you’ll notice from my previous posts, the server was prone to get a little unhappy when copying large files or large amounts of data generally to it from an external device. However, extracting the compressed download files worked fine.
To achieve this, I downloaded the required files onto a trusty memory stick, mounted it on the server, then unzipped it.
The files are in zip format, so I needed to get the unzip package :
sudo apt-get install unzip
Now with the USB mounted on /media/external (have a look here if you need details on how to do this):
sudo unzip /media/external/linux_11gR2_database_1of2.zip -d .
sudo unzip /media/external/linux_11gR2_database_2of2.zip -d .
sudo unmount /media/external
This should extract the files in the zips into a newly created directory called database under /media.
NOTE – it’s probably a good idea to make sure all is working as expected after unzipping the first file – i.e. that the database directory has been created and that all of the files have been extracted under that directory.
Updating the packages on the Server
Connect to the server, switch to root and update the packages currently on the server
Once this is done, reboot the server so we’re sure that all the changes take effect.
Getting Required Packages
Connect to the server again and ( as root) download some more packages ( I’ve listed these as one command at a time to make it easier to read) :
sudo su -
NOTE – the following packages are also required for the Oracle install, but they were already present on the server :
gcc make binutils rpm
Final Server Preparations
We need to tweak the server environment, setup some users, and create some links.
First off, update the shell ( we’re still connected as root here, hence the # prompt)
# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-04-28 19:59 /bin/sh -> dash
# ln -sf bash /bin/sh
# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-05-01 22:51 /bin/sh -> bash
Add users and groups
# set -o vi
# addgroup oinstall
Adding group `oinstall' (GID 1001) ...
# addgroup dba
Adding group `dba' (GID 1002) ...
# addgroup nobody
Adding group `nobody' (GID 1003) ...
# usermod -g nobody nobody
# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
# passwd oracle
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
# mkdir /home/oracle
# chown -R oracle:dba /home/oracle
Create symbolic links
# ln -s /usr/bin/awk /bin/awk
# ln -s /usr/bin/rpm /bin/rpm
# ln -s /usr/bin/basename /bin/basename
Not entirely sure why we need to do this bit, but I did
# mkdir /etc/rc.d
# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d; done
Create the ORACLE_BASE directory
# mkdir -p /u01/app/oracle
# chown -R oracle:dba /u01
Now we need to change some config files :
/etc/sysctl.conf – make sure that the following parameters are set to these values. These should all be placed at the end of the file.
fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 1048576 net.core.wmem_max = 1048576 net.ipv4.ip_local_port_range = 9000 65535 fs.aio-max-nr = 1048576
/etc/security/limits.conf – add these settings to the end of the file :
oracle soft nproc 2047 oracle hard nproc 16384 oracle hard nofile 65536 oracle soft nofile 1024
/etc/pam.d/login – add the following line at the end of the file
session required /lib/security/pam_limits.so
In order to make sure that all of these settings had taken effect, I did a reboot at this point :
Installing the Oracle Software
Now, cross everything, check that you are indeed wearing your lucky underpants…time to do the install.
Start a terminal session on the client and ssh into the and check the setting
ssh -X administrator@server
First, we need to get the value of the DISPLAY variable as we’ll need to set it when we su to the oracle user so that the installer GUI will run on the client ( remember, we have no X-Windows desktop on the server).
Now we need to make sure that the server is running in the correct runlevel
The last number in the output of the runlevel command is the current runlevel.
The server is currently at runlevel 2, we need it to be at 3 so :
sudo init 3
NOTE – at this point, I opened a separate ssh session on the server and su’d to root on that session, just in case I hit any issues during the installation process. On the fifth attempt to get the install to work this changed into for when I hit issues.
Now we’re ready to fire up the installer.
su – oracle
After a short pause, you should now see this screen :
Please bear in mind that these screenshots were taken over numerous installation attempts so the step numbers displayed at the top may not match up to what you see. However, the screens themselves should be the same as the ones below.
Uncheck the I wish to receive security updates via My Oracle Support – if you’re installing on Ubuntu, your doing it for your own research purposes so aren’t going to have paid for Oracle support anyway.
We’re just going to install the software at this point, so select Install database software only ( as per the screenshot above) and click Next
We’ve got enough on our plate just trying to persuade oracle to work on this platform, so let’s keep it simple and just go for Single database installation.
English (United Kingdom) ? Surely this should read English( Proper, not that strange dialect they use in The Colonies across the Atlantic). Enough of the jingoism, make the appropriate selection and click Next.
We’re going for Enterprise Edition. Click Next
Steps 6, 7 and 8 should provide you with default suggestions, which I accepted in each case.
This is where it gets a bit interesting. The first time I tried this, I hadn’t set all of the parameters in sysctl.conf and limits.conf to oracle’s liking. Some of these come up as fixable and the Fix & Check Again button is enabled.
If you click this, Oracle will direct you to a script that you can run as root to correct the problems :
If you do go down this route, hit Check Again once you’ve run the script(s).
As you can see, the installer complains about a number of things which you can by-pass by checking the Ignore All checkbox in the top left-hand corner.
Note, for the record, oracle complained about the following packages being missing ( which I ignored) :
make-3.80 binutils-2.15.92.02 gcc-3.4.6 libaio-0.3.105 glibc-2.3.4-2.41 compat-libstdc++-33-3.2.3 elfutils-libelf-0.97 elfutils-libelf-devel-0.97 glibc-common-2.3.4 glibc-devel-2.3.4 glibc-headers-2.3.4 gcc-c++-3.4.6 libaio-devel-0.3.105 libgcc-3.4.6 libstdc++-3.4.6 libstdc++-devel-3.4.6 sysstat-5.0.5 unixODBC-2.2.11 unixODBS-devel-2.2.11 pdksh-5.2.14
Once you’re happy, Click Next
At this point, I did select Save Response File, just in case I needed to try a silent installation. Fortunately, I didn’t, but it’s probably worth doing, just in case.
This will take a while, but at least you get a progress bar.
Once it’s all completed, click Next and you get this confirmation
Celebrate with a beverage of your choice…but not too much, we still need to create a database.
Creating a database using Database Configuration Assistant
First of all, we need to get another package. On the server :
sudo apt-get lesstif2
Now we can run the Database Configuration Assistant ( DBCA).
This time, connect to the server as oracle :
ssh -X oracle@server
Make sure that the DISPLAY variable is set. If not, set it to the value it was for the software installation. So, if it was localhost:10.0 for that session then :
now we just need to fire it up :
Just click through the first couple of screens until you get to :
Hot Tip : when you pick a Global Database Name and SID here, make sure it’s no longer than 8 characters.
If you’re foolish enough to pick one with more characters ( such as orakarmic, to take a completely random example), you’ll find that, when you come to check your new database, it thinks it’s called ORAKARMI, at least, in v$instance.
On reflection, orakoala would probably a better, not to mention fluffier, choice.
Anyway, once you’ve chosen a database name, click Next.
Uncheck the Configure Enterprise Manager box here. Once again, we want to keep things as simple as possible.
Choose your passwords. Obviously, it’s a good idea to make a note of them at this point !
Click Next through the next few screens until you get to :
I’d like the sample schemas installed.
Keep clicking next until…
At this point, you should get a nice screen confirming what dbca is going to do. You should do.
I haven’t got a screenshot of this because dbca popped up a blank screen. I’m not sure whether this was Java having a sulk, or some problem with my setup.
Although nothing was displayed, I managed to get past this screen by randomly clicking in the bottom third of the window until I evidently managed to hit the relevant button…because I then got this screen :
Yes, it’s supposed to have a prograss bar on it, but all I got was the animated gif. Eventually however, Java decided to behave itself once more and displayed :
Nearly done. One final ingredient required. What’s that you say ? More beer ? Good guess…
Post Installation Configuration
We want to make sure that any sessions we start on this server have the correct environment variables set, so edit /etc/profile and add :
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 export PATH=$PATH:/u01/app/oracle/product/11.2.0/dbhome_1/bin export ORACLE_BASE=/u01/app/oracle export ORACLE_OWNR=oracle
Next, we want the database to start when the server boots.
Edit /etc/oratab and change the line :
where SID is the name of the database you created.
Next, we want to create a script to execute on startup to start the database and the listener :
sudo vi oracledb
The script should be as follows :
#!/bin/bash # # Run-level Startup script for the Oracle Listener and Instances # It relies on the information on /etc/oratab # Based on script listing at # http://www.pythian.com/news/1355/installing-oracle-11gr1-on-ubuntu-810-intrepid-ibex/ # Mike 7/3/10 # export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 export ORACLE_OWNR=oracle export PATH=$PATH:$ORACLE_HOME/bin if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ] then echo "Oracle startup: cannot start" exit 1 fi case "$1" in start) # Oracle listener and instance startup echo -n "Starting Oracle: " su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start" su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" touch /var/lock/oracle echo "OK" ;; stop) # Oracle listener and instance shutdown echo -n "Shutdown Oracle: " su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop" su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" rm -f /var/lock/oracle echo "OK" ;; reload|restart) $0 stop $0 start ;; *) echo "Usage: `basename $0` start|stop|restart|reload" exit 1 esac exit 0
Now make the script executable and set it to run at boot time :
chmod a+x /etc/init.d/oracledb
update-rc.d oracledb defaults 99
Testing Server Changes
Connect via ssh as oracle, check that the environment variable changes in /etc/profile have been picked up :
Now we want to test our script. First off, we need to shutown the database :
sqlplus / as sysdba
SQL> shutdown immediate
Now connect to the server as the administrator and run the script
sudo /etc/init.d/oracledb start
This should start the TNS Listener and the database. To check :
The output of this command should include the line :
Service "orakarmic.server" hasd 1 instance(s).
Instance "orakarmic", status READY, has 1 handler(s) for this service...
You should also be able to connect to the database via SQL*Plus as before.
If you now reboot the server, you can then verify that both the listener and the database have started correctly :
SQL> select status from v$instance;
The query should return a status of OPEN.
Connecting to the database from a client machine
The client needs to have an oracle client or similar installed.
There should be a file called tnsnames.ora in $ORACLE_HOME/network/admin.
Simply add an entry for your new database in this file. It will something like this :
ORAKARMIC = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = mikeserver)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orakarmic.mikeserver) ) )
You should now be able to connect to the database from the client :
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 13 18:46:37 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Oracle Database 11g Enterprise Edition Release 220.127.116.11.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
I seem to remember someone mentioning beer.