安装按以下步骤
Installing Oracle 11g R2 Express Edition on Ubuntu 64-bit
Recently I installed Oracle 11g R2 Express Edition on my ubuntu 12.04 ( Precise Pangolin). But for this, I have to google a lot and had to install two times to get a fully working environment. So, I thought it would be better if I share my experience with my fellow ubuntu'ers so that they don't have to face the troubles that I encountered. I have came up with following series of steps ( mostly derived from the link source I given at the end of this post ) for easy and hassle-free installation.
But at first, I must inform you about the limitations of Oracle 11g R2 Express Edition (XE) which are as follows :
- The Installer released by Oracle is only meant for 64-bit (x86_64) systems. If you wish to install the 32-bit version , seeinstalling oracle xe on ubuntu 32-bit
- It will consume, at most, processing resources equivalent to one CPU.
- Only one installation of Oracle Database XE can be performed on a single computer.
- The maximum amount of user data in an Oracle Database XE database cannot exceed 11 GB.
- The maximum amount of RAM that Oracle XE uses cannot exceed 1 GB, even if more is available.
Now the steps for Installation :
1)Download the Oracle 11gR2 express edition installer from the link given below:
(You will need to create a free oracle web account if you don'talready have it )
2)Unzip it :
unziporacle-xe-11.2.0-1.0.x86_64.rpm.zip
3)Install the following packages :
sudoapt-get install alien libaio1 unixodbc vim
4)Convert the red-hat ( rpm ) package to Ubuntu-package :
sudoalien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm
(Note:this may take a while , till that time you can go for step 5 )
5)Do the following pre-requisite things:
a)Create a specialchkconfig
script:
TheRed Hat based installer of Oracle XE 11gR2 relies on
/sbin/chkconfig
,which is not used in Ubuntu. The
chkconfig
package available for the current version of Ubuntu produces errorsand my not be safe to use. Below is a simple trick to get around theproblem and install Oracle XE successfully:
sudovim /sbin/chkconfig
(copyand paste the following into the 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.doracle-xe defaults 80 01
(copyand paste the following into the 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.doracle-xe defaults 80 01
Save the above file and provideappropriate execute privilege :
chmod755 /sbin/chkconfig
b)Set the Kernel parameters :
Oracle11gR2 XE requires to set the following additional kernel parameters:
sudovim /etc/sysctl.d/60-oracle.conf
(Enterthe following)
#Oracle 11g XE kernel parameters
fs.file-max=6815744
net.ipv4.ip_local_port_range=900065000
kernel.sem=25032000 100 128
kernel.shmmax=536870912
(Savethe file)
Note:
kernel.shmmax= max possible value , e.g. size of physical RAM ( in bytes e.g.512MB RAM == 512*1024*1024 == 536870912 bytes )
Verifythe change :
sudocat /etc/sysctl.d/60-oracle.conf
Load
new
kernelparameters:
sudoservice procps start
Verify:
sudosysctl -qfs.file-max
->fs.file-max = 6815744
c)Increase the system swap space :
Analyzeyour current swap space by following command :
free-m
Minimumswap space requirement of Oracle 11gR2 XE is 2 GB . In case, your islesser , you can increase it by following steps in my one of previous post .
d)make some more required changes :
i)
ln-s /usr/bin/awk /bin/awk
ii)
mkdir/var/lock/subsys
iii)
touch/var/lock/subsys/listener
6)N
owyou are ready to install Oracle 11gR2 XE. Go to the directory whereyou created the ubuntu package file in Step 4 and enter followingcommands in terminal :
i)
sudodpkg --install oracle-xe_11.2.0-2_amd64.deb
Update :Before you proceed to next step , do have a look at this trouble-shooting post in order to avoid MEMORY TARGET or any other "shared memory"
error.
ii) sudo/etc/init.d/oracle-xe configure
ii) sudo/etc/init.d/oracle-xe configure
Enterthe following configuration information:
- Avalid HTTP port for the Oracle Application Express (the default is8080)
- Avalid port for the Oracle database listener (the default is 1521)
- Apassword for the SYS and SYSTEM administrative user accounts
- Confirmpassword for SYS and SYSTEM administrative user accounts
- Whetheryou want the database to start automatically when the computer starts(next reboot).
7)Before you start using Oracle 11gR2 XE you have to set-up more things:
a)Set-up the environmental variables :
Addfollowing lines to your
.bashrc
:
exportORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
exportORACLE_SID=XE
exportNLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
exportORACLE_BASE=/u01/app/oracle
exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
exportPATH=$ORACLE_HOME/bin:$PATH
exportORACLE_SID=XE
exportNLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
exportORACLE_BASE=/u01/app/oracle
exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
exportPATH=$ORACLE_HOME/bin:$PATH
b)execute your .profile to load the changes:
../.profile
8)Start the Oracle 11gR2 XE :
sudoservice oracle-xe start
Theoutput should be similar to following :
user@machine:~$sudo service oracle-xe start
StartingOracle Net Listener.
StartingOracle Database 11g Express Edition instance.
user@machine:~$
StartingOracle Net Listener.
StartingOracle Database 11g Express Edition instance.
user@machine:~$
8)
Createyour user
:
a)start sqlplus and login as sys
:
sqlplussys as sysdba
(provide the password you gave while configuring the oracle in Step 6(ii) ).
Thisshould come to following :
SQL*Plus:Release 11.2.0.2.0 Production on Wed May 9 12:12:16 2012
Copyright(c) 1982, 2011, Oracle. All rights reserved.
Enterpassword:
Connectedto:
OracleDatabase 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>
b)Enter following on the sql prompt : Replaceusername andpassword by your desired ones.
SQL>create user username identified by password;
Usercreated.
SQL>grant connect,resource to username;
Grantsucceeded.
9) Now as you have created the user , you can login to it :
user@machine:~$sqlplus
SQL*Plus:Release 11.2.0.2.0 Production on Wed May 9 12:28:48 2012
Copyright(c) 1982, 2011, Oracle. All rights reserved.
Enteruser-name: temp
Enterpassword:
Connectedto:
OracleDatabase 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>select 2+2 from dual;
2+2
----------
4
当启动oracle configuration时可能会遇到如下问题
ORA-00845: MEMORY_TARGET not supported on this system
这是可能是由/dev/shm没有被分配内存引起的。
解决方案:
ORA-00845: MEMORY_TARGET not supported on this system
这是可能是由/dev/shm没有被分配内存引起的。
解决方案:
nano /etc/init.d/oracle-shm
add text
#! /bin/sh
# /etc/init.d/oracle-shm
#
case "$1" in
start)
echo "Starting script /etc/init.d/oracle-shm"
# Run only once at system startup
if [ -e /dev/shm/.oracle-shm ]; then
echo "/dev/shm is already mounted, nothing to do"
else
rm -f /dev/shm
mkdir /dev/shm
mount --move /run/shm /dev/shm
mount -B /dev/shm /run/shm
touch /dev/shm/.oracle-shm
fi
;;
stop)
echo "Stopping script /etc/init.d/oracle-shm"
echo "Nothing to do"
;;
*)
echo "Usage: /etc/init.d/oracle-shm {start|stop}"
exit 1
;;
esac
#
### BEGIN INIT INFO
# Provides: oracle-shm
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Bind /run/shm to /dev/shm at system startup.
# Description: Fix to allow Oracle 11g use AMM.
### END INIT INFO
make the file executable
chmod 755 /etc/init.d/oracle-shm
/etc/init.d/oracle-shm start
At this stage reboot, then check
df -kh /dev/shm