【0】 配置网易YUM源

[root@localhost dev]# vi /etc/yum.repos.d/CentOS-Base.repo


[base]

name=CentOS-$releasever - Base

baseurl=http://mirrors.163.com/centos/6/os/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#released updates

[updates]

name=CentOS-$releasever - Updates

baseurl=http://mirrors.163.com/centos/6/updates/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#packages used/produced in the build but not released

#[addons]

#name=CentOS-$releasever - Addons

#baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/

#gpgcheck=1

#gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

baseurl=http://mirrors.163.com/centos/6/extras/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/

"/etc/yum.repos.d/CentOS-Base.repo" 29L, 993C written

[root@localhost dev]#

[root@localhost dev]# yum clean all

Loaded plugins: refresh-packagekit, rhnplugin

Cleaning up Everything

[root@localhost dev]#

[root@localhost dev]#

[root@localhost dev]


【1】准备安装


为了避免缺包导致的Error,请在安装Oracle之前执行以下命令:


yum install yum-fastestmirror -y

yum install compat-db*

yum install compat-libc*

yum install compat-gcc*

yum install libXp.so.6

yum install libc-*

yum install libaio*

yum install openmotif

yum install glibc-devel*

yum install libgcc*

yum install gnome-lib*


【2】安装包解压

unzip 10201_database_linux32.zip


【3】创建 Oracle 组和用户帐户


创建用于安装和维护Oracle 10g 软件的账户。用户帐户将称为oracle,而组将称为oinstall和dba。以root用户身份执行以下命令:


# /usr/sbin/groupadd oinstall

# /usr/sbin/groupadd dba

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

# id oracle

uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)

设置oracle帐户的口令


# passwd oracle

Changing password for user oracle.

New password:asdfghjkl

Retype new password:asdfghjkl

passwd:all authentication tokens updated successfully.


【4】修改版本


cat > /etc/redhat-release << EOF

Red Hat Enterprise Linux AS release 3 (Taroon)

EOF


【5】修改内核参数


安装Oracle 10g需修改内核参数,否则安装检测时会报Failed,甚至导致安装时出现Error。以root身份执行以下命令:


cat >> /etc/sysctl.conf <<EOF

kernel.shmall = 2097152

kernel.shmmax = 2147483648

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

EOF

如果检查没有问题后,即可以开始装Oralce 10g。

参看

cat /proc/sys/kernel/shmmax

使配置生效

sysctl -p


【6】.修改gennttab


解压缩filegroup6.jar。


cd database/stage/Components/oracle.network.rsf/10.2.0.1.0/1/DataFiles/


unzip filegroup6.jar bin/gennttab


修改解压出来的gennttab文件。


vi bin/gennttab




改为:




即把`s/ /\\`中的后面的”\”改为”n”,同时要注意把n后的空格删除,否则在安装监听器时会报错。


将gennttab添加到filegroup6.jar中。


zip -vu filegroup6.jar bin/gennttab



【7】. Oracle 建议对每个 Linux 帐户可以使用的进程数和打开的文件数设置限制。


要进行这些更改,以 root 用户的身份执行下列命令:


vi /etc/security/limits.conf


添加如下内容:


  oracle soft nproc 2047


  oracle hard nproc 16384


  oracle soft nofile 1024


  oracle hard nofile 65536



【8】.关闭SELINUX工作模式


SELINUX属性配置文件位置为/etc/selinux/config


# 设置SELINUX为disabled


  SELINUX=disabled



【9】.设置环境变量


以oracle用户登录。


vi  ~/.bash_profile


添加如下内容:


   export TMP=/tmp


   export TMPDIR=/tmp


   export ORACLE_BASE=/home/oracle


   export ORACLE_SID=ora10g


   export ORACLE_HOME=$ORACLE_BASE/product/10.2.0.1/db_1


   export PATH=$PATH:$ORACLE_HOME/bin


【10】.修改enterprise.rsp文件,在oracle安装目录下可以找到 vi database/response/enterprise.rsp


ORACLE_HOME="/home/oracle/product/10.2.0.1/db_1"


ORACLE_HOME_NAME="Oracle10g"


s_nameForDBAGrp="dba"


s_nameForOPERGrp="dba"


n_configurationOption=3


说明:


ORACLE_HOME Oracle服务器的主目录位置,必须是绝对路径。


ORACLE_HOME_NAME Oracle服务器的名称,必须以字母开头。


s_nameForDBAGrp 用于Oracle系统管理的linux用户组名,该组的用户拥有管理Oracle服务器的权限。


s_nameForOPERGrp 用于Oracle数据库常规操作的linux用户组名,该组的用户拥有常规操作Oracle数据库的权限。


n_configurationOption 安装类型(1为在安装后创建数据库,2为安装后创建一个自动存储管理实例,3为只安装服务器软件)。




【11】.开始安装


./runInstaller -ignoreSysPrereqs -silent -responseFile /home/oracle/database/response/enterprise.rsp


说明:


ignoreSysPrereqs 让Oracle忽略系统检查,因为Oracle官方声明只支持Linux服务器产品,所以要在非服务器产品的Linux上安装就必须指定此参数。


silent 让安装程序以静默模式运行。


responseFile 指定一个应答文件。


注意:如果ORACLE_HOME和ORACLE_BASE目录设在相同的位置,或者ORACLE_HOME所在目录不为空的话,会有如下错误:


SEVERE:OUI-10029:You have specified a non-empty directory to install this product. It is recommended to specify either an empty or a non-existent directory. You may, however, choose to ignore this message if the directory contains Operating System generated files or subdirectories like lost+found.


如果仍然要以当前配置安装的话,请在安装时添加-force参数进行强制安装。


【12】.oracle系统初始化


以root管理员运行$ORACLE_HOME/root.sh进行Oracle的系统初始化工作,通常一路按回车用默认值即可。


【13】.安装网络监听器


编辑oracle安装目录下的netca.rsp应答文件,地址为:/home/oracle/database/response/netca.rsp,主要查看以下参数配置:


INSTALL_TYPE=""custom"" 安装的类型


LISTENER_NUMBER=1 监听器数量


LISTENER_NAMES={"LISTENER"} 监听器的名称列表


LISTENER_PROTOCOLS={"TCP;1521"} 监听器使用的通讯协议列表


LISTENER_START=""LISTENER"" 监听器启动的名称


运行安装命令:


$ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/database/response/netca.rsp


注意:在此处可能会有错误oracle需要的软件包不全。请根据1中列出的软件包,确保所有的软件包都已经正确安装(2)6中对gennttab文件的修改不正确,本人就是没有去掉n后的空格导致了该错误。


【15】.修改dbstart

lsnrctl stop

vi $ORACLE_HOME/bin/dbstart


   ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle


改为:


   ORACLE_HOME_LISTNER=$ORACLE_HOME


确保数据库启动时,网络监听器同时启动。


【16】.安装数据库实例


编辑Oracle安装源文件夹response目录下的dbca.rsp应答文件:


vi /home/oracle/database/response/dbca.rsp


根据自己的需要修改下列参数:


GDBNAME  = “orcl10g”  #数据库全局名称


SID = “ora”  #数据库的SID


SYSPASSWORD = “sys”  # SYS用户的初始密码


SYSTEMPASSWORD = ”sys” #SYSTEM用户的初始密码


CHARACTERSET = “ZHS16GBK” #数据库字符集(中文为 ZHS16GBK)


NATIONALCHARACTERSET = ”ZHS16GBK” # 数据库国家字符集


运行安装命令:


$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/database/response/dbca.rsp -cloneTemplate


如果你要重建的实例和刚删除实例的实例名一样的话,删除

/etc/oratab文件最后一行。


数据库创建成功后需要修改一些信息:


vi /etc/oratab


ora10g:/home/oracle/product/10.2.0.1/db_1:N


改为:


ora10g:/home/oracle/product/10.2.0.1/db_1:Y


保证数据库实例能自动启动。


【17】.启动数据库实例


$ORACLE_HOME/bin/dbstart


【18】.测试


sqlplus "/as sysdba"


修改listener

vi /home/oracle/product/10.2.0.1/db_1/network/admin/listener.ora

SID_LIST_LISTENER =

 (SID_LIST =

   (SID_DESC =

     (SID_NAME = PLSExtProc)

     (ORACLE_HOME = /home/oracle/product/10.2.0.1/db_1)

     (PROGRAM = extproc)

   )

#增加下面的内容

   (SID_DESC =

     (GLOBAL_DBNAME = orcl10g.z.com)

     (ORACLE_HOME = /home/oracle/product/10.2.0.1/db_1)

     (SID_NAME = orcl10g)

   )

#^^^^^^^^^^^^^^^

 )

重启listener


【19】. 配置EM资料库,数据库和监听都必须已经启动并正常工作


配置dbcontrol


[oracle@oracle10 ~]$ emca -config dbcontrol db


STARTED EMCA at Oct 27, 2007 9:33:48 AM


EM Configuration Assistant, Version 10.2.0.1.0 Production


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


Enter the following information:


Database SID: orcl


Database Control is already configured for the database orcl


You have chosen to configure Database Control for managing the database orcl


This will remove the existing configuration and the default settings and perform a fresh configuration


Do you wish to continue? [yes(Y)/no(N)]: Y


Listener port number: 1521


Password for SYS user:


Password for DBSNMP user:


Password for SYSMAN user:


Email address for notifications (optional):


Outgoing Mail (SMTP) server for notifications (optional):


-----------------------------------------------------------------


You have specified the following settings


Database ORACLE_HOME ................ /opt/oracle/product/10.2.0/Database


Database hostname ................ oracle10


Listener port number ................ 1521


Database SID ................ orcl


Email address for notifications ...............


Outgoing Mail (SMTP) server for notifications ...............


-----------------------------------------------------------------


Do you wish to continue? [yes(Y)/no(N)]: Y


Oct 27, 2007 9:35:12 AM oracle.sysman.emcp.EMConfig perform


INFO: This operation is being logged at /opt/oracle/product/10.2.0/Database/cfgtoollogs/emca/orcl/emca_2007-10-27_09-33-46-AM.log.


Oct 27, 2007 9:35:33 AM oracle.sysman.emcp.util.DBControlUtil stopOMS


INFO: Stopping Database Control (this may take a while) ...


Oct 27, 2007 9:36:39 AM oracle.sysman.emcp.ParamsManager getLocalListener


WARNING: Error retrieving listener for oracle10


Oct 27, 2007 9:36:54 AM oracle.sysman.emcp.util.DBControlUtil startOMS


INFO: Starting Database Control (this may take a while) ...


Oct 27, 2007 9:39:51 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration


INFO: Database Control started successfully


Oct 27, 2007 9:39:53 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration


INFO: >>>>>>>>>>> The Database Control URL is http://oracle10:5500/em <<<<<<<<<<<


Enterprise Manager configuration completed successfully


FINISHED EMCA at Oct 27, 2007 9:39:53 AM


[oracle@oracle10 ~]$


删除数据库的 Database Control配置


[oracle@oracle10 ~]$ emca -deconfig dbcontrol db


STARTED EMCA at Oct 27, 2007 10:44:24 AM


EM Configuration Assistant, Version 10.2.0.1.0 Production


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


Enter the following information:


Database SID: orcl


Do you wish to continue? [yes(Y)/no(N)]: Y


Oct 27, 2007 10:44:47 AM oracle.sysman.emcp.EMConfig perform


INFO: This operation is being logged at /opt/oracle/product/10.2.0/Database/cfgtoollogs/emca/orcl/emca_2007-10-27_10-44-22-AM.log.


Oct 27, 2007 10:44:52 AM oracle.sysman.emcp.util.DBControlUtil stopOMS


INFO: Stopping Database Control (this may take a while) ...


Oct 27, 2007 10:48:13 AM oracle.sysman.emcp.EMReposConfig stopDBMSJobs


WARNING: Error initializing SQL connection. SQL operations cannot be performed


Oct 27, 2007 10:48:13 AM oracle.sysman.emcp.EMReposConfig invoke


WARNING: Unable to remove DBMS jobs.


Enterprise Manager configuration completed successfully


FINISHED EMCA at Oct 27, 2007 10:51:01 AM


[oracle@oracle10 ~]$


【20】.uninstall oracle if you want:


  ./runInstaller -silent -deinstall -removeallfiles -removeAllPatches "REMOVE_HOMES=/home/oracle/product/10.2.0.1" -responseFile /home/oracle/database/response/enterprise.rsp

  ./runInstaller -silent -deinstall -invPtrLoc /home/oracle/product/10.2.0.1/db_1/oraInst.loc -responseFile /home/oracle/database/response/enterprise.rsp


【21】常用命令

$oracle_home\admin\SID\bdump\alert.log


修改pfile后,创建spfile

SQL> shutdown immediate

SQL> create spfile from pfile='/home/oracle/product/10.2.0.1/db_1/dbs/initorcl10g.ora'

SQL> startup


1、启动数据库:

oracle@suse92:~> sqlplus /nolog


SQL*Plus: Release 9.2.0.4.0 - Production on Fri Jan 20 02:29:37 2006


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


SQL> connect /as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.


Total System Global Area 135352820 bytes

Fixed Size                   455156 bytes

Variable Size             109051904 bytes

Database Buffers           25165824 bytes

Redo Buffers                 679936 bytes

Database mounted.

2、关闭数据库:

oracle@suse92:~> sqlplus /nolog


SQL*Plus: Release 9.2.0.4.0 - Production on Fri Jan 20 02:29:37 2006


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


SQL> connect /as sysdba

Connected to an idle instance.

SQL> shutdwon abort;

3、启动监听器

oracle@suse92:~> lsnrctl start

4、停止监听器

oracle@suse92:~> lsnrctl stop

5、查看监听器状态

  oracle@suse92:~> lsnrctl

  LSNRCTL> status

  LSNRCTL> exit