Installing Oracle 10g XE on Linux

Post date: 03-May-2010 06:48:20

Introduction.

Oracle XE (Oracle Express Edition) is basically a fully functional but slightly limited version of the full Oracle 10g database. For the average home user/developer it's a perfect tool where the limitations will not have any real effect. Quoting from the Oracle XE homepage:

Oracle Database 10g Express Edition (Oracle Database XE) is an entry-level, small-footprint database based on the Oracle Database 10g Release 2 code base that's free to develop, deploy, and distribute; fast to download; and simple to administer.

To download the database (or any other software from the Oracle site) you will first have to register and create an Oracle account, this is free and can be done on the Oracle account page.

In this guide I'm using Fedora 7 so the rpm install method is used and the paths relate to a default Fedora installation.

Download the database.

Go to the Oracle XE download site and after accepting the license agreement click on the link 'Oracle Database 10g Release 2 (10.2.0.1.0) for Linux x86' to save the file named 'oracle-xe-10.2.0.1-1.0.i386.rpm' to your computer.

If you are running SELinux in enforcing mode then as root turn this off during the install process.

# /usr/sbin/setenforce 0

cd to the download location and then install the rpm as root:

# rpm -ivh oracle-xe-10.2.0.1-1.0.i386.rpm

After installation is finished follow the instructions displayed in the terminal by running this script.

# /etc/init.d/oracle-xe configure Oracle Database 10g Express Edition Configuration ------------------------------------------------- This will configure on-boot properties of Oracle Database 10g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press <Enter> to accept the defaults. Ctrl-C will abort. Specify the HTTP port that will be used for Oracle Application Express [8080]: Specify a port that will be used for the database listener [1521]: Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration: Confirm the password: Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:n Starting Oracle Net Listener...Done Configuring Database...Done Starting Oracle Database 10g Express Edition Instance...Done Installation Completed Successfully. To access the Database Home Page go to "http://127.0.0.1:8080/apex"

I just press enter to accept the default ports and say 'n' to the option for oracle-xe to turn at startup as it uses a fair bit of system resources and since I use it as a development tool and not a live server I am happy to start it as required. Note that the script also starts oracle-xe.

If you turned off SELinux you can now set enforcing mode again.

# /usr/sbin/setenforce 1

Starting and stopping the server as root.

Once installed you can start oracle-xe by running this command as root:

$ /sbin/service oracle-xe start

and to stop use:

$ /sbin/service oracle-xe stop

Starting as non root user

There are menus created that are supposed to start and stop the database even for non root users, however I have found that although they do start the database they do not start the TNS listener that is required to run if you wish to connect to the database either through the web browser interface or using the ojdbc connector and OpenOffice for example. For this reason I always choose to start the database from the command line as root.

If you start the database as non root you can still connect using the SQL*Plus utility (labelled 'Run SQL Command Line') included in the menus as this does not require the TNS listener to run.

If you wish to do this as non root anyway then first you need to add your chosen user to the dba group, do this either by running system-config-users if you have this installed or from the command line.

Using system-config-users on the users tab select your user, click on properties, then the Groups tab and check the dba group.

To do this from a command line run this command as root replacing username with the chosen user:

# usermod -a -G dba username

Unlocking the sample database account.

First you should read the page located at /usr/lib/oracle/xe/app/oracle/doc/getting_started.htm, this is available in the menu under Oracle Database 10g Express Edition>Get Started. Read sections 1 and 2 to unlock the sample HR account and give this account a password.

Accessing the database from SQL*Plus.

This is a command line interface to the Oracle database, from the menus go to Oracle Database 10g Express Edition>Run SQL Command Line.

On Fedora the program is located at /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/runsqlplus.sh

To connect to the sample database type connect at the prompt and enter the username 'HR' and the password you set up previously.

Accessing the database from a browser.

From the menu go to Oracle Database 10g Express Edition>Go To Database Homepage, this opens the login page located at http://127.0.0.1:8080/apex, simply login in using the unlocked HR account with the password set up in the previous step.

This opens up the database administration pages where you can can add tables, browse data, run SQL queries etc. It's pretty easy to use and uses a lot of Javascript to give it a modern AJAX like feel.

Connecting with OpenOffice

Download the file ojdbc14.jar file from the Oracle JDBC drivers download page. As root move the file into your /opt folder:

$ mv ojdbc14.jar /opt/

Open OpenOffice and select Tools>Options.

Expand the OpenOffice.org option on the left then select Java then click on the 'Class Path' button on the right. Click on 'Add Archive' and browse to the ojdbc14.jar file you just moved into your /opt folder.

Next open OpenOffice Base and when the Database Wizard opens select the bottom option 'Connect to an existing database', from the drop down box select 'Oracle JDBC' (NOT the option that says just 'JDBC') and click next.

On the next page, titled 'Set up a connection to an Oracle database', enter these settings:

  • Name of database - XE

  • Server URL - localhost

  • Port number - 1521

Click on Test Class to make sure that the jdbc driver is loaded OK.

Click next for 'User Authentication', for username enter HR and check the 'Password required' checkbox. Finally you can click on 'Test Connection' and enter your password the check that you can connect to the database.

If all is well just press next and then OK to save the database.