Linux下的ORACLE安裝,成功率99.99999%

          相信很多童鞋都有過在Linux上安裝Oracle數(shù)據(jù)庫的痛苦經(jīng)歷,其中絕大多數(shù)都是環(huán)境設(shè)置的問題。我給大家推薦一個(gè)國外大牛寫的Oracle的安裝腳本 OTK,是用Bash寫的,這東東大大簡化了Oracle安裝過程,而且成功率達(dá)到99.9999%以上,只要確保你的Linux系統(tǒng)是干凈的,那么按照這個(gè)教程,保證你會(huì)安裝成功。

          準(zhǔn)備工作

          OTK針對(duì)各種Linux提供了 安裝文檔,本文使用的RHEL5.5_x86_64位,數(shù)據(jù)庫版本為11gR2,主要參考這個(gè) 文檔

          首先準(zhǔn)備阿好如下的安裝文件:

          下載上述文件并放在/var/tmp/oracle目錄下。最好要把你的YUM源指向你的系統(tǒng)安裝光盤或者ISO文件。

          安裝OTK

          用root登陸,執(zhí)行如下命令:

          # 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已經(jīng)幫我們建立了oracle用戶,下面需要設(shè)置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.

          解決環(huán)境依賴

          這一步最爽,最為頭疼的環(huán)境依賴問題輕松就解決了!首先要驗(yàn)證下你的系統(tǒng)還差什么沒有滿足要求,OTK腳本提供了智能的環(huán)境是否滿足檢查:

          # /opt/oracle/otk/current/bin/installManager swReqCheck osSetup11gR2.cfg 
          ...//省略大部分輸出
          20130521_165122: Info: Action swReqCheck of installManager ended with 7 WARNINGS

          最后的結(jié)論告訴你的系統(tǒng)共有幾個(gè)警告(我的系統(tǒng)是7個(gè)),你可以在輸出日志中查看到底缺了什么。下面的一組命令很酷,讓你一下子解決所有的問題:

          //先拼裝命令 
          # 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

          //執(zhí)行命令
          # $YUM_COMMAND

          //再次執(zhí)行環(huán)境檢查
          # /opt/oracle/otk/current/bin/installManager swReqCheck osSetup11gR2.cfg
          ...
          20130521_170131: Info: Action swReqCheck of installManager ended successfully //這次驗(yàn)證成功了,環(huán)境已經(jīng)滿足Oracle安裝要求

          增強(qiáng)sqlplus

          OTK提供了一個(gè)優(yōu)化增強(qiáng)的sqlplus環(huán)境:

          # 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來配置安裝參數(shù),包括內(nèi)核參數(shù)、目錄創(chuàng)建及所有授權(quán)等設(shè)置,如果你想默認(rèn)安裝就無需更改這個(gè)文件。

          # cd /opt/oracle/otk/current/conf/installManager/ 
          # vi osSetup11gR2.cfg
          # sdiff -s osSetup11gR2.cfg sample/osSetup11gR2.cfg //對(duì)比哪些參數(shù)修改過
          # /opt/oracle/otk/current/bin/installManager osSetup osSetup11gR2.cfg

          把Oracle安裝文件移入資源目錄

          otk默認(rèn)讀取oracle安裝文件的目錄是/var/opt/oracle/repository,otk的swInst實(shí)例安裝命令會(huì)讀取這個(gè)目錄:

          # 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變量

          這一步?jīng)]什么實(shí)際意義,就是定制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
          ------------------------------------------------------
          <SITE|COMPANY>:oracle@stquist1p:sidNotSet$ grep ^SITE .profile.custom.interactive
          SITE="<SITE|COMPANY>"
          <SITE|COMPANY>:oracle@stquist1p:sidNotSet$ vi .profile.custom.interactive
          <SITE|COMPANY>:oracle@stquist1p:sidNotSet$ grep ^SITE .profile.custom.interactive
          SITE="KuuYee"http://修改這一行,可以顯示你喜歡的內(nèi)容
          <SITE|COMPANY>:oracle@stquist1p:sidNotSet$ exit
          # su - oracle
          KuuYee:oracle@stquist1p:sidNotSet$

          安裝Oracle數(shù)據(jù)庫

          OTK沒有采用Oracle Universal Installer(OUI),而是用swInst來控制整個(gè)安裝過程的:

          $ 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

          創(chuàng)建數(shù)據(jù)庫實(shí)例

          OTK采用dbSetup來創(chuàng)建實(shí)例,首先要進(jìn)入$INSTALL_CONF目錄配置實(shí)例參數(shù)

          $ cd $INSTALL_CONF 
          $ ls -1 dbSetup*.cfg
          dbSetup-dev.cfg
          dbSetup-prod.cfg
          dbSetup-test.cfg
          $ vi dbSetup-prod.cfg //prod為生產(chǎn)模式
          $ 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 //執(zhí)行這部之前最好先配置下/etc/hosts文件,看下面說明

          本文采用dbSetup-prod.cfg生產(chǎn)環(huán)境模式配置,我們看到還有dev(開發(fā)環(huán)境)和test(測試環(huán)境),不過我沒試過,有興趣的童鞋可以試試。我在上面列出了我所作出的配置,原文并沒有修改內(nèi)存參數(shù),我之所以修改是因?yàn)閷?shí)際環(huán)境因?yàn)閮?nèi)存設(shè)置太小導(dǎo)致運(yùn)行一段時(shí)間數(shù)據(jù)庫經(jīng)常掛掉,經(jīng)過多次的調(diào)試而得到的經(jīng)驗(yàn)值,這里需要說明下我的數(shù)據(jù)庫配置:
          OS:VMware虛擬機(jī)(RHEL5.5)
          CPU:8核
          內(nèi)存:32G
          硬盤:200GB
          上面用sdiff -s dbSetup-prod.cfg sample/dbSetup-prod.cfg命令可以對(duì)比下我的參數(shù)修改,左面是我的修改參數(shù),右面是原參數(shù),需要特別說明的是第二個(gè)參數(shù)ORACLE_HOME,一定要自修修改,原來的參數(shù)是$ORACLE_BASE/sesrv/11.1.0/db1,要修改為$ORACLE_BASE/eesrv/11.2.0/db1,別改錯(cuò)了!

          installManager dbSetup dbSetup-prod.cfg命令開始安裝數(shù)據(jù)庫實(shí)例,不過我建議你最好先配置下你的/etc/hosts文件,加入下面的內(nèi)容:

          127.0.0.1    你的hostname

          接下來就是漫長的等待,大概需要幾十分鐘,具體根據(jù)你的機(jī)器配置情況。如果你最后看到如下的輸出:

          ---------------------------------------------------------------------------------------------------- 
          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默認(rèn)創(chuàng)建了一個(gè)otk用戶,密碼也是otk, syssystem默認(rèn)密碼是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提供了一個(gè)ctl工具來幫我們管理Oracle實(shí)例:

          $ ctl status all //查看當(dāng)前狀態(tài) 
          $ ctl stop all //停止數(shù)據(jù)庫
          $ ctl start all //啟動(dòng)數(shù)據(jù)庫

          使用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

          定時(shí)備份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 backup
          0 2 * * * [ -d $HOME/../current ] && (ksh -c '. ./.profile >/dev/null; backupManager full prod.cfg >/dev/null')

          創(chuàng)建EM管理控制臺(tái)

          otk并沒有幫我們創(chuàng)建EM控制臺(tái),對(duì)于習(xí)慣用Web管理的用戶很不方便,我們需要手工創(chuàng)建:

          $ 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 //監(jiān)聽輸入端口
          Listener ORACLE_HOME [ /opt/oracle/eesrv/11.2.0/db1 ]: //默認(rèn)回車
          Password for SYS user: //輸入密碼manager
          Password for DBSNMP user: //輸入密碼manager
          Password for SYSMAN user: //輸入密碼manager
          Email address for notifications (optional): //默認(rèn)回車
          Outgoing Mail (SMTP) server for notifications (optional): //默認(rèn)回車
          -----------------------------------------------------------------

          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) ... //可能會(huì)等一會(huì)
          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 <<<<<<<<<<< //這個(gè)是EM的訪問鏈接
          May 22, 2013 11:26:31 AM oracle.sysman.emcp.EMDBPostConfig invoke
          WARNING:
          ************************ 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 successfully
          FINISHED EMCA at May 22, 2013 11:26:31 AM

          OK! 大功告成,相信各位童鞋都安裝成功了,OTK的安裝還是很穩(wěn)健的,至少我安裝了幾十次都成功了!

          最后祝各位童鞋好運(yùn)!

          2013-05-21

          posted on 2013-05-24 12:27 kuuyee 閱讀(12036) 評(píng)論(5)  編輯  收藏 所屬分類: Linux數(shù)據(jù)庫系統(tǒng)管理

          評(píng)論

          # re: Linux下的ORACLE安裝,成功率99.99999% 2013-05-28 12:45 開發(fā)吧

          學(xué)習(xí)啦,真的很不錯(cuò)!  回復(fù)  更多評(píng)論   

          # re: Linux下的ORACLE安裝,成功率99.99999%[未登錄] 2013-08-08 19:36 x

          20130808_193410: Warning: Oracle software runs on CentOS however this combination is NOT supported by Oracle

          出現(xiàn)了這個(gè),還能裝不。。。  回復(fù)  更多評(píng)論   

          # re: Linux下的ORACLE安裝,成功率99.99999% 2015-09-24 06:59 天地華宇

          看不懂 才疏學(xué)淺 呵呵  回復(fù)  更多評(píng)論   

          # re: Linux下的ORACLE安裝,成功率99.99999% 2015-11-06 13:21 王新強(qiáng)

          我就是那0.00001% 的人了  回復(fù)  更多評(píng)論   

          # re: Linux下的ORACLE安裝,成功率99.99999% 2015-11-09 12:58 kuuyee

          @王新強(qiáng)
          這東西好像收費(fèi)了,所以建議使用https://github.com/biemond/biemond-oradb  回復(fù)  更多評(píng)論   

          導(dǎo)航

          <2015年11月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          統(tǒng)計(jì)

          隨筆分類(139)

          Linux內(nèi)核

          搜索

          •  

          積分與排名

          • 積分 - 319561
          • 排名 - 177

          最新評(píng)論

          閱讀排行榜

          主站蜘蛛池模板: 阿合奇县| 长寿区| 昭觉县| 普兰县| 陆丰市| 二手房| 沛县| 潢川县| 巴南区| 隆安县| 桐城市| 仪征市| 巫山县| 南城县| 安徽省| 彩票| 都江堰市| 华安县| 融水| 神农架林区| 醴陵市| 四平市| 江油市| 抚顺县| 清新县| 塘沽区| 太仓市| 建宁县| 会同县| 古丈县| 黔江区| 江安县| 同德县| 青海省| 民乐县| 宽甸| 壤塘县| 永丰县| 阜宁县| 乌苏市| 全州县|