ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 在RHEL4/Fedora4上安装Oracle10g攻略(zt)

在RHEL4/Fedora4上安装Oracle10g攻略(zt)

原创 Linux操作系统 作者:tolywang 时间:2007-03-23 00:00:00 0 删除 编辑
经过无数次的上网找教程,经过N次失败,终于成功在RHEL4上成功安装了Oracle10g数据库并开启WebEM服务,在Fedora4的安装也通过了,现在把攻略记下来很有必要。


第一步,正确配置操作系统
操作系统版本:Red Hat Enterprise Linux AS release 4 (Sentenz)
       Kernel 2.6.9-4.EL on an i686

按照常规来安装操作系统,记得要安装开发工具(gcc等必要工具).


必要的硬件信息检查:

检查内容


最小值


检查命令参考

物理内存


512M


# grep MemTotal /proc/meminfo

交换空间


1.0 GB或者2倍内存大小


# grep SwapTotal /proc/meminfo

/tmp 空间


400 MB


# df -k /tmp

软件所需空间


2.5 GB


# df -k (空间越大越好,如果是正式系统,应该进行详尽的规划)

数据库文件


1.2 GB


# df -k (空间越大越好,如果是正式系统,应该进行详尽的规划)


检查完如上各项之后, 应该修改核心参数.执行如下命令:

#vi /etc/sysctl.conf
#注释:#表示使用root用户操作,$表示使用oracle 用户进行操作.提示符后面的蓝色部分表示需要输入的命令,以下同.

在该文件末尾加入如下内容:

#-----------Begin from here--------------------------------------
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
#--------------End here--------------------------------------------

编辑完之后,保存,执行 # /sbin/sysctl -p 命令操作来使我们所做的变更生效.

注:上面kernel.shmmax/kernel.sem等是典型的核心参数配置.您可能需要根据您的实际环境进行适当的变动.

关于这些核心参数的说明在Oracle的Oracle9i Installation Guide Release 2 (9.2.0.1.0) for UNIX Systems
中有很详细的说明.( http://download-west.oracle.com/docs/html/A96167_01/toc.htm )

然后,应该检查一下上面的操作是否正确:

# /sbin/sysctl -a | grep sem
# /sbin/sysctl -a | grep shm
# /sbin/sysctl -a | grep file-max
# /sbin/sysctl -a | grep ip_local_port_range


为Oracle用户设定Shell的限制

一般来说,出于性能上的考虑,还需要需要进行如下的设定,以便改进Oracle用户的有关 nofile(可打开的文件
描述符的最大数)和nproc(单个用户可用的最大进程数量)

# vi /etc/security/limits.conf
# 添加如下的行

* soft nproc 2047

* hard nproc 16384

* soft nofile 1024

* hard nofile 65536




添加如下的行到/etc/pam.d/login 文件:

session required /lib/security/pam_limits.so



编辑 /etc/profile 文件,添加如下部分:

if [ $USER = "oracle" ]; then

if [ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

fi


之后,执行$ unlimit 验证一下.

检查并安装相关补丁

在这个版本的RHEL上安装Oracle,必须要有几个软件包. 确认以下 rpm包都已经安装:

make-3.79
binutils-2.11
openmotif-2.2.2-16
setarch-1.3-1
compat-db-4.0.14.5
compat-gcc-7.3-2.96.122
compat-gcc-c++-7.3-2.96.122
compat-libstdc++-7.3-2.96.122
compat-libstdc++-devel-7.3-2.96.122

# rpm -qa | grep compat
# 在我的机器上输出如下:
compat-gcc-c++-7.3-2.96.122
compat-libstdc++-7.3-2.96.122
compat-libstdc++-devel-7.3-2.96.122
compat-glibc-7.x-2.2.4.32.5
compat-db-4.0.14-5
compat-gcc-7.3-2.96.122

# rpm -qa | grep openmotif
openmotif-devel-2.2.2-16
openmotif-2.2.2-16

# rpm -qa | grep setarch
setarch-1.3-1

上面显示的内容是在笔者已经安装了具体的RPM包之后的结果.一般情况下,你的系统上的输出结果和这个不同.如果个
别包没有安装,把系统安装光盘mount上,找到具体的软件包(大多数在第三张光盘上),然后利用如下的命令来安装相应
的包:

# rpm -ivh compat.....rpm

要额外注意的是,这些软件包之间是有依赖性的,先后的顺序要找好.否则会报告不能安装的错误.

此外,最好验证一下 gcc和glibc的版本(要求是gcc-3.2.3-2 或者更高)

#gcc -v
#rpm -q glibc

创建用户和相关的组

# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/useradd -g oinstall -G dba oracle 

如果只是测试目的的话,不创建oinstall组也没什么. 不过还是规范一点比较好.如果oracle 用户和dba组等已经存在,作
适当的调整即可.

检查并调整环境变量

登录为oracle用户
# su – oracle
$ cd
$ vi .bash_profile

#添加如下内容,你的具体值应该不会和这个完全相同.

export ORACLE_BASE=/u/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1
export ORACLE_SID=TEST
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export LC_CTYPE=en_US.UTF-8

然后执行
$ source .bash_profile
使环境变量生效. /u/app/oracle 等目录应该建立好并做合适的授权.

开始安装10g

$ sh /u/install/runInstaller -ignoreSysPrereqs (此处参数表明不检查操作系统版本)

如果不能出现安装画面,查看本文后面的FAQ。

非常值得称道的是,10g的安装相比以前的多了一个 Checking operating system certification 的步骤。特别实用。
安装文件会自动检测所需的条件。如果有不符合的地方,安装程序会报告给你.并会给出具体原因。大大减少了出错的可能.
===========

其他的步骤比较清晰,不再赘述.

最后系统会提示你运行root.sh文件.按照提示做即可.


FAQ (在Linux平台安装Oracle比较常见)

1. 不能启动安装界面.运行runInstaller提示信息类似如下:

xlib:connection to "localhost:0.0" refused by server
xlib:client is not authorized to connect to server

Exception in thread "main" java.lang.InternalError:can't connect to x11 window server using "localhost:0.0"
at .......

解决办法: 设定你的DISPLAY环境参数.# export DISPLAY= your_IPaddress :0.0把your_IPaddress换成你的IP.或者
用root简单的执行一下# xhost + (要注意这样会有安全上的隐患)

创建数据库:$ORACLE_HOME/bin/dbca
启动WebEM:$ORACLE_HOME/bin/emctl start dbconsole


2.安装界面显示很多"口口"样子的乱码

解决办法:查看locale输出
# locale
LANG=en_US.UTF-8
LC_CTYPE=zh_CN.GB18030
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

执行#export LC_CTYPE=en_US.UTF-8 然后重新调用安装程序.


3. 用IE登录Linux服务器上的em出现乱码

 在Linux(Unix) 环境下成功安装了Oracle 10g,从windows下用IE浏览器登录 10g 的em, 按钮是"口口"这样的方框.

解决办法:
主要原因是Oracle10g自带的JavaRuntime的问题
(1)停止em服务-emctl stop dbconsole
(2)把相关目录(RHEL4里是/etc/java/)下的font.properties用fontproperties.zh_CN.Redhat8.0或者font.properties.zh代替
(3)删除$ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/em/em/cabo/images/
cache/zhs中的gif文件
(4)重起服务 emctl start dbconsole



开机自动启动Oracle10g方法(三种)
一、
1. 创建文件/etc/oratab
添加

Code: [Copy to clipboard]
#添加如下内容到/etc/oratab文件中,
#$ORACLE_SID是你的Oracle数据库的sid
#$ORACLE_HOME是你的Oracle数据库的Oracle_home
#Y表示要求在系统启动的时候启动Oracle数据库.N表示不要在系统启动的时候启动Oracle
$ORACLE_SID:$ORACLE_HOME:Y

2. 修改文件/etc/rc.local添加一下两行

Code: [Copy to clipboard]
##
## 关于su的具体命令参看linux的manual文档
##
su - oracle -c 'dbstart'
su - oracle -c 'lsnrctl start'

3. 在本机使用dbstart,和dbshut测试设置的准确性.

Code: [Copy to clipboard]
[oracle@tzcenter oracle]$ dbshut

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Nov 11 21:02:35 2004

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> Connected.
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
Database "webora9" shut down.
[oracle@tzcenter oracle]$ dbstart

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Nov 11 21:02:43 2004

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> Connected to an idle instance.
SQL> ORACLE instance started.

Total System Global Area 437327188 bytes
Fixed Size 451924 bytes
Variable Size 134217728 bytes
Database Buffers 301989888 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

Database "webora9" warm started.
[oracle@tzcenter oracle]$

二、

先z在oracle用户目录里创建dbstart.sh , 内容如下:
#!/bin/sh
export oracle_HOME=/home/oracle/product/10.1.0/db_1
export oracle_SID=oracle10
$oracle_HOME/bin/sqlplus /nolog<
connect system/manager as sysdba
startup
exit
EOF
$oracle_HOME/bin/lsnrctl start

然后在local.rc里面加一行:
su -c /home/oracle/dbstart.sh - oracle

这样每次启动的时候就会自动启动oracle和监听,记得修改相应的路径啊。

三、(官方文档)
In this article I'll describe the installation of oracle Database 10g Release 2 (10.2.0.1) on RedHat Advanced Server 4.0. The article is based on a server installation with a minimum of 2G swap, secure linux disabled and the following package groups installed:

X Window System
GNOME Desktop Environment
Editors
Graphical Internet
Text-based Internet
Server Configuration Tools
Development Tools
Administration Tools
System Tools
Alternative installations may require additional packages to be loaded in addition to the ones listed below.

Download Software
Unpack Files
Hosts File
Set Kernel Parameters
Setup
Installation
Post Installation
Download Software
Download the following software:

oracle Database 10g Release 2 (10.2.0.1) Software
Unpack Files
Unzip the files:

unzip 10201_database_linux32.zip
You should now have a single directory (db/Disk1) containing installation files.

Hosts File
The /etc/hosts file must contain a fully qualified name for the server:


Set Kernel Parameters
Add the following lines to the /etc/sysctl.conf file:

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
Run the following command to change the current kernel parameters:

/sbin/sysctl -p
Add the following lines to the /etc/security/limits.conf file:

* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536
Add the following line to the /etc/pam.d/login file, if it does not already exist:

session required /lib/security/pam_limits.so
Note by Kent Anderson: In the event that pam_limits.so cannot set privilidged limit settings see Bug 115442.

Disable secure linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set as follows:

SELINUX=disabled
Alternatively, this alteration can be done using the GUI tool (Applications > System Settings > Security Level). Click on the SELinux tab and disable the feature.

Setup
Install the following packages:

# From RedHat AS4 Disk 2
cd /media/cdrom/RedHat/RPMS
rpm -Uvh setarch-1.6-1.i386.rpm
rpm -Uvh compat-libstdc++-33-3.2.3-47.3.i386.rpm
rpm -Uvh make-3.80-5.i386.rpm
rpm -Uvh glibc-2.3.4-2.i386.rpm

# From RedHat AS4 Disk 3
cd /media/cdrom/RedHat/RPMS
rpm -Uvh openmotif-2.2.3-6.RHEL4.2.i386.rpm
rpm -Uvh compat-db-4.1.25-9.i386.rpm
rpm -Uvh libaio-0.3.102-1.i386.rpm
rpm -Uvh gcc-3.4.3-9.EL4.i386.rpm

# From RedHat AS4 Disk 4
cd /media/cdrom/RedHat/RPMS
rpm -Uvh compat-gcc-32-3.2.3-47.3.i386.rpm
rpm -Uvh compat-gcc-32-c++-3.2.3-47.3.i386.rpm
Create the new groups and users:

groupadd oinstall
groupadd dba
groupadd oper

useradd -g oinstall -G dba oracle
passwd oracle
Create the directories in which the oracle software will be installed:

mkdir -p /u01/app/oracle/product/10.2.0/db_1
chown -R oracle.oinstall /u01
Login as root and issue the following command:

xhost +
Login as the oracle user and add the following lines at the end of the .bash_profile file:

# oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

oracle_BASE=/u01/app/oracle; export oracle_BASE
oracle_HOME=$oracle_BASE/product/10.2.0/db_1; export oracle_HOME
oracle_SID=TSH1; export oracle_SID
oracle_TERM=xterm; export oracle_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$oracle_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$oracle_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$oracle_HOME/JRE:$oracle_HOME/jlib:$oracle_HOME/rdbms/jlib; export CLASSPATH
#LD_ASSUME_KERNEL=2.4.1; export LD_ASSUME_KERNEL

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
Installation
Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable:

DISPLAY=:0.0; export DISPLAY
Start the oracle Universal Installer (OUI) by issuing the following command in the Disk1 directory:

./runInstaller
During the installation enter the appropriate oracle_HOME and name then continue installation.

Post Installation
Edit the /etc/oratab file setting the restart flag for each instance to 'Y':

TSH1:/u01/app/oracle/product/10.2.0/db_1:Y
Create a file called /etc/init.d/dbora containing the following:

#!/bin/sh
# description: oracle auto start-stop script.
# chkconfig: - 20 80
#
# Set ORA_HOME to be equivalent to the $oracle_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
;;
'stop')
# Stop the oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esac
Use chmod to set the privileges to 750:

chmod 750 /etc/init.d/dbora
Link the file into the appropriate run-level script directories:

ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
Associate the dbora service with the appropriate run levels:

chkconfig --level 345 dbora on
The relevant instances should now startup/shutdown automatically at system startup/shutdown.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-84535/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13381761