分类: Oracle
2009-08-27 21:46:21
目录
1.安装前配置: 1
1.1.软件包 1
1.2.用户和组 1
1.2.1.问题 1
1.3.创建目录并设置文件夹权限 2
1.4.修改设置 2
1.4.1.环境变量(只针对Oracle用户) 2
1.4.2.内核参数 3
1.4.3.Swap交换区 4
1.4.4.软连接 4
1.5.针对Ubuntu的RedHat欺骗(可略) 4
2.安装: 4
3.启动 7
3.1.命令行 7
3.1.1.启动数据库 7
3.1.2.启动监听器 7
3.2.web 8
apt-get install gcc make binutils lesstif2 libc6 libc6-dev rpm libmotif3 libaio libstdc++5 alien
缺少必要软件包可能在安装过程报出各种意料之外的错误,如果在安装过程中,控制台出现:“*** not found”字样,则很有可能是由于缺少的软件包所致。
oracle 安装需要两个 unix 用户组和一个运行时的 oracle 用户。
addgroup oinstall
addgroup dba
addgroup nobody
useradd -g oinstall -G dba -p passwd -d /home/oracle -s /bin/bash oracle
usermod -g nobody nobody
此处第四条命令执行后发现了一个问题,创建oracle用户,并指定了其密码为:“passwd”,在su进行切换的时候发现总是提示密码错误。解决办法:先创建用户,然后指定其组和次要组以及所有的目录和登录shell。
创建完用户之后,oracle用户没有root权限,解决步骤如下:
sodu visodu
文件内容(‘……’为忽略内容):
……
root ALL=(ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
#Members of the oracle group may gain root prileges
oracle ALL=(ALL) ALL # 此处即为需要添加的项目
……
Oracle安装在/opt/oracle目录下,先切换至root,然后执行一下命令。
mkdir -p /opt/oracle
mkdir -p /opt/oracle
chown -R oracle:oinstall /opt/ora*
chmod -R 775 /opt/ora*
修改设置包含所有的需要修改或者重新设置的项目。
切换到oracle用户,进入其所属目录,添加.bashrc,.bash_profile两个文件(注意:如果存在两文件,则修改;如果不存在,创建你之并添加内容)
su oracle
cd /home/oracle
sudo nano ./.bashrc
添加如下内容:
# oracle 10g
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
#export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
export ORACLE_OWNER=oracle
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
# Edit paths
#export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/opt/oracle/lib/stubs/:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
sudo nano ./.bashrc
添加如下内容,粗体处引用了刚刚添加的.bashrc文件:
# Begin ~/.bash_profile
# Written for Beyond Linux From Scratch
#
by James Robertson
#
updated by Bruce Dubbs
# Personal environment variables and startup programs.
# Personal aliases and functions should go in ~/.bashrc. System wide
# environment variables and startup programs are in /etc/profile.
# System wide aliases and functions are in /etc/bashrc.
append () {
# First remove the directory
local IFS=':'
local NEWPATH
for DIR in $PATH; do
if [ "$DIR" != "$1" ]; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
# Then append the directory
export PATH=$NEWPATH:$1
}
if [ -f "$HOME/.bashrc" ] ; then
source $HOME/.bashrc
fi
if [ -d "$HOME/bin" ] ; then
append $HOME/bin
fi
unset append
# End ~/.bash_profile
由于oracle对系统的要求比较高,所以有对系统内核参数进行一定的修改,避免因为系统资源不足造成的错误(比较难以排查)。
修改 sysctl.conf
添加以下内容到/etc/sysctl.conf 中:
……
##########################################################
#Oracle Settings
#By Chenghaojun 2008-08-19 16.53
kernel.shmall = 2097152
kernel.shmmax = 3147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
#########################################################
……
注意:该处的设置可以参考oracle10g的帮助文件中的设置,由于该处的参数对系统影响较大,想要深究的话可以参考其他资料以获得更好的配置。
修改 limits.conf
添加以下内容到/etc/security/limits.conf 以修改资源限制:
……
##################################
#By chenghaojun 2008-08-19 17.18
soft nproc 2047
hard nproc 16384
soft nofile 1024
hard nofile 65536
##################################
……
Swap交换区的说明,本博有一篇文章进行描述,请参考:http://blog.163.com/chhj_292/blog/static/12229472008719112811745
安装oracle的swap设置如下:
dd if=/dev/zero of=tmp_swap bs=1k count=900000
chmod 600 tmp_swap
mkswap tmp_swap
swapon tmp_swap
完成安装以后,可以释放这个空间:
swapoff tmp_swap
rm tmp_swap
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
配置完成之后我们需要让我们的参数设置生效,方法很多,本文不赘述。
由于Oracle不提供Ubuntu的支持,所以在进行安装时候有必要对Oracle进行以下欺骗:
创建一个文件 /etc/redhat-release:添加如下内容。
Red Hat Linux release 3.1 (drupal)
oracle 将会把系统认为是 redhat 3,在安装前的系统需求检测中针对RedHat的检测就会显示为通过。
nano /etc/redhat-release
添加如下内容:
Red Hat Linux release 3.1 (drupal)
注意:在安装过程中发现,如果不进行此项的设置在后面安装过程中指定参数(-ignoreSysPrereqs)忽略这些非必要的话也可以安装成功。
下载Oracle 10g(10.2.0):
目录设置
假设文件完整路径为:/usr/repository/oracle/oracle\ for\ linux32.zip
主要命令如下:
su oracle
cd /usr/repository/oracle/oracle
unzip oracle\ for\ linux32.zip
解压完成后,在该目录下会多出一个database目录,即为出来的文件。进入此目录。
cd ./database
在安装之前设置LANG为en_US,因为oracle安装界面对中文支持并不算很友好,对中文显示的设置过于繁琐,所以此处我们并不对中文显示做过高要求,安装的英文提示比较简单。
export LANG=en_US
开始安装:
oracle@administrator-desktop:/usr/repository/oracle/database$ ./runInstaller
Starting Oracle Universal Installer...
Checking installer requirements...
Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2
Passed
All installer requirements met.
到了这里,我们可以看到所有的安装条件都已经满足了,包括操作的版本(在1.5中设置)。
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2008-08-22_10-14-13AM. Please wait ...oracle@administrator-desktop:/usr/repository/oracle/database$ No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at
sun.awt.X11GraphicsEnvironment.
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
at java.awt.Window.init(Unknown Source)
at
java.awt.Window.
at
java.awt.Frame.
at
oracle.ewt.popup.PopupFrame.
at
oracle.ewt.lwAWT.BufferedFrame.
at
oracle.sysman.oio.oioc.OiocOneClickInstaller.
at oracle.sysman.oio.oioc.OiocOneClickInstaller.main(OiocOneClickInstaller.java:2091)
这里发现了一个错误,“Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. ”大致意思是说,不能用DISPLAY环境变量连接到 X11 window server
X11 window server: The Sun AWT classes on Unix and Linux have a dependence on the X Window System: when you use the classes, they expect to load X client libraries and be able to talk to an X display server. This makes sense if your client has a GUI... unfortunately, it's required even if your client uses AWT but does not have a GUI. For example, you need access to an X server to use the java.awt.BufferedImage class. Access to an X display server means a few things:
In general, if you're running your program from a terminal within the X Window System, all these things are true and the program just works. If you can run other X applications, like xterm or xclock, you should be able to run your Java AWT application. In non-graphical environments, such as a servlet engine, your program may not know how to find or connect to an X display server. A common solution here is to run a special non-display version of the X display server, Xvfb, and set DISPLAY to point to it. |
针对Ubuntu8.04的解决方法如下:
切换到root用户,设置DISPLAY环境变量的值为“:0.0”,然后执“xhost +” 命令,如果“access control disabled, clients can connect from any host ”的提示消息,则表示设置成功。
重新切换回oracle用户,执行xterm命令,如果弹出另外一个标题为“Xterm” 的窗口则表示命令执行成功,可以继续下一步的安装。截图如下,右边为控制台,左边为执行xterm命令的结果。
出现“Xterm”为标题的窗口后,在其中重新执行第三步即可。
如果还不能解决请参考:
oracle@administrator-desktop:/$ sqlplus "scott/tiger as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Aug 22 11:27:48 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
oracle@administrator-desktop:/$ lsnrctl
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 22-AUG-2008 11:29:46
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> start
Starting /opt/oracle/product/10.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=administrator-desktop)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-AUG-2008 11:29:53
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/10.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/product/10.2.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=administrator-desktop)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
注意,如果监听器出现以下信息,
Starting
/app/oracle/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR
for Linux: Version 10.2.0.1.0 - Production
System parameter file
is /app/oracle/10.2.0/db_1/network/admin/listener.ora
Log messages
written to
/app/oracle/10.2.0/db_1/network/log/listener_orcl.log
Listening
on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gprsint1.ke.celtel.com)(PORT=1521)))
Error
listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
TNS-12555:
TNS:permission
denied
TNS-12560:
TNS:protocol adapter error
TNS-00525: Insufficient privilege for
operation
Linux Error: 1: Operation not permitted
则执行以下命令,执行完成之后重复3.1.2的操作。
oracle@administrator-desktop:/$ sudo chown -R -v oracle /var/tmp/.oracle
[sudo] password for oracle:
ownership of `/var/tmp/.oracle/s#9628.2' retained as oracle
ownership of `/var/tmp/.oracle/s#9654.1' retained as oracle
ownership of `/var/tmp/.oracle/s#9654.2' retained as oracle
ownership of `/var/tmp/.oracle/s#14765.2' retained as oracle
ownership of `/var/tmp/.oracle/sEXTPROC1' retained as oracle
ownership of `/var/tmp/.oracle/s#9628.1' retained as oracle
ownership of `/var/tmp/.oracle/sEXTPROC0' retained as oracle
ownership of `/var/tmp/.oracle/s#14765.1' retained as oracle
ownership of `/var/tmp/.oracle' retained as oracle
直接访问
进行操作即可,不过要注意控制台和web中操作的冲突。
安装过程