Linux下的ORACLE安装,成功率99.99999%
相信很多童鞋都有过在Linux上安装Oracle数据库的痛苦经历,其中绝大多数都是环境设置的问题。我给大家推荐一个国外大牛写的Oracle的安装脚本? OTK,是用Bash写的,这东东大大简化了Oracle安装过程,而且成功率达到99.9999%以上,只要确保你的Linux系统是干净
相信很多童鞋都有过在Linux上安装Oracle数据库的痛苦经历,其中绝大多数都是环境设置的问题。我给大家推荐一个国外大牛写的Oracle的安装脚本? OTK,是用Bash写的,这东东大大简化了Oracle安装过程,而且成功率达到99.9999%以上,只要确保你的Linux系统是干净的,那么按照这个教程,保证你会安装成功。
准备工作
OTK针对各种Linux提供了? 安装文档,本文使用的RHEL5.5_x86_64位,数据库版本为11gR2,主要参考这个? 文档。
首先准备阿好如下的安装文件:
-
linux.x64_11gR2_database_1of2.zip
-
linux.x64_11gR2_database_2of2.zip
-
oratoolkit-1.0.2.1.5-1.noarch.rpm
下载上述文件并放在 /var/tmp/oracle目录下。最好要把你的YUM源指向你的系统安装光盘或者ISO文件。
安装OTK
用root登陆,执行如下命令:
# su - root # cd /var/tmp/oracle # ls -1 oratool* oratoolkit-1.0.2.1.5-1.noarch.rpm # rpm -ivh oratoolkit-1.0.2.1.5-1.noarch.rpm Preparing... ########################################### [100%] 1:oratoolkit ########################################### [100%]
otk已经帮我们建立了oracle用户,下面需要设置Oracle用户密码
# 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.
解决环境依赖
这一步最爽,最为头疼的环境依赖问题轻松就解决了!首先要验证下你的系统还差什么没有满足要求,OTK脚本提供了智能的环境是否满足检查:
# /opt/oracle/otk/current/bin/installManager swReqCheck osSetup11gR2.cfg ...//省略大部分输出 20130521_165122: Info: Action swReqCheck of installManager ended with 7 WARNINGS
最后的结论告诉你的系统共有几个警告(我的系统是7个),你可以在输出日志中查看到底缺了什么。下面的一组命令很酷,让你一下子解决所有的问题:
//先拼装命令 # REQ_FILE_DIR="/opt/oracle/otk/current/conf/installManager/requirement" # REQ_FILE_PATH="$REQ_FILE_DIR/ora11gR2-redhat-5-x86_64.pkg.lst" # YUM_COMMAND=$(echo "yum install") # YUM_COMMAND+=$(egrep -v "#" $REQ_FILE_PATH | grep 32-bit | awk '{ print " "$1".i[356]86" }') # YUM_COMMAND+=$(egrep -v "#" $REQ_FILE_PATH | grep 64-bit | awk '{ print " "$1".x86_64" }') //用echo看看最终拼装的命令是什么样 # echo $YUM_COMMAND //执行命令 # $YUM_COMMAND //再次执行环境检查 # /opt/oracle/otk/current/bin/installManager swReqCheck osSetup11gR2.cfg ... 20130521_170131: Info: Action swReqCheck of installManager ended successfully //这次验证成功了,环境已经满足Oracle安装要求
增强sqlplus
OTK提供了一个优化增强的sqlplus环境:
# cd /opt/oracle/otk/current/tools/rlwrap/ # ./configure # make # make install # /usr/local/bin/rlwrap -v rlwrap 0.30
使用installManager提取安装
切换到 /opt/oracle/otk/current/conf/installManager目录,编辑 osSetup11gR2.cfg来配置安装参数,包括内核参数、目录创建及所有授权等设置,如果你想默认安装就无需更改这个文件。
# cd /opt/oracle/otk/current/conf/installManager/ # vi osSetup11gR2.cfg # sdiff -s osSetup11gR2.cfg sample/osSetup11gR2.cfg //对比哪些参数修改过 # /opt/oracle/otk/current/bin/installManager osSetup osSetup11gR2.cfg
把Oracle安装文件移入资源目录
otk默认读取oracle安装文件的目录是 /var/opt/oracle/repository,otk的 swInst实例安装命令会读取这个目录:
# cd /var/tmp/oracle # chown oracle:oinstall * # mv linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip /var/opt/oracle/repository/
定制oracle用户登录的PS1变量
这一步没什么实际意义,就是定制Oracle用户登录的提示符。
# su - oracle ------------------------------------------------------ oraToolKit environment variables ------------------------------------------------------ Installation directory : /opt/oracle/otk Release : 1.0.2.1.5 $RUN directory : /opt/oracle/otk/1.0/bin $LOG_BASE directory : /var/opt/oracle/otk/1.0/log ------------------------------------------------------:oracle@stquist1p:sidNotSet$ grep ^SITE .profile.custom.interactive SITE=" " :oracle@stquist1p:sidNotSet$ vi .profile.custom.interactive :oracle@stquist1p:sidNotSet$ grep ^SITE .profile.custom.interactive SITE="KuuYee"//修改这一行,可以显示你喜欢的内容 :oracle@stquist1p:sidNotSet$ exit # su - oracle KuuYee:oracle@stquist1p:sidNotSet$
安装Oracle数据库
OTK没有采用Oracle Universal Installer( OUI),而是用 swInst来控制整个安装过程的:
$ bash $ cd $INSTALL_CONF $ cp sample/swInstEeSrv11gR2-Step1-linux-x86_64.cfg . $ installManager swInst swInstEeSrv11gR2-Step1-linux-x86_64.cfg $ su - # /opt/oracle/eesrv/11.2.0/db1/root.sh # exit
创建数据库实例
OTK采用 dbSetup来创建实例,首先要进入 $INSTALL_CONF目录配置实例参数
$ cd $INSTALL_CONF $ ls -1 dbSetup*.cfg dbSetup-dev.cfg dbSetup-prod.cfg dbSetup-test.cfg $ vi dbSetup-prod.cfg //prod为生产模式 $ sdiff -s dbSetup-prod.cfg sample/dbSetup-prod.cfg DB_NAME="idm_test" | DB_NAME="prod" ORACLE_HOME="$ORACLE_BASE/eesrv/11.2.0/db1" | ORACLE_HOME="$ORACLE_BASE/sesrv/11.1.0/db1" NLS_LANG=".AL32UTF8" | NLS_LANG=".UTF8" SYSTEM_SIZE=1G | SYSTEM_SIZE=512M TEMP_SIZE=2G | TEMP_SIZE=512M UNDO_SIZE=2G | UNDO_SIZE=512M USERS_SIZE=100M | USERS_SIZE=10M LISTENER_PORT="1541" | LISTENER_PORT="1531" MEMORY_TARGET=7G | MEMORY_TARGET=512M MEMORY_MAX_TARGET=7G | MEMORY_MAX_TARGET=512M SGA_TARGET=3G | SGA_TARGET=256M PROCESSES=1000 | PROCESSES=100 $ installManager dbSetup dbSetup-prod.cfg //执行这部之前最好先配置下/etc/hosts文件,看下面说明
本文采用 dbSetup-prod.cfg生产环境模式配置,我们看到还有dev(开发环境)和test(测试环境),不过我没试过,有兴趣的童鞋可以试试。我在上面列出了我所作出的配置,原文并没有修改内存参数,我之所以修改是因为实际环境因为内存设置太小导致运行一段时间数据库经常挂掉,经过多次的调试而得到的经验值,这里需要说明下我的数据库配置:
OS:VMware虚拟机(RHEL5.5)
CPU:8核
内存:32G
硬盘:200GB
上面用 sdiff -s dbSetup-prod.cfg sample/dbSetup-prod.cfg命令可以对比下我的参数修改,左面是我的修改参数,右面是原参数,需要特别说明的是第二个参数 ORACLE_HOME,一定要自修修改,原来的参数是 $ORACLE_BASE/sesrv/11.1.0/db1,要修改为$ORACLE_BASE/ eesrv/11.2.0/db1,别改错了!
installManager dbSetup dbSetup-prod.cfg命令开始安装数据库实例,不过我建议你最好先配置下你的 /etc/hosts文件,加入下面的内容:
127.0.0.1 你的hostname
接下来就是漫长的等待,大概需要几十分钟,具体根据你的机器配置情况。如果你最后看到如下的输出:
---------------------------------------------------------------------------------------------------- 20130522_091856: Info: Executing libmiscellaneous.getFooter function 20130522_091856: Info: Terminating installManager execution 20130522_091856: Info: Summary log file: /var/opt/oracle/otk/1.0/log-old/installManager/../installManager.log 20130522_091856: Info: Detailed log file: /var/opt/oracle/otk/1.0/log-old/installManager/dbsetup-20130522_090349.log 20130522_091856: Info: Action dbSetup of installManager ended successfully ----------------------------------------------------------------------------------------------------
Congratulations!你安装成功了。
下面登陆试试:
Note | OTK默认创建了一个 otk用户,密码也是 otk,? sys和 system默认密码是 manager |
$ bash $ sourceProdEnv $ sqlplus sys/manager@idm_dev as sysdba; 或者 $ sqlplus otk/otk@idm_dev SQL*Plus: Release 11.2.0.1.0 Production on Wed May 22 11:05:16 2013 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, OLAP, Data Mining and Real Application Testing options SQL>
使用appctl管理oracle
OTK提供了一个ctl工具来帮我们管理Oracle实例:
$ ctl status all //查看当前状态 $ ctl stop all //停止数据库 $ ctl start all //启动数据库
使用backupuManager备份oracle
$ cd $BACKUP_CONF $ vi prod.cfg $ sdiff -s prod.cfg sample/prod.cfg DISK_DEVICE_MOUNT_POINT="/" | DISK_DEVICE_MOUNT_POINT="/backup01" $ backupManager full prod.cfg
定时备份Job
$ crontab -l|head -2 # Example 1: Daily physical database backup # 0 2 * * * [ -d $HOME/../current ] && (ksh -c '. ./.profile >/dev/null; backupManager full.cfg .cfg .cfg >/dev/null') $ crontab -e $ crontab -l|head -2 # Example 1: Daily physical database backup 0 2 * * * [ -d $HOME/../current ] && (ksh -c '. ./.profile >/dev/null; backupManager full prod.cfg >/dev/null')
创建EM管理控制台
otk并没有帮我们创建EM控制台,对于习惯用Web管理的用户很不方便,我们需要手工创建:
$ emca -config dbcontrol db -repos recreate STARTED EMCA at May 22, 2013 11:18:41 AM EM Configuration Assistant, Version 11.2.0.0.2 Production Copyright (c) 2003, 2005, Oracle. All rights reserved. Enter the following information: Database SID: idm_dev //输入sid Listener port number: 1541 //监听输入端口 Listener ORACLE_HOME [ /opt/oracle/eesrv/11.2.0/db1 ]: //默认回车 Password for SYS user: //输入密码manager Password for DBSNMP user: //输入密码manager Password for SYSMAN user: //输入密码manager Email address for notifications (optional): //默认回车 Outgoing Mail (SMTP) server for notifications (optional): //默认回车 ----------------------------------------------------------------- You have specified the following settings Database ORACLE_HOME ................ /opt/oracle/eesrv/11.2.0/db1 Local hostname ................ localhost.localdomain Listener ORACLE_HOME ................ /opt/oracle/eesrv/11.2.0/db1 Listener port number ................ 1541 Database SID ................ idm_dev Email address for notifications ............... Outgoing Mail (SMTP) server for notifications ............... ----------------------------------------------------------------- Do you wish to continue? [yes(Y)/no(N)]: yes May 22, 2013 11:19:20 AM oracle.sysman.emcp.EMConfig perform INFO: This operation is being logged at /opt/oracle/cfgtoollogs/emca/idm_dev/emca_2013_05_22_11_18_40.log. May 22, 2013 11:19:21 AM oracle.sysman.emcp.EMReposConfig invoke INFO: Dropping the EM repository (this may take a while) ... May 22, 2013 11:19:23 AM oracle.sysman.emcp.EMReposConfig invoke INFO: Repository successfully dropped May 22, 2013 11:19:23 AM oracle.sysman.emcp.EMReposConfig createRepository INFO: Creating the EM repository (this may take a while) ... May 22, 2013 11:24:27 AM oracle.sysman.emcp.EMReposConfig invoke INFO: Repository successfully created May 22, 2013 11:24:30 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository INFO: Uploading configuration data to EM repository (this may take a while) ... //可能会等一会 May 22, 2013 11:25:19 AM oracle.sysman.emcp.EMReposConfig invoke INFO: Uploaded configuration data successfully May 22, 2013 11:25:23 AM oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib INFO: Software library configured successfully. May 22, 2013 11:25:23 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary INFO: Deploying Provisioning archives ... May 22, 2013 11:25:45 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary INFO: Provisioning archives deployed successfully. May 22, 2013 11:25:45 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole INFO: Securing Database Control (this may take a while) ... May 22, 2013 11:25:58 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole INFO: Database Control secured successfully. May 22, 2013 11:25:58 AM oracle.sysman.emcp.util.DBControlUtil startOMS INFO: Starting Database Control (this may take a while) ... May 22, 2013 11:26:28 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration INFO: Database Control started successfully May 22, 2013 11:26:28 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration INFO: >>>>>>>>>>> The Database Control URL is https://localhost.localdomain:1158/em
OK! 大功告成,相信各位童鞋都安装成功了,OTK的安装还是很稳健的,至少我安装了几十次都成功了!
最后祝各位童鞋好运!
2013-05-21
kuuyee 2013-05-24 12:27 发表评论
原文地址:Linux下的ORACLE安装,成功率99.99999%, 感谢原作者分享。
推荐阅读
-
Linux下安装oracle客户端并配置php5.3,oraclephp5.3
-
PHP4.03在linux下的安装_PHP教程
-
Redhat Enterprise Linux 5.4下安装配置Oracle 11g R2
-
phpmyadmin课程之linux下phpmyadmin的安装
-
Linux下安装Oracle数据库完整笔记
-
Linux下安装配置Oracle
-
RHEL5下安装Oracle 10g的完整过程
-
Linux 下修改Oracle 的字符集:WE8ISO8859P1 修改为 ZHS16GBK
-
Linux下MySQL的安装与MySQL一机多实例
-
Oracle数据库在Linux 中的安装与启动动