8) Installing Oracle 11gR2 Express Edition
The final release version of Oracle 11gR2 Express Edition can be downloaded for free at http://otn.oracle.com/database/express-edition/downloads. The software should automatically downloaded into the "Downloads" folder of your home directory.
Enter the following commands to unpack the installer:
cd ~/Downloads
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
rm oracle-xe-11.2.0-1.0.x86_64.rpm.zip
The Debian Linux based package management of Ubuntu is not compatible with the Red Hat package manager. The Oracle installer needs to be converted using the following commands:
cd ~/Downloads/Disk1
sudo alien --to-deb --scripts oracle-xe-11.2.0-1.0.x86_64.rpm
(This may take a few minutes)
rm oracle-xe-11.2.0-1.0.x86_64.rpm
The following needs to be set for compatibility:
sudo ln -s /usr/bin/awk /bin/awk
sudo mkdir /var/lock/subsys
Ubuntu uses different tools to manage services and system startup scripts. The "chkconfig" tool required by the Oracle installer is not available in Ubuntu. The following will create a file to simulate the "chkconfig" tool.
Login as root:
sudo su -
Copy & paste the following directly into the command prompt to create a file:
cat > /sbin/chkconfig <<-EOF
!/bin/bash
Oracle 11gR2 XE installer chkconfig hack for Debian based Linux (by dude)
Only run once.
echo "Simulating /sbin/chkconfig..."
if [[ ! `tail -n1 /etc/init.d/oracle-xe | grep INIT` ]]; then
cat >> /etc/init.d/oracle-xe <<-EOM
#
BEGIN INIT INFO
Provides: OracleXE
Required-Start: \\$remote_fs \\$syslog
Required-Stop: \\$remote_fs \\$syslog
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: Oracle 11g Express Edition
END INIT INFO
EOM
fi
update-rc.d oracle-xe defaults 80 01
EOF
Exit root:
exit
Set execute privileges:
sudo chmod 755 /sbin/chkconfig
Install Oracle 11gR2 Express Edition entering the following commands:
cd ~/Downloads/Disk1
sudo dpkg --install ./oracle-xe_11.2.0-2_amd64.deb
(This may take a couple of minutes)
Run the configuration script to create (clone) the database and follow the screen. Accept the default answers, including "y" to startup the database automatically, or modify as required.
sudo /etc/init.d/oracle-xe configure
(This can take a few minutes - the installation completed successfully.)
To verify success, the procedure should end showing:
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
Set a password for the Oracle account:
sudo passwd oracle
9) Post-Installation
In order to use sqlplus and other tools, the Oracle account requires specific environment variables. The following will set these variables automatically at every Oracle login:
Login as the Oracle user:
su - oracle
Copy the default account skeleton files and add the Oracle env script to .profile:
cp /etc/skel/.bash_logout ./
cp /etc/skel/.bashrc ./
cp /etc/skel/.profile ./
echo "" >>./.profile
echo '. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh' >>./.profile
By default, the Oracle Database XE graphical user interface is only available at the local server, but not remotely. The following will enable remote logins:
Login as the Oracle user:
su - oracle
Login as SYSDBA and execute the following:
sqlplus / as sysdba
SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit
See http://download.oracle.com/docs/cd/E17781_01/admin.112/e18585/toc.htm for more information.
a) Unity desktop configurations
The Oracle XE menu under the previous Gnome Classic desktop shows several useful scripts to backup the database, start and stop the database, etc. Under the Unity based desktop this menu is not available. You can either switch to the Gnome Classic desktop as outlined in chapter 2, or perform the following steps to modify and copy the scripts as outlined below. The start and stop database scripts will also be modified to perform a progress feedback.
Login as user root:
sudo su -
Convert desktop files:
cd /usr/share/applications
sed -i 's/Categories./Categories=Database;Office;Development;/g' oraclexe
sed -i 's/MultipleArgs/X-MultipleArgs/g' oraclexe*
sed -i 's/MimeType./MimeType=application/x-database/g' oraclexe
sed -i 's/.png//g' oraclexe*
sed -i 's/Terminal=false/Terminal=true/g' oraclexe-startdb.desktop
sed -i 's/Terminal=false/Terminal=true/g' oraclexe-stopdb.desktop
Exit root:
exit
Login as user Oracle:
su - oracle
Modify database start and stop scripts:
cd /u01/app/oracle/product/11.2.0/xe/config/scripts
cp startdb.sh start.sh_orig
cp stopdb.sh stopdb.sh_orig
sed -i 's/>.//g' startdb.sh
sed -i 's/>.//g' stopdb.sh
You will need SYSDBA privileges and set Oracle environment variables in order to use your regular user account.
Login to your regular user account:
su - dude
Enter the folowing command:
sudo usermod -a -G dba dude
Then update your profile to automatically set the necessary Oracle environment variables:
echo "" >>./.profile
echo '. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh' >>./.profile
Update your Desktop folder to contain useful Oracle XE scripts:
cp /usr/share/applications/oraclexe* ~/Desktop
chmod 750 ~/Desktop/oraclexe*
To verify success re-login and try "sqlplus":
su - oracle
sqlplus / as sysdba
b) Backup database
In order to perform an online database backup using the supplied "Backup Database" script, the database needs to run in Archivelog mode. This can be accomplished using the following:
Login as the Oracle user:
su - oracle
Login as SYSDBA and type the following:
sqlplus / as sysdba
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
SQL> exit
10) Troubleshooting
10a) Port 1521 appears to be in use by another application
Error: Port 1521 appears to be in use by another application. Specify a different port.
This error happens after a previously unsuccessful configuration attempt using /etc/init.d/oracle-xe configure script. The script was able to start the Listener process, but most likely failed to continue to clone the database, e.g. ORA-00845. The following should correct the problem:
Determine the oracle listener process that is already running:
$ ps -ef | grep oracle
Your output should be similar to:
oracle 19789 1 0 19:46 ? 00:00:00 /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr
Then kill the process, using the appropriate process id, for instance:
$ sudo kill -9 19789
10b) cannot touch `/var/lock/subsys/listener': No such file or directory
Starting Oracle Net Listener...touch: cannot touch `/var/lock/subsys/listener': No such file or directory
This error occurs when you run /etc/init.d/oracle-xe configure, but failed the preinstallation step to create the /var//lock/subsys directory as outlined in chapter 8.
10c) ORA-00845: MEMORY_TARGET
ORA-00845: MEMORY_TARGET not supported on this system
See chapter 7 to enable /dev/shm and verify free space available in /run/shm
10d) Apex ADMIN password
According to the Oracle documentation, the password for the INTERNAL and ADMIN Oracle Application Express user accounts is initially the same as the SYS and SYSTEM administrative user accounts. Well, I tried several times without success. To reset the Apex Admin password:
Login as user oracle:
su - oracle
Login as SYSDBA and type the following:
sqlplus / as sysdba
At the SQL prompt, type the following to be prompted to change the password:
SQL> @?/apex/apxxepwd.sql
exit
When done, open your browser and go to http://127.0.0.1:8080/apex
Workspace: Internal
Username: ADMIN
Password: password you set with apxxepwd.sql
I will prompt you to reset the password:
old password: password you set with apxxepwd.sql
new password: final_password
You can also login as the Apex Admin using http://127.0.0.1:8080/apex/apex_admin
10e) SYS and SYSTEM password
Use the following commands to reset the SYS and SYSTEM passwords if necessary:
Login as the Oracle user:
su - oracle
Login as SYSDBA and type the following at the SQL prompt:
sqlplus / as sysdba
SQL> alter user sys identified by "password" account unlock;
SQL> alter user system identified by "password" account unlock;
SQL> exit
10f) Uninstall Oracle 11g XE
The following will completely uninstall and remove Oracle 11g XE:
Open a terminal seesion and login as user root:
sudo su -
Enter the following:
/etc/init.d/oracle-xe stop
dpkg --purge oracle-xe
rm -r /u01/app
rm /etc/default/oracle-xe
update-rc.d -f oracle-xe remove
update-rc.d -f oracle-mount remove
update-rc.d -f oracle-shm remove
h3. g) Reconfigure Oracle 11g XE\
Type the following commands in a terminal window:
sudo /etc/init.d/oracle-xe stop
sudo rm /etc/default/oracle-xe
sudo /etc/init.d/oracle-xe configure
{code}
11) References
http://download.oracle.com/docs/cd/E17781_01/install.112/e18802/toc.htm
http://askubuntu.com/questions/57297/why-has-var-run-been-migrated-to-run
http://lwn.net/Articles/436012/
https://forums.oracle.com/forums/thread.jspa?threadID=2300750&tstart=0
https://forums.oracle.com/forums/thread.jspa?threadID=2298493