天天看點

Redhat 5.5 安裝oracle 11G

安裝前準備工作:

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.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_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

# 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}"

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                            //檢查監聽