frankfan126 发表于 2011-12-22 08:54

Oracle 11.2.0.1 for RHEL5-6 x86和x64静默安装

<DIV>本文档是Oracle Database 11.2.0.1 for RHEL5 RHEL6 Server(包括x86和x86_64平台)的静默安装指南. 所有操作无需使用图形界面. 静默安装能减少安装出错的可能性, 也能大大加快安装速度.</DIV>
<DIV># 后跟命令表示以操作系统下root用户操作; <BR>$ 后跟命令表示以操作系统下oracle用户操作; <BR>禁用selinux<BR>setenforce 0<BR>vi /etc/sysconfig/seliunx<BR>SELINUX=disabled<BR>关闭防火墙:<BR>service iptables stop</DIV>
<DIV>禁用以下非必要的系统服务:<BR>chkconfig --level 2345 iptables off<BR>chkconfig --level 2345 rhnsd off<BR>&nbsp;chkconfig --level 2345 isdn off <BR>&nbsp;chkconfig --level 2345 avahi-daemon off<BR>&nbsp;chkconfig --level 2345 avahi-dnsconfd off<BR>&nbsp;chkconfig --level 2345 bluetooth off<BR>&nbsp;chkconfig --level 2345 cpuspeed off<BR>&nbsp;chkconfig --level 2345 hidd off<BR>&nbsp;chkconfig --level 2345 ip6tables off<BR>&nbsp;chkconfig --level 2345 mcstrans off<BR>&nbsp;chkconfig --level 2345 pcscd off<BR>&nbsp;chkconfig --level 2345 gpm off<BR>&nbsp;chkconfig --level 2345 xinetd off<BR>&nbsp;chkconfig --level 2345 portmap off<BR>&nbsp;chkconfig --level 2345 yum-updatesd&nbsp; off<BR>&nbsp;chkconfig --level 2345 restorecond&nbsp;&nbsp; off<BR>&nbsp;chkconfig --level 2345 setroubleshoot&nbsp;&nbsp; off<BR>&nbsp;chkconfig --level 2345 yum-updatesd&nbsp;&nbsp; off<BR>&nbsp;chkconfig --level 2345 libvirtd off<BR>&nbsp;chkconfig --level 2345 xendomains off<BR>&nbsp;chkconfig --level 2345 xend off<BR>&nbsp;chkconfig --level 2345 iptables off<BR>&nbsp;chkconfig --level 2345 sendmail off<BR>&nbsp;chkconfig --level 2345 cups off</DIV>
<DIV>将/dev/shm的大小增加到总内存的100%(要大于给oracle分配的total mem:缺省值:40%),<BR>修改/etc/fstab的这行:<BR>默认的: <BR>none&nbsp;&nbsp;&nbsp;&nbsp; /dev/shm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp; defaults&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 0<BR>改成: <BR>none&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /dev/shm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp; defaults,size=16G&nbsp;&nbsp; 0 0<BR>重新mount /dev/shm使之生效:<BR># mount -o remount /dev/shm</DIV>
<DIV><BR>马上可以用"df -h"命令检查变化。<BR>1.2 Package安装检查<BR># 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&nbsp; sysstat unixODBC unixODBC-devel | grep "not installed"</DIV>
<DIV>libaio-devel sysstat unixODBC unixODBC-devel 几个rpm包可以在RHEL5.3的安装光盘里找到<BR>&nbsp;注意:除了sysstat包,其他同样名字的32位的rpm包在64位系统中也要安装</DIV>
<DIV>1.3 增加数据库组和用户<BR># id oracle (确认oracle用户是否存在,确保oracle原不存在)(建立产品清单管理组) (建立数据库安装组) (建立ASM管理组) (建立Grid管理组)</DIV>
<DIV>/usr/sbin/groupadd -g 1001 oinstall <BR>/usr/sbin/groupadd -g 1002 dba <BR>/usr/sbin/groupadd -g 1003 asmadmin<BR>/usr/sbin/groupadd&nbsp; -g 1004 asmdba</DIV>
<DIV>(oinstall主要组,确保/home/oracle原不存在),配置oracle密码:georacle<BR>/usr/sbin/useradd -g oinstall -G dba,asmdba oracle -d /home/oracle&nbsp; <BR>passwd oracle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>id oracle </DIV>
<DIV>uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba),1004(asmdba)</DIV>
<DIV><BR>1.4 调整OS内核参数</DIV>
<DIV><BR>设置原则:</DIV>
<DIV>kernel.shmmax设为物理内存大小(如果系统已设置了足够大就无需再设置了, 参考值为最小需求,)</DIV>
<DIV># vi /etc/sysctl.conf <BR>#------------------------------------------<BR>kernel.shmall = 2097152</DIV>
<DIV>kernel.shmmax = 536870912</DIV>
<DIV>kernel.shmmni = 4096</DIV>
<DIV>kernel.sem = 250 32000 100 128</DIV>
<DIV>fs.aio-max-nr = 1048576</DIV>
<DIV>fs.file-max = 6815744</DIV>
<DIV>fs.aio-max-nr = 1048576</DIV>
<DIV>net.ipv4.ip_local_port_range = 9000 65500</DIV>
<DIV>net.core.rmem_default = 262144</DIV>
<DIV>net.core.rmem_max = 4194304</DIV>
<DIV>net.core.wmem_default = 262144</DIV>
<DIV>net.core.wmem_max = 1048586</DIV>
<DIV>#------------------------------------------</DIV>
<DIV># /sbin/sysctl -p (设置参数立即生效)</DIV>
<DIV><BR>如果有如下提示错误,忽略,因为即使未修改参数也提示有这个错误</DIV>
<DIV>error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key</DIV>
<DIV>error: "net.bridge.bridge-nf-call-iptables" is an unknown key</DIV>
<DIV>error: "net.bridge.bridge-nf-call-arptables" is an unknown key</DIV>
<DIV><BR>vi /etc/redhat-release,修改为如下值,成功安装数据库后在修改回来:</DIV>
<DIV>Red Hat Enterprise Linux Server release 5.0 (Tikanga)</DIV>
<DIV></DIV>
<DIV><BR>1.5 增加shell限制</DIV>
<DIV><BR>为了提升性能增加oracle用户的shell限制.</DIV>
<DIV># vi /etc/security/limits.conf&nbsp; (在文件最后增加或修改以下参数)</DIV>
<DIV>oracle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soft&nbsp;&nbsp;&nbsp; nproc&nbsp;&nbsp; 2047<BR>oracle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hard&nbsp;&nbsp;&nbsp; nproc&nbsp;&nbsp; 16384<BR>oracle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soft&nbsp;&nbsp;&nbsp; nofile&nbsp; 1024<BR>oracle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hard&nbsp;&nbsp;&nbsp; nofile&nbsp; 65536</DIV>
<DIV># vi /etc/pam.d/login&nbsp; (在文件最后增加或修改以下参数)</DIV>
<DIV>session&nbsp;&nbsp;&nbsp; required&nbsp;&nbsp;&nbsp;&nbsp; pam_limits.so</DIV>
<DIV># vi /etc/profile&nbsp; (在文件最后增加或修改以下脚本)</DIV>
<DIV>if [ $USER = "oracle" ]; then</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if [ $SHELL = "/bin/ksh" ]; then</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulimit -p 16384</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulimit -n 65536</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulimit -u 16384 -n 65536</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi</DIV>
<DIV>fi</DIV>
<DIV>1.6 建立必需目录和文件</DIV>
<DIV>&nbsp;more /etc/oratab (确认原来不存在Oracle主目录)</DIV>
<DIV>&nbsp;more /etc/oraInst.loc (确认原来不存在Oracle产品清单目录)<BR>建立(Oracle_base目录)</DIV>
<DIV>mkdir -p /opt/oracle/11.2.0 /home/oracle/inventory/<BR>chown -R oracle:oinstall /opt/oracle /home/oracle</DIV>
<DIV><BR>1.7 设置oracle用户环境变量</DIV>
<DIV><BR>如果服务器有多网卡, 注意设置ORACLE_HOSTNAME为某网卡IP对应的主机名, 参照/etc/hosts文件.<BR>&nbsp;</DIV>
<DIV>$ vi /home/oracle/.bash_profile</DIV>
<DIV>umask 022<BR>ORACLE_HOSTNAME=localhost.localdomain<BR>ORACLE_BASE=/opt/oracle<BR>ORACLE_HOME=$ORACLE_BASE/11.2.0<BR>ORACLE_SID=ge01<BR>PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH<BR>LC_ALL="en_US"<BR>LANG="en_US"<BR>NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"<BR>NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"<BR>LD_LIBRARY_PATH=$ORACLE_HOME/lib<BR>NLS_LANG NLS_DATE_FORMAT<BR>export ORACLE_HOSTNAME ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LC_ALL LANG LD_LIBRARY_PATH NLS_LANG</DIV>
<DIV><BR>1.8 上传软件到/home/oracle/ 解压Oracle安装文件</DIV>
<DIV><BR># cd /home/oracle/</DIV>
<DIV># unzip linux*_11gR2_database_1of2.zip -d /home/oracle </DIV>
<DIV># unzip linux*_11gR2_database_2of2.zip -d /home/oracle</DIV>
<DIV># chown -R oracle:oinstall /opt/oracle /home/oracle</DIV>
<DIV><BR>在解压后oracle软件的response目录里有各种响应文件的模版.</DIV>
<DIV>1.9 生成响应文件模板</DIV>
<DIV><BR>1) 方法一(推荐)</DIV>
<DIV>$ vi /home/oracle/database/response/db_install.rsp</DIV>
<DIV>#--------------------------------------------------------------------</DIV>
<DIV># 注意!不要更改以下参数,否则安装会报错!</DIV>
<DIV>oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0</DIV>
<DIV>DECLINE_SECURITY_UPDATES=true</DIV>
<DIV><BR>#以下参数根据实际情况更改,ORACLE_HOSTNAME的值由hostname命令获得<BR>ORACLE_HOSTNAME=localhost.localdomain</DIV>
<DIV>INVENTORY_LOCATION=/home/oracle/inventory</DIV>
<DIV>UNIX_GROUP_NAME=oinstall</DIV>
<DIV>SELECTED_LANGUAGES=en,zh_CN</DIV>
<DIV>oracle.install.db.InstallEdition=EE</DIV>
<DIV>oracle.install.db.DBA_GROUP=dba</DIV>
<DIV>oracle.install.db.OPER_GROUP=dba</DIV>
<DIV>#--------------------------------------------------------------------</DIV>
<DIV>各参数含义如下:</DIV>
<DIV>-silent 表示以静默方式安装,不会有任何提示</DIV>
<DIV>-force 允许安装到一个非空目录</DIV>
<DIV>-noconfig 表示不运行配置助手netca</DIV>
<DIV>-responseFile 表示使用哪个响应文件,必需使用绝对路径</DIV>
<DIV>oracle.install.responseFileVersion 响应文件模板的版本,该参数不要更改</DIV>
<DIV>oracle.install.option 安装选项,本例只安装oracle软件,</DIV>
<DIV>DECLINE_SECURITY_UPDATES 是否需要在线安全更新,该参数不要更改</DIV>
<DIV>ORACLE_HOSTNAME 安装主机名</DIV>
<DIV>UNIX_GROUP_NAME oracle用户用于安装软件的组名</DIV>
<DIV>INVENTORY_LOCATION oracle产品清单目录</DIV>
<DIV>SELECTED_LANGUAGES oracle运行语言环境,一般选en,zh_CN</DIV>
<DIV>ORACLE_HOME Oracle安装目录</DIV>
<DIV>ORACLE_BASE oracle基础目录</DIV>
<DIV>oracle.install.db.InstallEdition 安装版本类型,一般是企业版</DIV>
<DIV>oracle.install.db.isCustomInstall 是否定制安装,默认Partitioning,OLAP,RAT都选上了</DIV>
<DIV>oracle.install.db.customComponents 定制安装组件列表:除了以上默认的,可加上Label Security和Database Vault</DIV>
<DIV>oracle.install.db.DBA_GROUP oracle用户用于授予OSDBA权限的组名</DIV>
<DIV>oracle.install.db.OPER_GROUP oracle用户用于授予OSOPER权限的组名</DIV>
<DIV><BR>1.10 开始安装oracle软件</DIV>
<DIV><BR>1) 通过response文件静默安装, 大概2-3分钟:</DIV>
<DIV>$ ./runInstaller -silent -force -noconfig -responseFile /home/oracle/db_install.rsp</DIV>
<DIV>控制台直到出现以下提示则表示安装完成:</DIV>
<DIV>#-------------------------------------------------------------------</DIV>
<DIV>...</DIV>
<DIV>/opt/oracle/oraInventory/orainstRoot.sh</DIV>
<DIV>/opt/oracle/product/11.2.0/dbhome_1/root.sh</DIV>
<DIV>To execute the configuration scripts:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1. Open a terminal window </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2. Log in as "root" </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3. Run the scripts </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4. Return to this window and hit "Enter" key to continue </DIV>
<DIV><BR>Successfully Setup Software.</DIV>
<DIV>#-------------------------------------------------------------------</DIV>
<DIV>2) 安装期间查看安装日志信息了解安装进度:</DIV>
<DIV>$ cd $ORACLE_BASE/oraInventory/logs</DIV>
<DIV>$ tail -100f installActions*.log</DIV>
<DIV>3) 安装的软件信息会写入inventory.xml文件, 如果需重运行则把该文件的对应安装条目信息删除即可:<BR>$ vi $ORACLE_BASE/oraInventory/ContentsXML/inventory.xml</DIV>
<DIV>1.11 运行orainstRoot.sh和root.sh</DIV>
<DIV>若本机第一次安装oracle软件, 则执行orainstRoot.sh来建立oraInst.loc文件和修改权限:</DIV>
<DIV>$ su -</DIV>
<DIV># /opt/oracle/oraInventory/orainstRoot.sh</DIV>
<DIV># more /etc/oraInst.loc</DIV>
<DIV>执行$ORACLE_HOME下的root.sh来建立oratab,dbhome,oraenv,coraenv文件, 如果提示则一直回车:</DIV>
<DIV># /opt/oracle/11.2.0/root.sh</DIV>
<DIV># more /etc/oratab</DIV>
<DIV>2.1 静默配置监听</DIV>
<DIV>通过response文件运行netca, 生成sqlnet.ora和listener.ora文件, 位于$ORACLE_HOME/network/admin目录下:</DIV>
<DIV># su - oracle</DIV>
<DIV>$ $ORACLE_HOME/bin/netca /silent /responsefile /home/oracle/netca.rsp</DIV>
<DIV>$ ll $ORACLE_HOME/network/admin/*.ora</DIV>
<DIV>$ lsnrctl status</DIV>
<DIV>执行完后, 监听就已经启动了, 默认端口是1521, 默认是动态监听, 只要实例启动了就会监听到.</DIV>
<DIV>3.1 静默建库</DIV>
<DIV>1) 生成响应文件模板:<BR>$ vi /home/oracle/dbca.rsp</DIV>
<DIV>#以下参数不要更改</DIV>
<DIV></DIV>
<DIV>RESPONSEFILE_VERSION = "11.2.0"<BR>OPERATION_TYPE = "createDatabase"</DIV>
<DIV><BR>TEMPLATENAME = "General_Purpose.dbc"</DIV>
<DIV>#以下参数必须设置</DIV>
<DIV><BR>GDBNAME = "ge01"<BR>SID = "ge01"<BR>SYSPASSWORD = "georacle"<BR>SYSTEMPASSWORD = "georacle"<BR>EMCONFIGURATION = "LOCAL"<BR>DBSNMPPASSWORD = "georacle"<BR>CHARACTERSET = " ZHS16GBK"<BR>MEMORYPERCENTAGE = "40"</DIV>
<DIV>安装数据库的命令:<BR>dbca -silent -responseFile /home/oracle/dbca.rsp</DIV>
<DIV>修改其他配置文件<BR>vi /etc/oratab&nbsp; 修改文件中第三列N为Y</DIV>
<DIV>修改$ORACLE_HOME/bin/dbstart文件中ORACLE_HOME_LITENER=${ORACLE_HOME}<BR>(同样,也需要修改 dbshut )后,可以手动运行dbstart文件,来测试是否可以正确启动oracle11g</DIV>
<DIV>首先以root身份在/etc/init.d/目录下创建Oracle11g的服务文件。<BR>vi /etc/init.d/oracle11g</DIV>
<DIV>然后修改这个文件内容如下:<BR># !/bin/bash<BR># chkconfig: 345 51 49 <BR># description: starts the oracle dabase deamons<BR>#<BR>ORACLE_HOME=/opt/oracle/11.2.0<BR>ORACLE_OWNER=oracle<BR>ORACLE_DESC="Oracle 11g"<BR>ORACLE_LOCK=/opt/oracle/oracle.lock</DIV>
<DIV>case "$1" in<BR>'start')<BR>echo -n \"Starting ${ORACLE_DESC}:\"<BR>runuser - $ORACLE_OWNER -c '$ORACLE_HOME/bin/dbstart'<BR>touch ${ORACLE_LOCK}<BR>echo<BR>;;<BR>'stop')<BR>echo -n "shutting down ${ORACLE_DESC}: "<BR>runuser - $ORACLE_OWNER -c '$ORACLE_HOME/bin/dbshut'<BR>rm -f ${ORACLE_LOCK}<BR>echo<BR>;;<BR>'restart')<BR>echo -n "restarting ${ORACLE_DESC}:"<BR>$0 stop<BR>$0 start<BR>echo<BR>;;<BR>*)<BR>echo "usage: $0 { start | stop | restart }"<BR>exit 1<BR>esac<BR>exit 0</DIV>
<DIV>chmod 744 /etc/init.d/oracle11g</DIV>
<DIV>配置自动启动oracle服务<BR>chkconfig --level 35 oracle11g on</DIV>
<DIV>按照平台使用要求设置oracle<BR>$sqlplus / as sysdba</DIV>
<DIV>将密码有效期由默认的180天修改成“无限制”:增加users表空间文件,调整参数。<BR>ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;</DIV>
<DIV>alter database add logfile '/opt/oracle/oradata/ge01/redo04.log' size 150M;<BR>alter database add logfile '/opt/oracle/oradata/ge01/redo05.log' size 150M;<BR>alter database add logfile '/opt/oracle/oradata/ge01/redo06.log' size 150M;<BR>&nbsp;<BR>alter tablespace users&nbsp; add datafile&nbsp;&nbsp;&nbsp; '/opt/oracle/oradata/ge01/users02.dbf' size 100M&nbsp; autoextend on next 10M;<BR>&nbsp;<BR>alter tablespace users&nbsp; add datafile '/opt/oracle/oradata/ge01/users03.dbf' size 100M&nbsp; autoextend on next 10M;</DIV>
<DIV>alter system set open_cursors = 500 scope=spfile; <BR>alter system set processes=350 scope=spfile; <BR>alter system set sessions=350 scope=spfile;</DIV>
<DIV>alter system set db_writer_processes=3 scope=spfile;<BR>alter system set max_dump_file_size='1024m' scope=both;<BR></DIV>
<DIV>重启oracle生效<BR>shutdown immediate<BR>startup<BR>-----------------------------------------------------------------------<BR>删除oracle 安装<BR>&nbsp;<BR>静默删除数据库文件<BR>vi /home/oracle/dbca.rsp<BR>#以下参数必须设置<BR><BR>OPERATION_TYPE = "deleteDatabase"</DIV>
<DIV><BR>SOURCEDB = "ge01"</DIV>
<DIV>&nbsp;dbca -silent -deleteDatabase -responseFile /home/oracle/dbca.rsp</DIV>
<DIV>或者使用oracle 的deinstall工具删除数据库程序文件:</DIV>
<DIV>&nbsp;deinstall -home /opt/oracle/11.2.0</DIV>
<DIV>-----------------END---------------------<BR></DIV>
页: [1]
查看完整版本: Oracle 11.2.0.1 for RHEL5-6 x86和x64静默安装