ubuntu 13.04 server安装Oracle XE 11G R2手记

By | 2018-11-27

以上是小弟安装的手记,可能会有错漏地方

一、 安装ubuntu 13.04 server 64位版本(最简安装即可),然后安装以下全部附件

#apt-get update
#apt-get dist-upgrade
#apt-get install automake autotools-dev binutils bzip2 doxygen elfutils expat gawk unzip
#apt-get install gcc gcc-multilib g++-multilib ia32-libs ksh less lesstif2 lesstif2-dev
#apt-get install lib32z1 libaio1 libaio-dev libc6-dev libc6-dev-i386 libc6-i386
#apt-get install libelf-dev libltdl-dev libmotif4 libodbcinstq4-1 libodbcinstq4-1:i386
#apt-get install libpth-dev libpthread-stubs0 libpthread-stubs0-dev libstdc++5 zlibc
#apt-get install lsb-cxx make pdksh rlwrap rpm openssh-server
#apt-get install sysstat unixodbc unixodbc-dev x11-utils

二、下载 Oracle XE 11g ,小弟下载存放于 /home 目录下

Download Oracle Database Express Edition 11g R2

三、 开始安装 Oracle

#cd /home
#unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
#cd Disk1
#alien –scripts oracle-xe-11.2.0-1.0.x86_64.rpm

创建 /sbin/chkconfig
#vi /sbin/chkconfig

#!/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

更改可运行权限
#chmod 755 /sbin/chkconfig

创建 /etc/sysctl.d/60-oracle.conf
#vi /etc/sysctl.d/60-oracle.conf

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

启动 procps 服务
#service procps start

#ln -s /usr/bin/awk /bin/awk
#mkdir /var/lock/subsys
#touch /var/lock/subsys/listener
#rm -rf /dev/shm
#mkdir /dev/shm
#mount -t tmpfs shmfs -o size=2048m /dev/shm

创建 /etc/rc2.d/S01shm_load
#vi /etc/rc2.d/S01shm_load

#!/bin/sh
case "$1" in
start) mkdir /var/lock/subsys 2>/dev/null
	   touch /var/lock/subsys/listener
	   rm /dev/shm 2>/dev/null
	   mkdir /dev/shm 2>/dev/null
	   mount -t tmpfs shmfs -o size=2048m /dev/shm ;;
*) echo error
   exit 1 ;;
esac

更改可运行权限
#chmod 755 /etc/rc2.d/S01shm_load

安装Oracle包
#dpkg –install oracle-xe_11.2.0-2_amd64.deb

加环境变量
#vi ~/.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

#source ~/.bashrc

执行 Oracle 配置
#/etc/init.d/oracle-xe configure

--- 以下为删除 oracle ---

sudo -s
/etc/init.d/oracle-xe stop
ps -ef | grep oracle | grep -v grep | awk '{print $2}' | xargs kill
dpkg --purge oracle-xe
rm -r /u01
rm /etc/default/oracle-xe
update-rc.d -f oracle-xe remove

 

——————————————————–
更改服务器的机器名会造成安装不成功,必须要留意以下三点:
1)/etc/hosts 的名称 “127.0.0.1     Oracle_svr”
2)/etc/hostname  一定要对应 “Oracle_svr”
3)/u01/app/oracle/product/11.2.0/xe/network/admin 目录里的 listener.ora 和 tnsnames.ora 里的 ‘host’ 也要对应“Oracle_svr”

 

——————————————————–
如果 listener 报如下错误可解决,先看listener的log文件:
路径: /u01/app/oracle/diag/tnslsnr/xxxxxx/listener/trace/listener.log

启动listener的时候,报错了:

[xxx admin]$ lsnrctl
LSNRCTL for Linux: Version 10.2.0.10.0 – Production on 28-APR-2015 12:13:06
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
Welcome to LSNRCTL, type “help” for information.

LSNRCTL> start
Starting /u01/app/oracle/product/10.2.0/bin/tnslsnr: please wait…

TNSLSNR for Linux: Version 10.2.0.1.0 – Production
System parameter file is /u01/app/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
TNS-12555: TNS:permission denied
TNS-12560: TNS:protocol adapter error
TNS-00525: Insufficient privilege for operation
Linux Error: 1: Operation not permitted

通过日志错误信息可知,应该跟权限有关,最后发现了一个隐藏的信息,
/var/tmp/.oracle这个目录比较特殊,如果oracle没有对此目录的操作权限的话,oracle用户就无法进入/var/tmp/.oracle文件夹.
方法很简单,执行:chmod 777 /var/tmp/.oracle 之后就ok了.

發佈回覆