首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

Linux停的ORACLE安装详解

2013-10-22 
Linux下的ORACLE安装详解原文链接:http://jingyan.baidu.com/article/922554469f9e59851648f4b3.html?相信

Linux下的ORACLE安装详解

原文链接:http://jingyan.baidu.com/article/922554469f9e59851648f4b3.html

?

相信很多童鞋都有过在Linux上安装Oracle数据库的痛苦经历,其中绝大多数都是环境设置的问题。我给大家推荐一个国外大牛写的Oracle的安装脚本 OTK,是用Bash写的,这东东大大简化了Oracle安装过程,而且成功率达到99%以上,只要确保你的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.rpmPreparing... ########################################### [100%]1:oratoolkit ########################################### [100%]

otk已经帮我们建立了oracle用户,下面需要设置Oracle用户密码

# passwd oracleChanging password for user oracle.New UNIX password:BAD PASSWORD: it is based on a dictionary wordRetype 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 -vrlwrap 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/otkRelease : 1.0.2.1.5$RUN directory : /opt/oracle/otk/1.0/bin$LOG_BASE directory : /var/opt/oracle/otk/1.0/log------------------------------------------------------<SITE|COMPANY>:oracle@stquist1p:sidNotSet$ grep ^SITE .profile.custom.interactiveSITE="<SITE|COMPANY>"<SITE|COMPANY>:oracle@stquist1p:sidNotSet$ vi .profile.custom.interactive<SITE|COMPANY>:oracle@stquist1p:sidNotSet$ grep ^SITE .profile.custom.interactiveSITE="KuuYee"//修改这一行,可以显示你喜欢的内容<SITE|COMPANY>:oracle@stquist1p:sidNotSet$ exit# su - oracleKuuYee: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*.cfgdbSetup-dev.cfgdbSetup-prod.cfgdbSetup-test.cfg$ vi dbSetup-prod.cfg //prod为生产模式$ sdiff -s dbSetup-prod.cfg sample/dbSetup-prod.cfgDB_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=512MTEMP_SIZE=2G | TEMP_SIZE=512MUNDO_SIZE=2G | UNDO_SIZE=512MUSERS_SIZE=100M | USERS_SIZE=10MLISTENER_PORT="1541" | LISTENER_PORT="1531"MEMORY_TARGET=7G | MEMORY_TARGET=512MMEMORY_MAX_TARGET=7G | MEMORY_MAX_TARGET=512MSGA_TARGET=3G | SGA_TARGET=256MPROCESSES=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 function20130522_091856: Info: Terminating installManager execution20130522_091856: Info: Summary log file: /var/opt/oracle/otk/1.0/log-old/installManager/../installManager.log20130522_091856: Info: Detailed log file: /var/opt/oracle/otk/1.0/log-old/installManager/dbsetup-20130522_090349.log20130522_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_devSQL*Plus: Release 11.2.0.1.0 Production on Wed May 22 11:05:16 2013Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL>

使用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 <sid_1>.cfg <sid_2>.cfg <sid_n>.cfg >/dev/null')$ crontab -e$ crontab -l|head -2# Example 1: Daily physical database backup0 2 * * * [ -d $HOME/../current ] && (ksh -c '. ./.profile >/dev/null; backupManager full prod.cfg >/dev/null')

创建EM管理控制台

otk并没有帮我们创建EM控制台,对于习惯用Web管理的用户很不方便,我们需要手工创建:

$ emca -config dbcontrol db -repos recreateSTARTED EMCA at May 22, 2013 11:18:41 AMEM Configuration Assistant, Version 11.2.0.0.2 ProductionCopyright (c) 2003, 2005, Oracle. All rights reserved. Enter the following information:Database SID: idm_dev //输入sidListener port number: 1541 //监听输入端口Listener ORACLE_HOME [ /opt/oracle/eesrv/11.2.0/db1 ]: //默认回车Password for SYS user: //输入密码managerPassword for DBSNMP user: //输入密码managerPassword for SYSMAN user: //输入密码managerEmail address for notifications (optional): //默认回车Outgoing Mail (SMTP) server for notifications (optional): //默认回车-----------------------------------------------------------------You have specified the following settingsDatabase ORACLE_HOME ................ /opt/oracle/eesrv/11.2.0/db1Local hostname ................ localhost.localdomainListener ORACLE_HOME ................ /opt/oracle/eesrv/11.2.0/db1Listener port number ................ 1541Database SID ................ idm_devEmail address for notifications ...............Outgoing Mail (SMTP) server for notifications ...............-----------------------------------------------------------------Do you wish to continue? [yes(Y)/no(N)]: yesMay 22, 2013 11:19:20 AM oracle.sysman.emcp.EMConfig performINFO: 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 invokeINFO: Dropping the EM repository (this may take a while) ...May 22, 2013 11:19:23 AM oracle.sysman.emcp.EMReposConfig invokeINFO: Repository successfully droppedMay 22, 2013 11:19:23 AM oracle.sysman.emcp.EMReposConfig createRepositoryINFO: Creating the EM repository (this may take a while) ...May 22, 2013 11:24:27 AM oracle.sysman.emcp.EMReposConfig invokeINFO: Repository successfully createdMay 22, 2013 11:24:30 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepositoryINFO: Uploading configuration data to EM repository (this may take a while) ... //可能会等一会May 22, 2013 11:25:19 AM oracle.sysman.emcp.EMReposConfig invokeINFO: Uploaded configuration data successfullyMay 22, 2013 11:25:23 AM oracle.sysman.emcp.util.DBControlUtil configureSoftwareLibINFO: Software library configured successfully.May 22, 2013 11:25:23 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibraryINFO: Deploying Provisioning archives ...May 22, 2013 11:25:45 AM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibraryINFO: Provisioning archives deployed successfully.May 22, 2013 11:25:45 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsoleINFO: Securing Database Control (this may take a while) ...May 22, 2013 11:25:58 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsoleINFO: Database Control secured successfully.May 22, 2013 11:25:58 AM oracle.sysman.emcp.util.DBControlUtil startOMSINFO: Starting Database Control (this may take a while) ...May 22, 2013 11:26:28 AM oracle.sysman.emcp.EMDBPostConfig performConfigurationINFO: Database Control started successfullyMay 22, 2013 11:26:28 AM oracle.sysman.emcp.EMDBPostConfig performConfigurationINFO: >>>>>>>>>>> The Database Control URL is https://localhost.localdomain:1158/em <<<<<<<<<<< //这个是EM的访问链接May 22, 2013 11:26:31 AM oracle.sysman.emcp.EMDBPostConfig invokeWARNING:************************ WARNING ************************Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted. The encryption key has been placed in the file: /opt/oracle/eesrv/11.2.0/db1/localhost.localdomain_idm_dev/sysman/config/emkey.ora. Please ensure this file is backed up as the encrypted data will become unusable if this file is lost.***********************************************************Enterprise Manager configuration completed successfullyFINISHED EMCA at May 22, 2013 11:26:31 AM

OK! 大功告成,相信各位童鞋都安装成功了,OTK的安装还是很稳健的,至少我安装了几十次都成功了!

最后祝各位童鞋好运!

?

?<script type="text/javascript">// <![CDATA[ F.use('/static/article/ui/auto-app/auto-app.js', function(app){app.init('Linux下的ORACLE安装详解','linuxoracle');}) // ]]></script>

参考资料http://www.devba.com/index.php/archives/893.html ||Linux下的ORACLE安装说明、安装文件以及文件下载

热点排行