本文档是Oracle Database 11.2.0.1 for RHEL5 Server(包括x86和x86_64平台)的静默安装指南. 所有操作无需使用图形界面. 静默安装能减少安装出错的可能性, 也能大大加快安装速度.
# 后跟命令表示以操作系统下root用户操作;
$ 后跟命令表示以操作系统下oracle用户操作;
1.1 上传软件
假如放在/wangnc/oracle/11g/目录下.
# mkdir -p /wangnc/oracle/11g/
# cd /wangnc/oracle/11g/
可通过SecureFX工具sftp上传数据库安装文件.
1.2 Package安装检查
# rpm -q \
binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel | grep "not installed"
1.3 增加数据库组和用户
# id oracle (确认oracle用户是否存在)
# /usr/sbin/groupadd oinstall (建立产品清单管理组)
# /usr/sbin/groupadd dba (建立数据库安装组)
# /usr/sbin/groupadd asmadmin (建立ASM管理组)
# /usr/sbin/groupadd asmdba (建立Grid管理组)
# /usr/sbin/useradd -g oinstall -G dba,asmdba oracle -d /home/oracle (oinstall为主要组,确保/home/oracle原不存在)
# id oracle (记住oracle用户的uid和gid)
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),504(asmdba)
# passwd oracle
1.4 调整OS内核参数
设置原则:
kernel.shmmax 为 4GB-1byte或一半的物理内存, 哪个值更低用哪个;
fs.file-max 为512 * PROCESSES.
# vi /etc/sysctl.conf (增加或修改以下参数, 参考值为最小需求, kernel.shmmax默认即可无需设置 )
#------------------------------------------
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
#kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
#------------------------------------------
# /sbin/sysctl -p (设置参数立即生效)
1.5 增加shell限制
为了提升性能增加oracle用户的shell限制.
# vi /etc/security/limits.conf (在文件最后增加或修改以下参数)
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
# vi /etc/pam.d/login (在文件最后增加或修改以下参数)
session required pam_limits.so
# 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
1.6 建立必需目录
# more /etc/oratab (确认原来是否存在Oracle主目录)
# more /etc/oraInst.loc (确认原来是否存在Oracle产品清单目录)
# mkdir -p /u01/app/oracle/ (Oracle基础目录, 一般为/mount_point/app/oracle_owner)
# chown -R oracle:oinstall /wangnc/oracle
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /u02
chown -R oracle:oinstall /u03
chown -R oracle:oinstall /u04
# chmod -R 775 /wangnc/oracle
chmod -R 775 /u01
chmod -R 775 /u02
chmod -R 775 /u03
chmod -R 775 /u04
1.7 设置oracle用户环境变量
如果服务器有多网卡, 注意设置ORACLE_HOSTNAME为某网卡IP对应的主机名, 参照/etc/hosts文件.
# su - oracle
$ vi ~/.bash_profile
umask 022
export ORACLE_HOSTNAME=rhel5
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
$ . ~/.bash_profile
1.8 解压Oracle安装文件
$ cd /wangnc/oracle/11g
$ unzip linux*_11gR2_database_1of2.zip -d /u01 (解压到/u01目录下,可选目录)
$ unzip linux*_11gR2_database_2of2.zip -d /u01
$ cd /u01/database
$ export DISTRIB=`pwd`
在解压后oracle软件的response目录里有各种响应文件的模版.
1.9 生成响应文件模板
1) 方法一(推荐)
$ vi $DISTRIB/db_swonly.rsp
#--------------------------------------------------------------------
#以下参数不要更改
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
#以下参数根据实际情况更改,一般也无需更改
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.customComponents=oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
#--------------------------------------------------------------------
各参数含义如下:
-silent 表示以静默方式安装,不会有任何提示
-force 允许安装到一个非空目录
-noconfig 表示不运行配置助手netca
-responseFile 表示使用哪个响应文件,必需使用绝对路径
oracle.install.responseFileVersion 响应文件模板的版本,该参数不要更改
oracle.install.option 安装选项,本例只安装oracle软件,该参数不要更改
DECLINE_SECURITY_UPDATES 是否需要在线安全更新,设置为false,该参数不要更改
ORACLE_HOSTNAME 安装主机名
UNIX_GROUP_NAME oracle用户用于安装软件的组名
INVENTORY_LOCATION oracle产品清单目录
SELECTED_LANGUAGES oracle运行语言环境,一般包括引文和简繁体中文
ORACLE_HOME Oracle安装目录
ORACLE_BASE oracle基础目录
oracle.install.db.InstallEdition 安装版本类型,一般是企业版
oracle.install.db.isCustomInstall 是否定制安装,默认Partitioning,OLAP,RAT都选上了
oracle.install.db.customComponents 定制安装组件列表:除了以上默认的,可加上Label Security和Database Vault
oracle.install.db.DBA_GROUP oracle用户用于授予OSDBA权限的组名
oracle.install.db.OPER_GROUP oracle用户用于授予OSOPER权限的组名
2) 方法二(图形界面)
$ ./runInstaller &
一步步设置到Summary页, 然后点击Save Response File按钮, 选择合适的存放路径并Finish后, 回到Summary页, 点击Cancel退出OUI.
1.10 开始安装oracle软件
1) 通过response文件静默安装, 大概2-3分钟:
$ ./runInstaller -silent -force -noconfig -responseFile $DISTRIB/db_swonly.rsp
控制台直到出现以下提示则表示安装完成:
#-------------------------------------------------------------------
...
/u01/app/oracle/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
#-------------------------------------------------------------------
2) 安装期间查看安装日志信息了解安装进度:
$ cd $ORACLE_BASE/oraInventory/logs
$ tail -100f installActions*.log
3) 安装的软件信息会写入inventory.xml文件, 如果需重运行则把该文件的对应安装条目信息删除即可:
$ vi $ORACLE_BASE/oraInventory/ContentsXML/inventory.xml
1.11 运行orainstRoot.sh和root.sh
若本机第一次安装oracle软件, 则执行orainstRoot.sh来建立oraInst.loc文件和修改权限:
$ su -
# /u01/app/oracle/oraInventory/orainstRoot.sh
# more /etc/oraInst.loc
执行$ORACLE_HOME下的root.sh来建立oratab,dbhome,oraenv,coraenv文件, 如果提示则一直回车:
# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
# more /etc/oratab
1.1 静默配置监听
通过response文件运行netca, 生成sqlnet.ora和listener.ora文件, 位于$ORACLE_HOME/network/admin目录下:
# su - oracle
$ $ORACLE_HOME/bin/netca /silent /responsefile $DISTRIB/response/netca.rsp
$ ll $ORACLE_HOME/network/admin/*.ora
$ lsnrctl status
执行完后, 监听就已经启动了, 默认端口是1521, 默认是动态监听, 只要实例启动了就会监听到.
1.2 静默建库
1) 生成响应文件模板:
$ vi $DISTRIB/db_create.rsp
#--------------------------------------------------------------------
#以下参数不要更改
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
#以下参数必须设置
[CREATEDATABASE]
GDBNAME = "ORCL.LK"
TEMPLATENAME = "General_Purpose.dbc"
#以下参数不设置则使用默认值,建议设置
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1024"
#--------------------------------------------------------------------
2) dbca静默建库, 大概3-4分钟:
种子数据库和控制文件位于$ORACLE_HOME/assistants/dbca/templates/下, 即Seed_Database.dfb和Seed_Database.ctl文件, 实际上建库就是基于通过rman恢复种子数据库和控制文件来实现的.
$ $ORACLE_HOME/bin/dbca -silent -responseFile $DISTRIB/db_create.rsp
Enter SYS user password:
<输入sys用户密码>
Enter SYSTEM user password:
<输入system用户密码>
Copying database files
...
37% complete
Creating and starting Oracle instance
...
62% complete
Completing Database Creation
...
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ORCL/ORCL.log" for further details.
各参数含义如下:
-silent 表示以静默方式安装
-responseFile 表示使用哪个响应文件,必需使用绝对路径
RESPONSEFILE_VERSION 响应文件模板的版本,该参数不要更改
OPERATION_TYPE 安装类型,该参数不要更改
GDBNAME 全局数据库名,点号前面默认是db_name,点号后面默认就是db_domain
TEMPLATENAME 建库模板名,参考各模板定义:$ORACLE_HOME/assistants/dbca/templates/*.dbc
CHARACTERSET 字符集,默认是WE8MSWIN1252
TOTALMEMORY 实例内存,默认是服务器物理内存的40%
3) 安装期间查看日志信息了解进度:
$ tail -100f $ORACLE_BASE/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log
4) 建库后实例检查
$ ps -ef | grep ora_ | grep -v grep | wc -l
21
$ ps -ef | grep ora_ | grep -v grep
oracle 1855 1 0 10:07 ? 00:00:00 ora_pmon_ORCL
oracle 1857 1 0 10:07 ? 00:00:00 ora_vktm_ORCL
oracle 1861 1 0 10:07 ? 00:00:00 ora_gen0_ORCL
oracle 1863 1 0 10:07 ? 00:00:00 ora_diag_ORCL
oracle 1865 1 0 10:07 ? 00:00:00 ora_dbrm_ORCL
oracle 1867 1 0 10:07 ? 00:00:00 ora_psp0_ORCL
oracle 1869 1 0 10:07 ? 00:00:00 ora_dia0_ORCL
oracle 1871 1 0 10:07 ? 00:00:00 ora_mman_ORCL
oracle 1873 1 0 10:07 ? 00:00:00 ora_dbw0_ORCL
oracle 1875 1 0 10:07 ? 00:00:00 ora_lgwr_ORCL
oracle 1877 1 0 10:07 ? 00:00:00 ora_ckpt_ORCL
oracle 1879 1 0 10:07 ? 00:00:00 ora_smon_ORCL
oracle 1881 1 0 10:07 ? 00:00:00 ora_reco_ORCL
oracle 1883 1 0 10:07 ? 00:00:00 ora_mmon_ORCL
oracle 1885 1 0 10:07 ? 00:00:00 ora_mmnl_ORCL
oracle 1887 1 0 10:07 ? 00:00:00 ora_d000_ORCL
oracle 1889 1 0 10:07 ? 00:00:00 ora_s000_ORCL
oracle 1969 1 0 10:07 ? 00:00:00 ora_qmnc_ORCL
oracle 1985 1 0 10:07 ? 00:00:00 ora_cjq0_ORCL
oracle 2003 1 0 10:08 ? 00:00:00 ora_q000_ORCL
oracle 2005 1 0 10:08 ? 00:00:00 ora_q001_ORCL
5) 建库后监听检查
$ lsnrctl status
...
Services Summary...
Service "ORCL.LK" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCLXDB.LK" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
The command completed successfully
实例应该被动态注册到监听程序了. 如果未被动态注册到监听程序, 则可以手工注册:
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 16 11:11:46 2009
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> alter system register;
6) 改为归档模式并重启
$ sqlplus / as sysdba
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database flashback on; (如果要启用数据库闪回功能则执行)
SQL> alter database open;
SQL> execute utl_recomp.recomp_serial(); (重新编译所有可能失效对象)
SQL> alter system archive log current; (手工归档测试)
到此建库完毕!
7) 默认安装的数据库用户:
SQL> set lines 256 pages 500
SQL> select USER_ID,USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE from dba_users order by 1;
USER_ID USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE
---------- ------------------------------ -------------------------------- ------------------------------
0 SYS OPEN SYSTEM
5 SYSTEM OPEN SYSTEM
9 OUTLN EXPIRED & LOCKED SYSTEM
14 DIP EXPIRED & LOCKED USERS
21 ORACLE_OCM EXPIRED & LOCKED USERS
30 DBSNMP EXPIRED & LOCKED SYSAUX
31 APPQOSSYS EXPIRED & LOCKED SYSAUX
32 WMSYS EXPIRED & LOCKED SYSAUX
42 EXFSYS EXPIRED & LOCKED SYSAUX
43 CTXSYS EXPIRED & LOCKED SYSAUX
45 XDB EXPIRED & LOCKED SYSAUX
46 ANONYMOUS EXPIRED & LOCKED SYSAUX
53 ORDSYS EXPIRED & LOCKED SYSAUX
54 ORDDATA EXPIRED & LOCKED SYSAUX
55 ORDPLUGINS EXPIRED & LOCKED SYSAUX
56 SI_INFORMTN_SCHEMA EXPIRED & LOCKED SYSAUX
57 MDSYS EXPIRED & LOCKED SYSAUX
61 OLAPSYS EXPIRED & LOCKED SYSAUX
65 MDDATA EXPIRED & LOCKED USERS
67 SPATIAL_WFS_ADMIN_USR EXPIRED & LOCKED USERS
70 SPATIAL_CSW_ADMIN_USR EXPIRED & LOCKED USERS
72 SYSMAN EXPIRED & LOCKED SYSAUX
74 MGMT_VIEW EXPIRED & LOCKED SYSTEM
75 FLOWS_FILES EXPIRED & LOCKED SYSAUX
76 APEX_PUBLIC_USER EXPIRED & LOCKED USERS
78 APEX_030200 EXPIRED & LOCKED SYSAUX
79 OWBSYS EXPIRED & LOCKED SYSAUX
83 OWBSYS_AUDIT EXPIRED & LOCKED SYSAUX
84 SCOTT EXPIRED & LOCKED USERS
2147483638 XS$NULL EXPIRED & LOCKED USERS
30 rows selected.
8) 默认安装的组件:
SQL> col COMP_ID format a8
col COMP_NAME format a35
col VERSION format a12
col schema format a12
col OTHER_SCHEMAS format a45
SQL> select comp_id,comp_name,version,schema,other_schemas from dba_registry order by 1;
COMP_ID COMP_NAME VERSION SCHEMA OTHER_SCHEMAS
-------- ----------------------------------- ------------ ------------ ---------------------------------------------
AMD OLAP Catalog 11.2.0.1.0 OLAPSYS
APEX Oracle Application Express 3.2.1.00.10 APEX_030200 FLOWS_FILES
APS OLAP Analytic Workspace 11.2.0.1.0 SYS
CATALOG Oracle Database Catalog Views 11.2.0.1.0 SYS
CATJAVA Oracle Database Java Packages 11.2.0.1.0 SYS
CATPROC Oracle Database Packages and Types 11.2.0.1.0 SYS APPQOSSYS,DBSNMP,DIP,ORACLE_OCM,OUTLN,SYSTEM
CONTEXT Oracle Text 11.2.0.1.0 CTXSYS
EM Oracle Enterprise Manager 11.2.0.1.0 SYSMAN
EXF Oracle Expression Filter 11.2.0.1.0 EXFSYS
JAVAVM JServer JAVA Virtual Machine 11.2.0.1.0 SYS
ORDIM Oracle Multimedia 11.2.0.1.0 ORDSYS MDSYS,ORDDATA,ORDPLUGINS,SI_INFORMTN_SCHEMA
OWB OWB 11.2.0.1.0 OWBSYS
OWM Oracle Workspace Manager 11.2.0.1.0 WMSYS
RUL Oracle Rules Manager 11.2.0.1.0 EXFSYS
SDO Spatial 11.2.0.1.0 MDSYS
XDB Oracle XML Database 11.2.0.1.0 XDB ANONYMOUS,XS$NULL
XML Oracle XDK 11.2.0.1.0 SYS
XOQ Oracle OLAP API 11.2.0.1.0 SYS
18 rows selected.
1.3 静默删库(可选)
1) 生成响应文件模板:
$ vi $DISTRIB/db_delete.rsp
#--------------------------------------------------------------------
#以下参数不能更改
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "deleteDatabase"
#以下参数根据实际情况更改
[DELETEDATABASE]
SOURCEDB = "ORCL"
#--------------------------------------------------------------------
2) dbca静默建库, 无需手工停库, 大概1分钟:
$ $ORACLE_HOME/bin/dbca -silent -responseFile $DISTRIB/db_delete.rsp
Connecting to database
...
47% complete
Updating network configuration files
...
52% complete
Deleting instance and datafiles
...
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ORCL.log" for further details.
各参数含义如下:
-silent 表示以静默方式删除
-responseFile 表示使用哪个响应文件,必需使用绝对路径
RESPONSEFILE_VERSION 响应文件模板的版本,该参数不要更改
OPERATION_TYPE 安装类型,该参数不要更改
SOURCEDB 数据库名,不是全局数据库名,即不包含db_domain
3) 删除期间查看日志信息了解进度:
$ tail -100f $ORACLE_BASE/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log