安装前准备工作:
1、检查下列包是否安装,若未安装则要先安装:
binutils-2.17.50.0.6-2.el5
compat-libstdc++-33-3.2.3-61
elfutils-libelf-0.125-3.el5
elfutils-libelf-devel-0.125
glibc-2.5-12
glibc-common-2.5-12
glibc-devel-2.5-12
gcc-4.1.1-52
gcc-c++-4.1.1-52
libaio-0.3.106
libaio-devel-0.3.106
libgcc-4.1.1-52
libstdc++-4.1.1
libstdc++-devel-4.1.1-52.e15
make-3.81-1.1
sysstat-7.0.0
unixODBC-2.2.11
unixODBC-devel-2.2.11
检查发现以下软件包未安装:
libaio-devel-0.3.106-5.i386.rpm
sysstat-7.0.2-3.el5_5.1.i386.rpm
unixODBC-2.2.11-7.1.i386.rpm
unixODBC-devel-2.2.11-7.1.i386.rpm
安装软件包
rpm -ivh libaio-devel*.rpm sysstat-7.0.2-3*.rpm unixODBC-2.2.11-7.1.i386.rpm unixODBC-devel-2.2.11-7.1.i386.rpm
2> 检查内存与虚拟内存
[root@node1 opt]# free
total used free shared buffers cached
Mem: 681540 415396 266144 0 4612 310660
-/+ buffers/cache: 100124 581416
Swap: 2048276 84 2048192
3> 检查磁盘空间
[root@node1 opt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 18G 5.3G 12G 33% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 333M 0 333M 0% /dev/shm
4> 查看系统版本
[root@node1 opt]# uname -a
Linux node1.cn1 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux
5> 配置主机名
[root@node1 /]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.201 node1.cn node1
[root@node1 /]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=node1.cn
GATEWAY=192.168.1.254
6> 创建安装用户与组 安装目录
[root@node1 /]# groupadd -g 1001 oinstall
[root@node1 /]# groupadd -g 1002 dba
[root@node1 /]# useradd -u 1001 -g oinstall -G dba oracle
[root@node1 /]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@node1 /]# mkdir -p /u01/app/oracle //软件安装目录
[root@node1 /]# chown -R oracle:oinstall /u01
# mkdir -p /opt/oradata //oracel 数据存放目录
# chown -R oracle:oinstall /opt
# chmod -R 775 /opt/
7> 修改系统内核参数:
[root@node1 opt]# vi /etc/sysctl.conf
===========================================
kernel.shmall = 2097152
kernel.shmmax = 536870912 //物理内存1半
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.aio-max-nr = 1048576
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576 //1M
net.core.rmem_max = 1048576
net.core.wmem_default = 262144 //256K
net.core.wmem_max = 262144
[root@node1 opt]# /sbin/sysctl -p //使内核参数即使生效
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmall = 2097152 //可用共享内存的总量,单位是页,在32位系统上一页等于4kB,也就是4096字节
kernel.shmmax = 536870912 //单个共享内存段的最大值,此值一般为物理内存的一半,不过大一点也没关系
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128 //设置的信号量,这4个参数内容大小固定
fs.file-max = 65536 //文件句柄的最大数量。文件句柄表示在Linux系统中可以打开的文件数量
fs.aio-max-nr = 1048576 //文件系统最大异步io
net.ipv4.ip_local_port_range = 9000 65500 //应用程序可使用的IPv4端口范围
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576 //接收套接字缓冲区大小的最大值
net.core.wmem_default = 262144
net.core.wmem_max = 262144 //发送套接字缓冲区大小的最大值
8> 设置oracle使用的文件数权限
[root@node1 opt]# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
9> 用户界面安全设置
[root@node1 opt]# vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
10> 用户访问端口范围设置
[root@node1 opt]# vi /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
11> 设置用户环境变量
[root@node1 opt]# su - oracle
[oracle@node1 ~]$ vi .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11g
export ORACLE_SID=orcl
export ORACLE_OWNER=oracle
export ORACLE_TERM=vt100
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
export CLASSPATH
[oracle@node1 ~]$ source .bash_profile //使环境变量即使生效
12> 准备进入界面安装程序
[root@node1 /]# xhost +
access control disabled, clients can connect from any host
[root@node1 /]# su - oracle
[oracle@node1 database]$ cd /opt/database/ //进入安装文件存储目录
[oracle@node1 database]$ ls
doc install response rpm runInstaller sshsetup stage welcome.html
[oracle@node1 database]$ ll //查看安装文件是否有执行权限
total 40
drwxr-xr-x 12 root root 4096 Aug 17 2009 doc
drwxr-xr-x 4 root root 4096 Aug 14 2009 install
drwxrwxr-x 2 root root 4096 Aug 14 2009 response
drwxr-xr-x 2 root root 4096 Aug 14 2009 rpm
-rwxr-xr-x 1 root root 4352 Aug 14 2009 runInstaller
drwxrwxr-x 2 root root 4096 Aug 14 2009 sshsetup
drwxr-xr-x 14 root root 4096 Aug 14 2009 stage
-rw-r--r-- 1 root root 5400 Aug 18 2009 welcome.html
[oracle@node1 database]$ ./runInstaller //执行安装程序包
.............
[oracle@node1 /]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 16 13:49:49 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 418484224 bytes
Fixed Size 1336932 bytes
Variable Size 276826524 bytes
Database Buffers 134217728 bytes
Redo Buffers 6103040 bytes
Database mounted.
Database opened.
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
ora11g OPEN
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
设置 Oracle11g 自动随系统启动
[oracle@node1 /]$ vi/etc/oratab
ora11g:/u01/app/oracle/11g:y //重启动标志设置成 'Y'
[oracle@node1 /]$vi /u01/app/oracle/11g/bin/dbstart
ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
[oracle@node1 /]$vi /u01/app/oracle/11g/bin/dbshut
ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
创建一个oracle启动文件:
[root@node1 ~]# cat /etc/init.d/oracle
#!/bin/sh
# chkconfig: 345 61 61 //这里头4项的设置与添加到系统服务有关系,设置不正确会导致找不到服务
# description: Oracle 11g AutoRun Services
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/11g
export ORACLE_SID=ora11g
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
echo "Oracle Start Succesful!OK."
;;
stop)
# Oracle listener and instance shutdown
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
echo "Oracle Stop Succesful!OK."
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo $"Usage: `basename $0` {start|stop|reload|reload}"
exit 1
esac
exit 0
[root@node1 ~]#chmod 750 /etc/init.d/oracle //赋于文件执行的权限
[root@node1 ~]#ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle
[root@node1 ~]#ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
[root@node1 ~]#chkconfig --level 345 oracle on //设置启动
[root@node1 ~]#chkconfig --add oracle //将程序添加到系统服务
[root@node1 ~]#chkconfig --list oracle
ora11g 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@node1 ~]#reboot //重启测试
[root@node1 ~]# ps -ef |grep ora //检查进程情况 或者直接登录数据库
[root@node1 ~]$lsnrcl status //检查监听