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 | |
| 19 | Oracle 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 | |
| 21 | This 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 | |
| 23 | In 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 | |
| 25 | How to install Oracle XE 10g |
| 141 | How to install Oracle XE 11g |
| 142 | ============================ |
| 143 | |
| 144 | As explained in the introduction, this will only work on a 64 bit distro. |
| 145 | |
| 146 | This is a simplified version of the installation procedure described at: |
| 147 | http://forums.oracle.com/forums/thread.jspa?threadID=2227554 |
| 148 | |
| 149 | The 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 | |
| 249 | Uninstall Oracle 11g |
| 250 | ==================== |
| 251 | |
| 252 | To uninstall the server:: |
| 253 | |
| 254 | # /etc/init.d/oracle-xe stop |
| 255 | # dpkg -P oracle-xe |
| 256 | |
| 257 | The ``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 | |
| 265 | To 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 | |