Oracle數(shù)據(jù)庫(kù)在Linux 中的安裝與啟動(dòng)動(dòng) |
發(fā)布時(shí)間: 2012/9/18 17:17:30 |
到目前為止,Oracle數(shù)據(jù)庫(kù)算是我在linux安裝的眾多軟件中最難安裝的一個(gè)。值得慶幸的是,就在剛剛我成功的把oracle database安裝到了linux os,F(xiàn)在回想起來裝個(gè)oracle也并非難事;蛟S自己將來還是安裝oracle,下面就簡(jiǎn)要回憶一下我的安裝過程,用來提示將來的自己和第一次要在linux上安裝oracle的朋友。 首先看一下我的軟件環(huán)境: - HOST:Ubuntu 10.04(lucid),呵呵,我并不是要把db裝到這個(gè)里面,我喜歡把這些軟件裝到vm(virtual machine)中。這么做有很多好處,當(dāng)然也有一點(diǎn)壞處就是系統(tǒng)資源會(huì)增加一點(diǎn)點(diǎn),但是這些增加的消耗是完全值得的。vm software我選用的是vbox(一款很不錯(cuò)的open-soruce軟件) GUEST(vm):CentOS 5.5。眾所周知,linux有很多發(fā)行版,我們必須要選擇一個(gè)發(fā)行版去安裝Oracle,這個(gè)時(shí)候最好是選擇oracle安裝手冊(cè)中提到那幾個(gè)發(fā)行版,比如Asianux 、 Oracle Enterprise Linux 、Red Hat Enterprise Linux、 SUSE Linux Enterprise Server 等。因?yàn)檫@樣安裝會(huì)簡(jiǎn)單很多。 DATABASE:Oracle Database 11g Release 2 下面是安裝steps: Step1. 創(chuàng)建用戶和組(#表示以root身份,$表示以普通用戶身份) 下面是Oracle 數(shù)據(jù)庫(kù)文檔中的一段話,依照下面的話去創(chuàng)建或修改DB所需的用戶和組: The following local operating system groups and users are required if you are installing Oracle Database: *The Oracle Inventory group (typically, oinstall) *The OSDBA group (typically, dba) *The Oracle software owner (typically, oracle) *The OSOPER group (optional. Typically, oper) To determine whether these groups and users already exist, and if necessary, to create them, follow these steps: 1.To determine whether the oinstall group exists, enter the following command: # more /etc/oraInst.loc If the output of this command shows the oinstall group name, then the group already exists. If the oraInst.loc file exists, then the output from this command is similar to the following: inventory_loc=/u01/app/oraInventory inst_group=oinstall The inst_group parameter shows the name of the Oracle Inventory group, oinstall. 2.To determine whether the dba group exists, enter the following command: # grep dba /etc/group If the output from this commands shows the dba group name, then the group already exists. 3.If necessary, enter the following commands to create the oinstall and dba groups: # /usr/sbin/groupadd oinstall # /usr/sbin/groupadd dba 4. To determine whether the Oracle user exists and belongs to the correct groups, enter the following command: # id Oracle If the Oracle user exists, then this command displays information about the groups to which the user belongs. The output should be similar to the following, indicating that oinstall is the primary group and dba is a secondary group: uid=440(Oracle) gid=200(oinstall) groups=201(dba),202(oper) 5.If necessary, complete one of the following actions: *If the Oracle user exists, but its primary group is not oinstall or it is not a member of the dba group, then enter the following command: # /usr/sbin/usermod -g oinstall -G dba Oracle *If the Oracle user does not exist, enter the following command to create it: # /usr/sbin/useradd -g oinstall -G dba Oracle This command creates the Oracle user and specifies oinstall as the primary group and dba as the secondary group. 6.Enter the following command to set the password of the Oracle user: # passwd Oracle Step2. 進(jìn)入db的解壓目錄執(zhí)行runInstaller,下面是我當(dāng)時(shí)的操作: [Oracle@DBServer ~]$ ls Desktop linux_11gR2_database [Oracle@DBServer ~]$ cd linux_11gR2_database/ [Oracle@DBServer linux_11gR2_database]$ ls doc install response rpm runInstaller sshsetup stage welcome.html [Oracle@DBServer linux_11gR2_database]$ ./runInstaller 接下來就是完全的圖形界面操作了,這里面就沒什么好說的了。 Step3. 安裝系統(tǒng)缺失軟件與修改系統(tǒng)配置參數(shù) 關(guān)于這一步你可以按照安裝文檔里的要求那樣做。但是有一個(gè)更簡(jiǎn)單的辦法,安裝程序會(huì)檢查系統(tǒng)配置參數(shù),當(dāng)有參數(shù)不滿足配置的時(shí)候,你要做的就是修復(fù)并重新檢查,這個(gè)時(shí)候安裝程序會(huì)生成一個(gè)修復(fù)腳本并提示你腳本所在的位置及你要如何操作。對(duì)于系統(tǒng)缺少的軟件,修復(fù)腳本不會(huì)安裝,需要自己手動(dòng)安裝。當(dāng)所有的軟件配置參數(shù)都滿足的時(shí)候,你就可以一直next而不會(huì)再遇到什么困難了。 當(dāng)初我安裝的時(shí)候選擇的是僅安裝數(shù)據(jù)庫(kù)軟件,所以我現(xiàn)在需要?jiǎng)?chuàng)建一個(gè)監(jiān)聽和數(shù)據(jù)庫(kù)。下面的Oracle_HOME需要你在配置文件(~/.bash_profile)中手動(dòng)設(shè)置,當(dāng)然最好是把$ORACLE_HOME/bin加入到PATH中去,這樣的話我們就可以在任何地方直接輸入命令了 [Oracle@DBServer ~]$ cd $ORACLE_HOME [Oracle@DBServer dbhome_1]$ pwd /home/Oracle/app/oracle/product/11.2.0/dbhome_1 [Oracle@DBServer dbhome_1]$ cd bin/ [Oracle@DBServer bin]$ netca 注:netca配置監(jiān)聽,圖形界面 [Oracle@DBServer bin]$ dbca 注:dbca 創(chuàng)建數(shù)據(jù)庫(kù),圖形界面 上述step執(zhí)行完后,數(shù)據(jù)庫(kù)就可以使用了
默認(rèn)情況下,linux中的Oracle是不會(huì)隨系統(tǒng)啟動(dòng)而啟動(dòng)的。當(dāng)我們r(jià)eboot系統(tǒng)的時(shí)候,可以用如下steps啟動(dòng)我們的db: [Oracle@DBServer ~]$ lsnrctl start注:?jiǎn)?dòng)監(jiān)聽 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-DEC-2010 11:05:02 Copyright (c) 1991, 2009, Oracle. All rights reserved. Starting /home/Oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /home/Oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Log messages written to /home/Oracle/app/oracle/diag/tnslsnr/DBServer/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DBServer)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=DBServer)(PORT=2484)))
STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 10-DEC-2010 11:05:02 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/Oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File /home/Oracle/app/oracle/diag/tnslsnr/DBServer/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DBServer)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=DBServer)(PORT=2484))) The listener supports no services The command completed successfully [Oracle@DBServer ~]$ dbstart注:?jiǎn)?dòng)數(shù)據(jù)庫(kù) Oracle_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener Usage: /home/Oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbstart ORACLE_HOME Processing Database instance "orcl": log file /home/Oracle/app/oracle/product/11.2.0/dbhome_1/startup.log 以下steps關(guān)閉db: [Oracle@DBServer ~]$ dbshut注:關(guān)閉數(shù)據(jù)庫(kù) Oracle_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener Usage: /home/Oracle/app/oracle/product/11.2.0/dbhome_1/bin/dbshut ORACLE_HOME Processing Database instance "orcl": log file /home/Oracle/app/oracle/product/11.2.0/dbhome_1/shutdown.log [Oracle@DBServer ~]$ lsnrctl stop注:關(guān)閉監(jiān)聽 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-DEC-2010 11:06:50 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DBServer)(PORT=1521))) The command completed successfully [Oracle@DBServer ~]$ 不幸的是如果是第一次這么做,我們可能會(huì)失敗,原因我們可以在dbstart腳本中發(fā)現(xiàn)。我把有用的內(nèi)容摘錄如下: # This script will start all databases listed in the oratab file # whose third field is a "Y". If the third field is set to "Y" and # there is no Oracle_SID for an entry (the first field is a *), # then this script will ignore that entry. 看完這段內(nèi)容我想你已經(jīng)明白該如何做了,沒錯(cuò)修改/etc/oratab中的內(nèi)容: orcl:/home/Oracle/app/oracle/product/11.2.0/dbhome_1:N 把其中的‘N’改為‘Y’ 到此數(shù)據(jù)庫(kù)啟動(dòng)的問題都解決了,以后我們可以放心使用我們的db了。GOOK LUCK
本文出自:億恩科技【mszdt.com】 服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM] |