As Oracle have now bought out Sun I thought it might be a good time to look at running an oracle database on linux. Especially as Sun have MySQL in their portfolio and that is one of if not the major database currently running on most linux systems.Now lucklily Oracle allow you to pull down a demo version and have a play. So I did. And what follows is the traps and pitfalls I found along the way.
Now before I start I have to say I broke a few rules by installing this on Centos 5.3 instead of RedHat or any of the approved operating systems. But to be honest, I did not have a single problem with the OS. A lot of the issues are really to do with the linux environment unless all the tricks and traps are done then something will break lol
So firstly register with oracle and pull down the database software. Due to me mucking about I ended up pulling down 10 and 11g versions. This document will be around the 10 version.
Once pulled down you have to ensure a few things are done on your system. Firstly ensure that the following RPM’s are installed
libaio-devel elfutils-devel sysstat compat-libstdc++ unixodbc unixodbc-devel
Then you have to modify the /etc/sysctl.conf file. The additions/modifiations I had to make were the following
net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 262144 net.ipv4.ip_local_port_range = 1024 65000 kernel.sem = 250 32000 100 128
If you add these lines and then use the ‘sysctl -p’ command to load them, failing any typos it will be fine.
Next you need to create a user accounts and groups for the database, this will make it easier for you in the future. For this i created an oracle user and a dba and oinstall groups.
These are easy to add using the following commands
groupadd oinstall groupadd dba useradd -m -g oinstall -G dba oracle passwd oracle
That is the installation account ready then ( as oracle will not let you install as root ).
Next create some directories for oracle. For this I just created a top level folder called oracle.
Again , easy to do with the following commands :
mkdir -p /oracle chown -R oracle:oinstall /oracle chmod -R 775 /oracle
Now oracle advise setting limits for the number of processes and open files for each account. This is done by adding the following lines to /etc/security/limits.conf just before the “# End of file” marker.
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
And also add the following for PAM security in “/etc/pam.d/login”
session required /lib/security/pam_limits.so
Ok now for the first gotcha I came across. In order to install oracle your system MUST have a fixed IP address. I couldn’t for the life of me get it working on DHCP. ONce you have your fixed IP done check to ensure your /etc/hosts file has your IP defined. If it hasn’t then oracle won’t install.
Just one simple line can muck up a whole installation, grrrrr.
Right you’ll be glad thats all the system tuning done. If you want to you can reboot here to ensure everything is set, but it should be all ok.
Now log into the oracle account you just created and unzip the oracle installation kit into it. ( Linux does have the unzip command so don’t worry it’s a zip file you got for the linux installation).
Start the Oracle Universal Installer.
$ ./runInstaller
1. Select Installation Method
* Select Basic Installation
* Oracle Home Location: /oracle/product/10.2.0/db_1
* Installation Type: Enterprise Edition (1.3GB)
* UNIX DBA Group: oinstall
* Make sure Create Starter Database is checked
* Global Database Name: demo1
* Enter the Database Password and Confirm Password
* Click on Next
2. Specify Inventory Directory and Credentials
* Inventory Directory: /oracle/oraInventory
* Operating System group name: oinstall
* Click on Next
3. Product-specific Prerequisite Checks
* If you’ve been following the steps in this guide, all the checks should pass without difficulty. If one or more checks fail, correct the problem before proceeding.
* Click on Next
4. Summary
* A summary of the products being installed is presented.
* Click on Install.
5. Configuration Assistants
* The Oracle Net, Oracle Database, and iSQL*Plus configuration assistants will run automatically
6. Execute Configuration Scripts
* At the end of the installation, a pop up window will appear indicating scripts that need to be run as root. Login as root and run the indicated scripts.
* Click on OK when finished.
7. End of Installation
* Make note of the URLs presented in the summary, and click on Exit when ready.
8. Congratulations! Your new Oracle Database 10g Release 2 database is up and ready for use.
You should now have an up and running Oracle installation. But, if you reboot the system it won’t be up and running. For some reason they don’t install any automatic startup script ??
The first thing to do is add some environment variables to the oracel user account. This is done by editing the .bashrc file in the account and add the following lines
ORACLE_OWNER=oracle; export ORACLE_OWNER ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1 ORACLE_SID=demo1 PATH=$PATH:$ORACLE_HOME/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME/network/lib export PATH ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH
So I surfed around and eventually came across a simple script I built up. This is my finished script that is located in /etc/rc.d/init.d/oracle
#!/bin/bash # # Run-level Startup script for the Oracle Instance and Listener # # chkconfig: 345 91 19 # description: Startup/Shutdown Oracle listener and instance ORA_HOME=”/oracle/product/10.2.0/db_1″ ORA_OWNR=”oracle” # if the executables do not exist — display error if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ] then echo “Oracle startup: cannot start” exit 1 fi # depending on parameter — startup, shutdown, restart # of the instance and listener or usage display case “$1” in start) # Oracle listener and instance startup echo -n “Starting Oracle: “ su – $ORA_OWNR -c “$ORA_HOME/bin/lsnrctl start” su – $ORA_OWNR -c “$ORA_HOME/bin/dbstart” su – $ORA_OWNR -c “emctl start dbconsole” su – $ORA_OWNR -c “isqlplusctl start” touch /var/lock/subsys/oracle echo “OK” ;; stop) # Oracle listener and instance shutdown echo -n “Shutdown Oracle: “ su – $ORA_OWNR -c “isqlplusctl stop” su – $ORA_OWNR -c “emctl stop dbconsole” su – $ORA_OWNR -c “$ORA_HOME/bin/lsnrctl stop” su – $ORA_OWNR -c $ORA_HOME/bin/dbshut rm -f /var/lock/subsys/oracle echo “OK” ;; reload|restart) $0 stop $0 start ;; *) echo “Usage: $0 start|stop|restart|reload” exit 1 esac exit 0
There was one last gotcha that I came across, something that is left over from Oracle themselves.
During the startup of the database it comes back with the following error
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
If you edit the file “/oracle/product/10.2.0/db_1/bin/dbstart” and look for the line containing that text and change it to the location for your oracel database. In my case it is “/oracle/product/10.2.0/db_1”.
Problems and my solutions.
When the “lsnrctl start” command is sent you get a the following errors
# /app/oracle/oracle/product/10.2.0/db_1/bin/lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 – Production on 19-APR-2008 22:24:04
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Message 1070 not found; No message file for product=network, facility=TNSTNS-12545: Message 12545 not found; No message file for product=network, facility=TNS
TNS-12560: Message 12560 not found; No message file for product=network, facility=TNS
TNS-00515: Message 515 not found; No message file for product=network, facility=TNS
Linux Error: 2: No such file or directory
This is because the oracle user account does not have “$ORACLE_HOME/network/lib” in its LD_LIBRARY_PATH. Check the modifications in .bashrc.
When you execute ./runInstaller and it shows an error on the first line of checks and then gives messages about DHCP, check the hostname and ip is defined in /etc/hosts.