Changes between Version 16 and Version 17 of OracleTestSetup


Ignore:
Timestamp:
Aug 23, 2011, 5:29:39 AM (13 years ago)
Author:
Aymeric Augustin
Comment:

Added instructions for version 11g

Legend:

Unmodified
Added
Removed
Modified
  • OracleTestSetup

    v16 v17  
    55==============================
    66
    7 This document attempts to ease the task of running Django's (or your own app's) test
    8 suite against Oracle by:
     7This document attempts to ease the task of running Django's (or your own app's) test suite against Oracle by:
    98
    109* Providing a step by step setup guide to achieve that.
    11 * Hopefully collecting information (best practices, tuning tips) to do that
    12   as efficiently as possible.
     10* Hopefully collecting information (best practices, tuning tips) to do that as efficiently as possible.
    1311
    1412Contributions from seasoned Oracle users are welcome!
     
    1614Chosen components are:
    1715
    18 * Oracle XE 10g. This is a free version of Oracle targeted at developers.
    19 * GNU/Debian Linux x86 — not amd64, because there's no 64bit free version of Oracle (XE). Things should also work with Ubuntu Linux without too much tweaking.
    20 
    21 The system isn't going to be dedicated exclusively to run Oracle so we will
    22 leave things set up so it is necessary to start it manually before a test-debug
    23 session.
    24 
    25 Obtain and install Oracle XE
     16* Oracle XE. This is a free version of Oracle targeted at developers.
     17* Debian GNU/Linux or Ubuntu.
     18
     19Oracle provides 32 bit binaries of Oracle 10g and 64 bit binaries of Oracle 11g. If you're using an x86 kernel, you have to install Oracle 10g, and Oracle 11g if you're using an amd64 kernel. There are no other free versions available. The 64 bit version is currently in beta and only available as a RPM packages; this document describes how to convert them to Debian packages.
     20
     21This procedure was tested with Debian 6 i686 + Oracle 10g, and with Ubuntu 11.04 x86_64 + Oracle 11g. There were no difference between Debian and Ubuntu.
     22
     23In case the system isn't going to be dedicated exclusively to run Oracle, we will describe how to set things up so it doesn't start automatically. In this case, it will be necessary to start it manually before a test-debug session.
     24
     25How to install Oracle XE 10g
    2626============================
     27
     28As explained in the introduction, this will only work on a 32 bit distro.
    2729
    2830We will be roughly following the `Oracle installation documentation`_.
     
    137139.. _here: http://oss.oracle.com/debian/dists/unstable/non-free/binary-i386/
    138140
     141How to install Oracle XE 11g
     142============================
     143
     144As explained in the introduction, this will only work on a 64 bit distro.
     145
     146This is a simplified version of the installation procedure described at:
     147http://forums.oracle.com/forums/thread.jspa?threadID=2227554
     148
     149The procedure is very similar to Oracle 10g, we focus on the differences, please read the previous section for more information.
     150
     151#. Create a Debian / Ubuntu package.
     152
     153   This can be done on another machine, you just need the resulting files, ``oracle-xe_11.2.0-1.5_amd64.deb`` and ``oracle-instantclient11.2-basiclite_11.2.0.2.0-2_amd64.deb``.
     154
     155   Download Oracle XE and Oracle InstantClient for Red Hat from Oracle's website. Oracle XE is delivered as a zip file that contains the RPM file we will use.
     156
     157   You need to have an *Oracle Developer Network* account and to accept the license agreement. (free but registration required).
     158
     159   Run these commands::
     160
     161    $ sudo apt-get install alien
     162    $ alien --scripts oracle-xe-11.2.0-0.5.x86_64.rpm
     163    $ alien --scripts oracle-instantclient11.2-basiclite-11.2.0.2.0.x86_64.rpm
     164
     165
     166#. Install dependencies
     167
     168   Run this command::
     169
     170    $ sudo apt-get install bc libaio1
     171
     172   The RPM contains install scripts that use ``chkconfig`` to add Oracle to the services started at boot. Debian and Ubuntu use ``update-rc.d``. In order to avoid modifying the install scripts, we create a fake ``chkconfig``. Create a file called ``/sbin/chkconfig`` with this content::
     173
     174
     175    #!/bin/sh
     176    if [ "$1" = '--add' ]; then
     177        update-rc.d "$2" defaults
     178    elif [ "$1" = '--del' ]; then
     179        update-rc.d -f "$2" remove
     180    fi
     181
     182   Make it executable::
     183
     184   $ sudo chmod +x /sbin/chkconfig
     185
     186   With this hack, there's a harmless warning during installation because the init script isn't tailored for Debian / Ubuntu::
     187
     188    update-rc.d: warning: /etc/init.d/oracle-xe missing LSB information
     189    update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
     190
     191#. Install the package you generated::
     192
     193    $ sudo dpkg -i oracle-xe_11.2.0-1.5_amd64.deb
     194
     195#. Configure the DB engine::
     196
     197    $ sudo /etc/init.d/oracle-xe configure
     198
     199#. Make sure the Oracle environment vars needed by its client libraries are set at least for the Oracle user::
     200
     201    $ sudo su oracle
     202    $ echo '. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh' >> ~/.bashrc
     203    $ exit
     204
     205#. Remove the fake ``chkconfig`` script::
     206
     207    $ sudo rm /sbin/chkconfig
     208
     209#. Test the server::
     210
     211    $ sudo su oracle
     212    $ sqlplus / as sysdba
     213    SQL> quit
     214    $ exit
     215
     216   APEX is reachable at http://localhost:8080/ but I can't figure out how to login.
     217   Since we don't need it for the purposes of running Django's test suite, we disable it::
     218
     219    SQL> EXEC DBMS_XDB.SETHTTPPORT(0);
     220    SQL> COMMIT;
     221
     222   If we wanted to enable it again::
     223
     224    SQL> EXEC DBMS_XDB.SETHTTPPORT(8080);
     225    SQL> COMMIT;
     226
     227#. Create a user and give the needed privileges::
     228
     229    $ sudo su oracle
     230    $ sqlplus / as sysdba
     231    SQL> CREATE USER djangotest IDENTIFIED BY djangotest;
     232    SQL> GRANT DBA TO djangotest;
     233    SQL> quit
     234    $ exit
     235
     236
     237#. Install the client libraries
     238
     239   This is necessary to compile ``cx_Oracle``::
     240
     241    # dpkg -i oracle-instantclient11.2-basiclite_11.2.0.2.0-2_amd64.deb
     242
     243   Since the libraries are installed in a non-standard directory, declare it::
     244
     245    # echo /usr/lib/oracle/11.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf
     246    # ldconfig
     247
     248
     249Uninstall Oracle 11g
     250====================
     251
     252To uninstall the server::
     253
     254    # /etc/init.d/oracle-xe stop
     255    # dpkg -P oracle-xe
     256
     257The ``prerm`` script doesn't work on Debian / Ubuntu; here's how to clean up your system entirely::
     258
     259    # rm -r /u01
     260    # update-rc.d oracle-xe remove
     261    # rm /etc/default/oracle-xe /etc/oratab /var/lib/update-rc.d/oracle-xe
     262    # rm -r /etc/kde/xdg/menus/OracleXE
     263    # rmdir -p /etc/kde/xdg/menus
     264
     265To uninstall the client::
     266
     267    # dpkg -P oracle-instantclient11.2-basiclite
     268    # rm /etc/ld.so.conf.d/oracle-instantclient.conf
     269    # ldconfig
     270
     271
    139272Install cx_Oracle
    140273=================
     274
     275Before compiling ``cx_Oracle`` make sure Oracle's environment variables are set (``. path/to/oracle_env.sh``, the path depends on the version you intalled). You need Python's headers too.
     276
    141277Do this in the system where you will run your tests::
    142278
    143279    $ sudo apt-get install python-dev
    144 
    145 ::
    146 
    147280    $ sudo pip install cx_Oracle
    148281
    149 or::
    150 
    151     $ sudo easy_install cx_Oracle
    152 
    153 etc.
     282To test the installation (as usual, you need the environment variables)::
     283
     284    $ python
     285    >>> import cx_Oracle
    154286
    155287Create the Django settings file
     
    247379
    248380.. _relevant Oracle documentation: http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/intro.htm#i60798
    249 
    250 Notes
    251 =====
    252 
    253 In my particular case I implemented this setup by using a KVM virtual machine
    254 (host system is a workstation running Debian unstable *Sid*). The VM got:
    255 
    256 * One CPU (Oracle XE won't use any additional CPU).
    257 * 512 MiB of RAM (initially it was 1GiB but the Django test suite execution doesn't push memory usage above that at all).
    258 * 30 GiB hard disk.
    259 
    260 Platform is GNU/Debian Linux 5.0 aka *Lenny* because it still is in
    261 its support period. As a bonus it includes Python 2.4 in pre-packaged form.
    262 
    263 Things to review:
    264 
    265 * How much does the Oracle installation pollutes the system?. If it result to be confined and easy to undo/cleanup, maybe this setup doesn't need to be done inside a VM.
    266381}}}
Back to Top