Installing Oracle 10g on Debian
This guide is to help with installing Oracle 10g on Debian "stable" (currently Sarge) on the x86 architecture.
If you are new to Debian and came to this page from
OTN, then you may prefer to have a read
through my
Debian guide first.
Create the Database Administrator group
The first step in installing oracle is to create a
dba group. Members of this group will have full administrative
access to the oracle environment and to the database:
/usr/sbin/groupadd -g 55 dba
Add your login username to this group:
/usr/sbin/usermod -G dba username
Environment
Set your environment for the oracle install, for example by adding a small
function to your
$ORACLE_HOME/.bashrc file to set the required variables:
go_10g()
{
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1
export ORACLE_SID=orcl
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
}
Be sure you don't include a trailing slash on your
ORACLE_HOME environment variable, as the client oracle
process needs to find the shared memory segment by using the very same
ORACLE_HOME and
ORACLE_SID settings
as are used when starting up the database instance. Any mismatch will result in the client connecting to
what's known as an "idle instance".
If you see the following message when you type
sqlplus / as sysdba then be sure to double-check
your
ORACLE_HOME and
ORACLE_SID settings as well as using the commands
ipcs and
ps -ef|grep ora_ to
check if the oracle "instance" is actually running.
Connected to an idle instance.
Consult the Oracle Guide
A very detailed guide to installing oracle is maintained by
Werner Puschitz. Even though his focus is on Red Hat, his
oracle installation guide is mostly relevant to Debian.
Jeffrey Hunter maintains
guides to setting up inexpensive cluster configurations. Here, I'll only mention some additional details needed for Debian.
Please also study the
guide written by Graham Williams,
it is specific to Debian and contains many things I missed including here. Another guide excellent Debian guide
maintained by Zlatko Calusic is
here. For Ubuntu 7.04 Feisty Fawn
this forum post is useful.
The build of the Oracle software can be found by starting
here,
and clicking on the link called
Oracle Database 10g Release 1 (10.1.0.3) for Linux x86
which brings up a license page, beyond which lies the download link for the file
ship.db.lnx32.cpio.gz as
well as a link to the
installation guide.
Creating a Convenient Install CD-ROM
It's indeed puzzling that the files are provided as a gzipped cpio archive, but at least it is quite
straightforward to create an ISO image, as all the filenames and directory names used fall within the Joliet
specifications. To extract the downloaded archive, use:
mkdir ora_10.1.0.3.0_x86 && cd $HOME/ora_10.1.0.3.0_x86
zcat $HOME/ship.db.lnx32.cpio.gz|cpio -idmv
If you have sufficient disk space, you can of course launch the installation using the
files extracted to
$HOME/ora_10.1.0.3.0_x86 in this way from the archive.
To instead create an ISO CD-ROM image suitable for burning to a CD-R, use the following:
mkisofs -r -J -o $HOME/cdimages/ora_10.1.0.3.0_x86.iso $HOME/ora_10.1.0.3.0_x86/Disk1
Preparing to Launch the Installer
As root, increase the maximum size of a contiguous shared memory segment to 170MB. Around
512MB of physical memory is needed to get an oracle install of 10g done in a timely fashion,
although it will work with as little as 256MB as long as sufficient swap space is available.
Also, create a symbolic link so that
basename can be invoked with the command
/bin/basename, since
the oracle installer script
$ORACLE_HOME/bin/genagtsh uses this, which doesn't exist on Debian, which
causes some linking problems during the install.
(cd /proc/sys/kernel; echo "178257920" > shmmax)
ln -s /usr/bin/basename /bin/basename
Launch the Installer
Here, I am assuming the CD has been written, and has been mounted on
/media/cdrom.
To launch the installer, the workaround flag
-ignoreSysPrereqs is needed, as follows:
mount /media/cdrom
(cd $HOME && /media/cdrom/runInstaller -ignoreSysPrereqs)
Wait for the Oracle Universal Installer graphical screen to appear, and follow
the usual steps in the
installation guide.
If you are logged into the graphical desktop as a different user to the one you are using for the oracle installation,
the command
sux - username is useful to preserve the
DISPLAY settings (which are needed for the oracle installer).
Another approach (convenient for remote installation) is to use
ssh -X username@hostname to forward the X11 connections
back to your graphical desktop (security is a concern, though, when using X11 forwarding, and many distributions disable
it by default).
Handling the Expected Problems
When installing 10gR1 patchset 1 (10.1.0.3.0) on Debian, there may be a problem
relinking both
hsodbc and
extproc agents. During the install, click
"Continue" to get past these problems. Later, you may need to go back and relink
the executables
hsodbc and
extproc manually. Normally, this is done by
the following steps:
cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk client_sharedlib
make -f ins_rdbms.mk ihsodbc
make -f ins_rdbms.mk iextproc
Before running the above steps, make sure that the script
$ORACLE_HOME/bin/genagtsh will be
able to find
basename. On Debian,
basename is found in
/usr/bin/basename, but the oracle script
$ORACLE_HOME/bin/genagtsh has been hardcoded to use
/bin/basename. Either change the script,
or create a symbolic link as follows:
ln -s /usr/bin/basename /bin/basename
Unlock Accounts
Once the installation is complete, the installer should have created a sample
database, and started up some services. Towards the end of the database
installation, you will be given the opportunity to take advantage of the GUI
interface to unlock a few demo accounts (
scott,
hr,
sh,
oe).
Life as a GUI-dba
After a successful installation, the database should be up and running,
and the Enterprise Manager
dbconsole should also be running.
If
dbconsole isn't running, start it up using:
emctl start dbconsole
If the Enterprise Manager
dbconsole doesn't start, please inspect the
EMD_URL
entry in the following file, to check it is valid:
$ORACLE_HOME/`hostname -f`_$ORACLE_SID/sysman/config/emd.properties
It should look something like this:
EMD_URL=http://localhost.localdomain:1830/emd/main
Once dbconsole has started, connect to it using the Mozilla browser at
the following URL:
http://localhost:5500/em
Pretty much all the routine database administration tasks, and many
performance tuning tasks can be done via this
dbconsole browser interface,
without ever going back to the command line. Enjoy life as a GUI-DBA
Database bindings for Python
Feeling a little queasy about using
sqlplus to develop your SQL statements?
Why not use a real programming language like Python to access your newly-installed
database in a more object-oriented way?
Matthew T. Kromer at Zope Corporation built what is known as a database binding
for Python, and gave it the name DCOracle2. It can be found on the
Python Database Modules page,
and the source code can be checked out from CVS using:
cvs -z7 -d ':pserver:anonymous@cvs.zope.org:/cvs-repository' checkout Products/DCOracle2
or if you are behind a http proxy, as follows:
cvs -z7 -d ':pserver;proxy=your-proxy.your-domain;proxyport=80:anonymous@cvs.zope.org:/cvs-repository' checkout Products/DCOracle2
After making sure the environment variable
ORACLE_HOME is set, and that you have the
python-dev package
installed, build
DCoracle2 as follows:
cd Products/DCOracle2
python setup.py install
This will give a compile error (shown below). All this is saying is that
(dword *) is undeclared
in the source file
src/dco2.c. It's easy to fix by just editing
src/dco2.c and changing the three
occurrences of
(dword *) into
(dvoid *), and then re-issuing the build command.
src/dco2.c:3393: error: `dword' undeclared (first use in this function)
src/dco2.c:3393: error: (Each undeclared identifier is reported only once
src/dco2.c:3393: error: for each function it appears in.)
src/dco2.c:3393: error: parse error before ')' token
src/dco2.c:3395: error: parse error before ')' token
src/dco2.c:3412: error: parse error before ')' token
Note: you need to be root for python to be able to install the database binding lubrary
dco2.so into
/usr/lib/python2.3/site-packages, so re-issuing the build command as root may be the most convenient way
to get things set up.
To test if your newly built
DCOracle2 database binding works with your Oracle 10gR1 installation,
start up the database and create the
scott user with the password
tiger, e.g. as follows:
grant connect, resource to scott identified by tiger;
alter user scott account unlock;
Then load the example files
scott.sql
and
procdef.sql from the DCOracle2 download "test" directory as follows:
@Products/DCOracle2/test/scott.sql
@Products/DCOracle2/test/procdef.sql
Now try things out in python:
python
>>> import DCOracle2
>>> db = DCOracle2.connect('scott/tiger')
>>> c = db.cursor()
>>> c.execute('select * from emp where empno=7902')
1
>>> print c.fetchall()
[[7902, 'FORD', 'ANALYST', 7566, OracleDate("1981-12-03 00:00:00"), 3000.0, None, 20]]
>>> find = c.procedure.scott.emp_actions.find
>>> print find.__doc__
function SCOTT.EMP_ACTIONS.FIND returns OUT VARCHAR2, has arguments:
EMPID IN NUMBER
>>> print find(7902)
FORD
Back to
LinuxHints - Everything GNU ever wanted to know about Linux
--
PeterKnaggs - 27 Sep 2005
to top