Oracle Install

To learn JDBC, you need to install a relational database on your system. Let's install Oracle 11 XE.

How to install Oracle 11g XE on Windows

Visit the following address, download the Oracle Database 11g Express Edition.1
http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
You must have an account on the Oracle website to download Oracle 11g XE. Windows is the official OS supported by Oracle and easy to install. Run setup.exe and click the Next button to complete the installation.

How to install Oracle 11g XE on Ubuntu

It is difficult to install Oracle on Ubuntu. Ubuntu is not a Linux distribution officially supported by Oracle.2

Download Oracle 11g XE for Linux from the following address:
http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
For 64-bit systems, choose Oracle Database Express Edition 11g Release 2 for Linux x64. When you log in to the site, the download begins. After downloading, go to the directory where the file is located and execute the following command.

unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
sudo apt-get install alien libaio1 unixodbc
cd Disk1
sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm

Create /sbin/chkconfig file with the following command:

sudo nano /sbin/chkconfig

Copy and paste the following into the chkconfig file.

#!/bin/bash
# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
file=/etc/init.d/oracle-xe
if [[ ! `tail -n1 $file | grep INIT` ]]; then
echo >> $file
echo '### BEGIN INIT INFO' >> $file
echo '# Provides: OracleXE' >> $file
echo '# Required-Start: $remote_fs $syslog' >> $file
echo '# Required-Stop: $remote_fs $syslog' >> $file
echo '# Default-Start: 2 3 4 5' >> $file
echo '# Default-Stop: 0 1 6' >> $file
echo '# Short-Description: Oracle 11g Express Edition' >> $file
echo '### END INIT INFO' >> $file
fi
update-rc.d oracle-xe defaults 80 01

Save the above file and grant execute permission.

sudo chmod 755 /sbin/chkconfig

Set the Kernel parameters:
Oracle 11g XE requires to set the following additional kernel parameters:

sudo nano /etc/sysctl.d/60-oracle.conf

Copy and paste the following into 60-oracle.conf file.

# Oracle 11g XE kernel parameters  
fs.file-max=6815744  
net.ipv4.ip_local_port_range=9000 65000  
kernel.sem=250 32000 100 128 
kernel.shmmax=2066743296

The kernel.shmmax value should be set to one-half of the RAM memory installed on the system. You can calculate it as follows.

free -m
             total       used       free     shared    buffers     cached
Mem:          3942       3809        133        947         50       1571
-/+ buffers/cache:       2186       1756
Swap:         4083        378       3705

3942 * 1024 * 1024 * 0.5 = 2066743296

Verify the change:

sudo cat /etc/sysctl.d/60-oracle.conf

Load the kernel parameters:

sudo service procps start

Verify:

sudo sysctl -q fs.file-max

Execute the following:

sudo ln -s /usr/bin/awk /bin/awk
sudo mkdir /var/lock/subsys
sudo touch /var/lock/subsys/listener

Go to the Disk1 directory where the Oracle installation files are located and start the installation with the following command:

sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb
sudo /etc/init.d/oracle-xe configure

On the configuration screen, the port for Oracle Application Express specifies a value other than 8080. This is because WAS like Tomcat uses 8080. (I set it to 8989.)
I will use the default value of 1521 for the listener port.
(Just hit the enter key to select the default.)
Set passwords for administrator accounts SYS and SYSTEM.
Set Oracle autostart to Yes at system boot. (Just hit the enter key)

Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g 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]:8989

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: <Admin Password>
Confirm the password: <Admin Password>

Do you want Oracle Database 11g Express Edition to be started 
on boot (y/n) [y]:

Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.

Set-up the environmental variables
Open .bashrc.

gedit ~/.bashrc

Add following lines to your .bashrc

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH

Execute your .bashrc to load the changes:

source ~/.bashrc

Start the Oracle 11g XE
(You do not need this command after rebooting because you have set Oracle startup to yes at boot time.)

sudo service oracle-xe start

Create a SCOTT account

Start sqlplus and login as sys:

sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on 월 6월 29 12:04:33 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter password: <Admin Password>

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> @/u01/app/oracle/product/11.2.0/xe/rdbms/admin/utlsampl.sql
Comments
  1. For information about Oracle Express Edition (XE) licenses, see:
    http://daust.blogspot.kr/2012/08/clarification-on-oracle-xe-licensing.html
  2. Oracle Enterprise Linux 4 Update 7
    Oracle Enterprise Linux 5 Update 2
    Red Hat Enterprise Linux 4 Update 7
    Red Hat Enterprise Linux 5 Update 2
    SUSE Linux Enterprise Server 10 SP2
    SUSE Linux Enterprise Server 11
References