1. 检查内存,至少1G

#free -m


2.检查交换分区,一般为内存1~2倍

#grep SwapTotal /proc/meminfo


3.检查CPU

#grep "model name" /proc/cpuinfo


4.检查/tmp, 至少1G

#df -h /tmp


5. 数据库软件和data磁盘空间要求

    Installation Type        Requirement for Software Files (GB) 

    Enterprise Edition        3.95 

    Standard Edition        3.88 


    Installation Type        Requirement for Data Files (GB) 

    Enterprise Edition        1.7 

    Standard Edition        1.5 


#df -h

#fdisk -l


6. 操作系统版本,一般为rhel5

#uname -a

    Linux rhel5.oraclelinux.com 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux


7. 配置yum源,并安装oracle所需软件包

#mount /dev/cdrom /mnt   //挂载光盘

#vi /etc/yum.repos.d/yum.repo   //配置yum源文件

[server]

name=server

baseurl=file:///mnt/Server

enabled=1

gpgcheck=0


#yum clean all

#yum repolist


需要被安装软件包:binutils-* compat-libstdc++-33-* elfutils-libelf-* elfutils-libelf-devel-* gcc-* gcc-c++-* glibc-* glibc-common-* glibc-devel-* glibc-headers-* ksh-* libaio-* libgcc-* libstdc++-*  make-* sysstat-* unixODBC-*  unixODBC-devel-*


#yum install -y  binutils-* compat-libstdc++-33-* elfutils-libelf-* elfutils-libelf-devel-* gcc-* gcc-c++-* glibc-* glibc-common-* glibc-devel-* glibc-headers-* ksh-* libaio-* libgcc-* libstdc++-*  make-* sysstat-* unixODBC-*  unixODBC-devel-* libXp   //采用yum一次性安装

 

  

#rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \                  //检查安装情况

compat-libstdc++ \

elfutils-libelf-devel \

elfutils-libelf-devel-static \

gcc \

gcc-c++ \

glibc \

glibc-common \

glibc-devel \

glibc-headers \

kernel-headers \

ksh \

libaio \

libaio-devel \

libgcc \

libgomp \

libstdc++ \

libstdc++-devel \

make \

sysstat \

unixODBC \

unixODBC-devel \

libXp



8.修改hostname

#vi /etc/hosts

 192.168.1.100 nod1

#hostname nod1

#ping nod1


9. 添加内核参数

#vi /etc/sysctl.conf

kernel.shmall = 2097152

kernel.shmmax = 536870912

kernel.shmmni = 4096

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


shmmax - 共享内存段的最大字节数,建议设大点,甚至可以大过物理内存的字节数

shmmin - 共享内存段的最小尺寸.

shmmni - 共享内存段的最大数目.

shmseg - 每个进程可分配的最大共享内存段数目.

shmall - 最大的并发共享内存段数目,比SGA还要大.

semmns - 信号灯的最大数量,跟ORACLE的PROCESS数有关.

semmsl - 每个信号灯集合中最多的信号灯数目.


#sysctl -p             //让参数立刻生效


10. 创建组和用户

#groupadd -g 501 dba

#useradd -g  dba -u 500 oracle  //gid和uid尽量错开,便于以后管理

#passwd oracle


11.添加oracle用户系统限制参数

#vi /etc/security/limits.conf

oracle           soft    nproc   2047

oracle           hard    nproc   16384

oracle           soft    nofile  1024

oracle           hard    nofile  65536


12. 创建安装目录

#mkdir  /oracle   //软件安装目录

#mkdir /oradata   //数据库安装目录

#chown  oracle:dba /oracle

#chown  oracle:dba /oradata


13.给oracle用户添加环境变量

#su - oracle

$vi /home/oracle/.bash_profile

export ORACLE_BASE=/oracle/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2

export PATH=$ORACLE_HOME/bin:$PATH


14.利用xshell上传oracle软件至服务器

10201_database_linux_x86_64.cpio.gz   //10.2.1版本

p8350262_10204_Generic.zip      //10.2.1的补丁

p8202632_10205_Linux-x86-64.zip      //10.2.5版本,它为10.2.1的增量升级版本


#su - oracle

$gunzip 10201_database_linux_x86_64.cpio.gz //解压为10201_database_linux_x86_64.cpio

$cpio -idcmv < 10201_database_linux_x86_64.cpio   //解压为database文件夹

$unzip p8202632_10205_Linux-x86-64.zip //解压为Disk1文件夹

$unzip p8350262_10204_Generic.zip                       //解压为8350262文件夹


15.以oracle身份安装

$su - oracle

$cd database

$./runInstaller  -ignoresysprereqs    //默认情况下,10g不支持rhel5,须加上这个参数,忽略掉版本检测

$cd 8350262

$ORACLE_HOME/OPatch/opatch apply      //安装补丁

OPatch succeeded.


$cd Disk1

$./runInstaller      //默认情况下,已支持rhel5

注意:10.2.5为10.2.1的增量升级包,所以安装的时候须采取覆盖安装的方式升级


16.netca创建监听

$netca  //据提示一步步安装

$lsnrctl status                   //查看监听情况,默认情况下,已启动

$lsnrctl start  //启动监听

$lsnrctl stop                     //关闭监听


17.dbca创建数据库

$dbca                            //据提示一步步安装


注意:在安装时如果选择asm,会提示以root用户执行localconfig add,启用CSS服务(集群服务)

# ./localconfig add

/etc/oracle does not exist. Creating it now.

Successfully accumulated necessary OCR keys.

Creating OCR keys for user 'root', privgrp 'root'..

Operation successful.

Configuration for local CSS has been initialized


Adding to inittab 

Startup will be queued to init within 30 seconds.

Checking the status of new Oracle init process...

Expecting the CRS daemons to be up within 600 seconds.

CSS is active on these nodes.

nod1

CSS is active on all nodes.

Oracle CSS service is installed and running under init(1M)


注意:oracle安装介质有3种形式fs,raw,asm,其中raw,asm配置方法见《linux下ORACLE之raw创建》及《linux下ORACLE之ASM创建》



18.查看数据库进程

$ps -ef|grep ora


19.进入数据库启动和关闭数据库

$export ORACLE_SID=fsdb1        //声明SID,指定进入的数据库

$sqlplus / as sysdba

SQL>startup                     //默认情况下已启动

SQL>shutdown immediate;






关于opatch :

从9.2版开始,Oracle公司实现了个别补丁安装工具opatch. opatch使用一个称为inventory的系统数据结构(严格说是与oui共享inventory),集中管理所有已安装的个别补丁;个别补丁的安装和卸载都使用opatch命令完成,冲突检测也由opatch在安装时自动完成;提供列表命令可以很方便得到已安装个别补丁的信息。

 

10g(10.1和10.2)版本中,opatch作为一个标准工具,在安装时自动安装。(安装在$ORACLE_HOME/OPatch下。)而对于9.2版,需要从metalink下载opatch.无论是哪一个版本,系统中是否已经安装opatch,在使用之前,应从metalink下载最新版本的opatch.很遗憾,由于系统实现的问题,10.2使用的opatch与之前版本(10.1和9.2)使用的opatch不兼容,不能混用,这一点必须注意。

 

opatch是使用perl编写的脚本程序(其中也使用JAVA API)。使用的perl版本是5.6版,虽然在5.6之前的版本中也可运行,但应尽可能安装5.6或以上的版本的perl. 对于DBA来说一个好消息是,如果安装9.2版软件时保留了HTTP服务器,则在$ORACLE_HOME/Apache下会自动安装perl.(10g会自动安装配置perl和opatch.)


 

使用“-help”参数可以获得opatch命令的帮助信息

$ ./opatch --help

Invoking OPatch 10.2.0.1.0

Oracle interim Patch Installer version 10.2.0.1.0

Copyright (c) 2005, Oracle Corporation.  All rights reserved..

Oracle Home       : /u01/oracle/oracle/product/10.2.0/db_1

Central Inventory : /u01/oracle/oraInventory

   from           : /u01/oracle/oracle/product/10.2.0/db_1/oraInst.loc

OPatch version    : 10.2.0.1.0

OUI version       : 10.2.0.1.0

OUI location      : /u01/oracle/oracle/product/10.2.0/db_1//oui

Log file location : /u01/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch-2010_Aug_09_03-05-40-CST_Mon.log

Usage: opatch [ -help ] [ -r[eport] ] [ command ]

            command := apply

                       lsinventory

                       query

                       rollback

                       version

 

  := -help       Displays the help message for the command.

                       -report     Print the actions without executing (deprecated).

 

example:

   'opatch -help'

   'opatch apply -help'

   'opatch lsinventory -help'

   'opatch rollback -help'

 

 


 

这个是10.2.0.1版本的opatch. 在10.2.0.4 版本的opatch命令与之前的又不同,它有添加了几个命令。

$ ./opatch --help

Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6

Copyright (c) 2009, Oracle Corporation.  All rights reserved.

 

Usage: opatch [ -help ] [ -r[eport] ] [ command ]

            command := apply

                       lsinventory

                       napply

                       nrollback

                       rollback

                       query

                       version

                       prereq

                       util

  := -help       Displays the help message for the command.

                       -report     Print the actions without executing.

 

example:

   'opatch -help'

   'opatch apply -help'

   'opatch lsinventory -help'

   'opatch napply -help'

   'opatch nrollback -help'

   'opatch rollback -help'

   'opatch prereq -help'

   'opatch util -help'

 

 

官网上对命令的一些解释:  

 

apply

Installs an interim patch. Refer to "apply Command" for more information.

napply

Installs n number of patches (hence napply). Refer to "napply Command" for more information.

auto

Applies Oracle Clusterware patches. Refer to "auto Command" for more information.

lsinventory

Lists what is currently installed on the system. Refer to "lsinventory Command" for more information.

query

Queries a given patch for specific details. Refer to "query Command" for more information.

rollback

Removes an interim patch. Refer to "rollback Command" for more information.

nrollback

Removes n number of patches (hence nrollback). Refer to "nrollback Command" for more information.

version

Prints the current version of the patch tool. Refer to "version Command" for more information.

 

 

在$ORACLE_HOME/OPatch/docs目录下,用指南文件(Users_Guide.txt),其中有详细的命令格式和使用示例,可以参考。

Opatch执行操作时,除在屏幕输出结果外,还生成日志文件。

日志文件的路径和文件名格式如下:

  $ORACLE_HOME/.patch_storage/< patch_id >/< action >-< patch_id >_< mm-dd-yyyy_hh-mi-ss>.log

  其中“patch_id”是Oracle技术支持部门为个别补丁分配的编号。

 


opatch下载

     从metalink下载补丁的压缩文件p8350262_10204_LINUX.zip.将此文件解压缩至某一目录中。解压缩后,这一补丁的所有文件都在子目录8350262下,目录名就是个别补丁的补丁号,opatch依据目录名获得信息,所以一定不要重命名子目录。



opatch命令的存放位置:

$ls /oracle/app/oracle/product/10.2.0/db_1/OPatch

 docs  emdpatch.pl  jlib  opatch  opatch.ini  opatch.pl

 

opatch 补丁安装

$su - oracle

$cd  /oracle/8350262

$$ORACLE_HOME/OPatch/opatch apply


opatch 补丁卸载 

$$ORACLE_HOME/OPatch/opatch rollback -id 8350262