---
title: "CentOS 5.5安装Oracle 10gR2"
author: "Juizes361"
date: "2011-01-27T10:51:05Z"
tags: []
categories: ["数据库"]
slug: "centos-5-5-oracle-10gr2"
draft: false
lastmod: "2012-04-14T13:14:23Z"
id: 898006
url: "https://juizes361.iteye.com/blog/898006"
---

1\. 用Root用户登录系统

2\. 检查Oracle安装依赖的软件包

```
 binutils-2.17.50.0.6-14.el5.i386.rpm
 compat-db-4.2.52-5.1.i386.rpm
 compat-libstdc++-33-3.2.3-61.i386.rpm
 gcc-4.1.2-48.el5.i386.rpm
 gcc-c++-4.1.2-48.el5.i386.rpm
 gd-2.0.33-9.4.el5_4.2.i386.rpm
 gdb-7.0.1-23.el5.i386.rpm
 gd-progs-2.0.33-9.4.el5_4.2.i386.rpm
 glibc-2.5-49.i686.rpm
 glibc-common-2.5-49.i386.rpm
 glibc-devel-2.5-49.i386.rpm
 glibc-headers-2.5-49.i386.rpm
 glibc-utils-2.5-49.i386.rpm
 libaio-0.3.106-5.i386.rpm
 libstdc++-4.1.2-48.el5.i386.rpm
 libstdc++-devel-4.1.2-48.el5.i386.rpm
 libXp-1.0.0-8.1.el5.i386.rpm
 make-3.81-3.el5.i386.rpm
 openmotif-2.3.1-2.el5_4.1.i386.rpm
 setarch-2.0-1.1.i386.rpm
 sysstat-7.0.2-3.el5.i386.rpm
```

 

3\. 创建需要的用户组及用户

```
# groupadd dba
# groupadd oinstall
# useradd -g oinstall -G dba -d /home/oracle oracle
# passwd oracle
```

  

4\. 配置内核参数

  修改：/etc/sysctl.conf 文件

```
 # shmall - maximum number of shared memory pages. If you set it to too low value can slowdown any program usng shared memory
 # shmmax - maximum size of shared memory segment that can be allocated in the memory. For servers with lots of memory can be increased to 80% of memory to avoid shared memory fragmentation
 # shmmni - maximum number of segments. It's good idea to change it only by vendor recommendation 
 kernel.shmall = 2097152
 kernel.shmmax = 2147483648
 kernel.shmmni = 4096

 # semaphores: semmsl, semmns, semopm, semmni
 # semmsl - maximum number of semaphores per semaphore identifier. Very big number will eat memory not used later
 # semmns - maximum number of semaphores in the system. Size it carefully because of above reason
 # semopm - Define maximum number of semaphore operations per system call
 # semmni ¨C maximum number of semaphore identifier. Do not increase it over needed limit, because of waste of memory
 kernel.sem = 250 32000 100 128

 # the maximum number of file handles
 fs.file-max = 65536

 # ip_local_port_range - define full range of local ports in Linux, normally upper limit is 32000
 # rmem_default - Default Receive Window
 # rmem_max Maximum - Receive Window
 # wmem_default - Default Send Window
 # wmem_max - Maximum Send Window 
 net.ipv4.ip_local_port_range = 1024 65000
 net.core.rmem_default = 1048576
 net.core.rmem_max = 1048576
 net.core.wmem_default = 262144
 net.core.wmem_max = 262144
```

 

5\. 为oracle用户提高shell限额，配置环境变量  
To improve the performance of the software on Linux systems, you must increase the following shell limits for the oracle user:

nofile - Maximum number of open file descriptors  
nproc  - Maximum number of processes available to a single user

  5.1 修改/etc/security/limits.conf 文件：

 

```
 oracle              soft    nproc   2047
 oracle              hard    nproc   16384
 oracle              soft    nofile  1024
 oracle              hard    nofile  65536
```

 

  5.2 修改/etc/pam.d/login文件：

```
 session    required     /lib/security/pam_limits.so
 session    required     pam_limits.so
```

 

  5.3 修改/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
```

 

  5.4 修改/etc/oratab文件

 

```
 #oradb:/opt/oracle/product/10.2.0/db_1:N
 oradb:/opt/oracle/product/10.2.0/db_1:Y
```

 

  5.5 设置bash下环境变量，修改 .bash\_profile文件

 

```
 ORACLE_BASE=/opt/oracle; export ORACLE_BASE
 ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
 ORACLE_SID=oradb; export ORACLE_SID
 PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH; export PATH
 LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
```

 

6\. 解压oracle安装文件 ./runInstaller，根据提示开始安装

7\. 将Oracle设为系统服务，并开机自启动

  7.1 编写 /etc/init.d/oracle脚本

 

```
#!/bin/bash
 #description:starts the oracle database deamons

 ORA_HOME="/opt/oracle/product/10.2.0/db_1"
 ORA_OWNER="oracle"
 case $1 in

 'start')
 echo -n "***Starting Oracle***"
 su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
 su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
 ;;

 'stop')
 echo -n "***Stopping Oracle***"
 su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
 su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
 ;;

 'restart')
 echo -n "***Restarting Oracle***"
 $0 stop
 $0 start
 ;;

 'isqlstart')
 echo "***Starting Oracle iSQL PLus***"
 su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl start"
 echo "*** Note:You can access service at url:http://$(hostname):5560/isqlplus"
 ;;

 'isqlstop')
 echo "***Stopping Oracle iSQL Plus***"
 su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl stop"
 ;;

 'emstart')
 echo "***Starting Oracle Enterprise Manager 10g Database control***"
 su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
 echo "Note:You can access service as url:http://$(hostname):1158/em"
 ;;

 'emstop')
 echo "***Stopping Oracle Enterprise Manager 10g Database control***"
 su - $ORA_OWNER -c "ORA_HOME/bin/emctl stop dbconsole"
 ;;

 '*')
 echo "Usage:$0 {start|stop|isqlstart|isqlstop|emstart|emstop}"
 exit 1

 esac
 exit 0
```

 

   7.2 设置Oracle服务开机启动

 

```
#chkconfig oracle on
```