標籤:網上 oracle
By Toper Lv
2015.8.16
平時在網上查閱各種文檔的過程中,大家可能都有過類似的經曆。一份文檔,沒有描述文檔作者的實驗環境,亦或對實驗環境描述不清晰。所以,一旦按文檔內容操作出錯,大家很難判斷問題的原因在於環境不一樣,還是自己操作過程中出錯。,
本人自然也避免不了以上情況,所以撰寫文檔時儘力做到描述清楚自己的環境,希望其他人蔘考此文檔時不會有太多困惑。
1 實驗環境1.1 硬體設定
本文檔實驗環境為虛擬機器,使用VMware WorkStation 11,建立的虛擬硬體版本為10(可以直接理解為使用的是VMware Workstation 10),為虛擬機器分配的硬體設定如下:
650) this.width=650;" title="clip_image001" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image001" src="http://s3.51cto.com/wyfs02/M01/71/78/wKiom1XRS_LyFmq3AACdLMReSDM802.jpg" height="185" />
1.2 作業系統
版本:Red Hat Enterprise Linux 6.4 x86_x64—案頭
語言:中文
主機名稱:oracle
IP:192.168.80.80
分區:如下
650) this.width=650;" title="clip_image003" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image003" src="http://s3.51cto.com/wyfs02/M01/71/78/wKiom1XRS_ODhQTGAACsUuVvslQ954.jpg" height="155" />
1.3 Oracle安裝包
Oracle官網目前只能下載到11.2.0.1的安裝包,所以本文檔的安裝包請大家百度找資源下載。
版本:11.2.0.4
安裝包檔案名稱:db_112040_Linux-x86-64_1of7.zip、db_112040_Linux-x86-64_2of7.zip
2 安裝前準備2.1 關閉防火牆
[[email protected] ~]# service iptables stop
[[email protected] ~]# chkconfig iptables off
2.2 配置主機名稱
[[email protected] ~]# vim /etc/hosts
192.168.80.80 oracle #在/etc/hosts檔案添加如下行
2.3 配置YUM源
將RHEL6.4的安裝光碟片串連至光碟機,並掛載光碟片
[[email protected] ~]# mount /dev/cdrom /media
[[email protected] ~]# vim /etc/yum.repos.d/rhel6.repo
[RHEL6]
name=RHEL6.4-ISO
baseurl=file:///media
gpgcheck=0
enabled=1
[[email protected] ~]# yum clean all
2.4 安裝軟體包
以下是Oracle安裝需要的前置軟體包。
[[email protected] ~]# yum install -y binutils-2.* compat-libstdc++-33* elfutils-libelf-* gcc-4* gcc-c++* glibc* libaio* libgcc* libstdc++-* make-3.* sysstat* unixODBC*
還有一個pdksh的安裝包RHEL6.4的鏡像中是沒有的,需要先去網上搜尋並下載,然後上傳到我們的伺服器進行安裝。
這裡將安裝包上傳到了root的家目錄。
[[email protected] ~]# yum install -y ./pdksh-5.2.14-37.el5_8.1.x86_64.rpm
2.5 建立使用者和組
為了比較規範,指定了使用者和組的ID,也可以不指定。
建立使用者oracle,密碼passw0rd;建立組oinstall、dba。
[[email protected] ~]# groupadd -g 5000 oinstall
[[email protected] ~]# groupadd -g 5001 dba
[[email protected] ~]# useradd -u 5000 -g oinstall -G dba oracle
[[email protected] ~]# echo ‘passw0rd‘ | passwd --stdin oracle
2.6 配置核心
紫色字型為已有內容,需按文檔變更。綠色為新加內容。
[[email protected] ~]# vim /etc/sysctl.conf
#單個共用記憶體段的最大值(不能超過自己的記憶體大小,這裡設定的值為2G)
kernel.shmmax = 2147483648
#可以使用的共用記憶體的總頁數
kernel.shmall = 2097152
#該參數是共用記憶體段的最大數量,建議用預設值4096
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
#該參數決定了系統中所允許的檔案控制代碼最大數目,檔案控制代碼設定代表linux系統中可以開啟的檔案的數量
fs.file-max = 6815744
#通訊端接收緩衝區大小的預設值
net.core.rmem_default = 1048576
#通訊端接收緩衝區大小的最大值
net.core.rmem_max = 4194304
#通訊端發送緩衝區大小的預設值
net.core.wmem_default = 262144
#通訊端發送緩衝區大小的最大值
net.core.wmem_max = 1048576
#此參數限制並發未完成的請求,應該設定避免I/O子系統故障
fs.aio-max-nr = 1048576
#IP4的連接埠可使用範圍
net.ipv4.ip_local_port_range = 9000 65500
[[email protected] ~]# /sbin/sysctl -p
執行該命令使修改的核心參數立即生效,如下錯誤提示請忽略
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
2.7 配置資源限制
在資源限制中添加如下內容
[[email protected] ~]# vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
2.8 建立安裝目錄
建立Oracle安裝目錄,並更改目錄所有者、所屬組
[[email protected] ~]# mkdir -p /u01/app/oracle
[[email protected] ~]# chown -R oracle:oinstall /u01/
2.9 配置環境變數
切換至建立的oracle使用者。
[[email protected] ~]# su - oracle
[[email protected] ~]$ vim .bash_profile
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
ORACLE_SID=orcl #這裡指定的ORACLE_SID為資料庫執行個體名
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH
使環境變數生效
[[email protected] ~]$ source /home/oracle/.bash_profile
3 Oracle安裝
Oracle安裝分為Oracle軟體安裝和建立資料庫兩步,可以將兩步一次完成,也可以分為兩步操作,這裡只示範分兩步安裝的過程。
使用oracle使用者登入安裝。
3.1 Oracle軟體安裝
將oracle安裝包上傳至使用者oracle家目錄
[[email protected] ~]$ ls
db_112040_Linux-x86-64_1of7.zip
db_112040_Linux-x86-64_2of7.zip
解壓安裝包,會自動建立database目錄
[[email protected] ~]$ unzip db_112040_Linux-x86-64_1of7.zip ; unzip db_112040_Linux-x86-64_2of7.zip
開啟另一個終端,使用root使用者執行如下命令,確保Oracle圖形安裝介面可以正常調用
[[email protected] ~]# xhost +
指定輸出語言為en_us,防止安裝介面亂碼
[[email protected] ~]$ export LANG=en_us
[[email protected] ~]$ cd database
[[email protected] database]$ ./runInstaller
安裝程式開啟Oracle圖形安裝介面
取消勾選,下一步
650) this.width=650;" title="clip_image005" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image005" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_OBFTzvAADpHiCaajs057.jpg" height="422" />
Yes
650) this.width=650;" title="clip_image007" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image007" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_OgNEfGAAE6VMQvGKg521.jpg" height="422" />
Skip software updates
650) this.width=650;" title="clip_image009" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image009" src="http://s3.51cto.com/wyfs02/M00/71/74/wKioL1XRTf3S1QUHAAEt89YKnzk811.jpg" height="422" />
Install database software only(前面已經提過這裡示範軟體和建立資料庫分開安裝情況)
650) this.width=650;" title="clip_image011" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image011" src="http://s3.51cto.com/wyfs02/M00/71/78/wKiom1XRS_TD2OvgAAD5Bq98b14279.jpg" height="422" />
Single Instance database installation(單一實例資料庫安裝)
650) this.width=650;" title="clip_image013" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image013" src="http://s3.51cto.com/wyfs02/M01/71/74/wKioL1XRTf7iupmnAADrW5L-YvM930.jpg" height="422" />
添加語言:簡體中文
650) this.width=650;" title="clip_image015" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image015" src="http://s3.51cto.com/wyfs02/M01/71/78/wKiom1XRS_SCyzhrAAEwnA7KYNE006.jpg" height="422" />
Enterprise Edtion(企業版)
650) this.width=650;" title="clip_image017" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image017" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_WhmiDtAAFo6dwrBMs803.jpg" height="422" />
Oracle會根據環境變數自動選擇設定好的安裝路徑,直接下一步即可
650) this.width=650;" title="clip_image019" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image019" src="http://s3.51cto.com/wyfs02/M02/71/74/wKioL1XRTf-Tb8pWAAEzhLVi1HA782.jpg" height="422" />
Next
650) this.width=650;" title="clip_image021" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image021" src="http://s3.51cto.com/wyfs02/M01/71/74/wKioL1XRTf-hQIAUAAEqDEHSdKA490.jpg" height="422" />
下面空白的選擇框選擇oinstall,Next
650) this.width=650;" title="clip_image023" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image023" src="http://s3.51cto.com/wyfs02/M00/71/74/wKioL1XRTf_Q7OweAAEtHOCOB4w147.jpg" height="422" />
這一步是對安裝前配置環境的檢查,由於我們配置好了所有的準備環境,所以這一步會在檢測通過後自動跳過。下面是倒退一步後對依賴軟體包的檢測
650) this.width=650;" title="clip_image025" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image025" src="http://s3.51cto.com/wyfs02/M01/71/74/wKioL1XRTf_RK5xlAAD-oKJNbFM976.jpg" height="299" />
Install
650) this.width=650;" title="clip_image027" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image027" src="http://s3.51cto.com/wyfs02/M02/71/74/wKioL1XRTgCSgP9eAAFDFgr7Ozw801.jpg" height="422" />
軟體安裝到最後一步,會跳出如下執行指令碼的提示
650) this.width=650;" title="clip_image029" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image029" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_bhqXzWAAFiKuXlC8o227.jpg" height="422" />
開啟一個終端,使用root登入,執行要求執行的指令碼。執行完畢後在圖形介面點OK。
[[email protected] ~]# /u01/app/oraInventory/orainstRoot.sh
[[email protected] ~]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
650) this.width=650;" title="clip_image031" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image031" src="http://s3.51cto.com/wyfs02/M00/71/74/wKioL1XRTgDg2El4AAHnl1r6wrE363.jpg" height="369" />
安裝完畢,Close
650) this.width=650;" title="clip_image033" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image033" src="http://s3.51cto.com/wyfs02/M01/71/74/wKioL1XRTgCQ--kBAADCzdDOqGE713.jpg" height="422" />
3.2 建立資料庫
用oracle使用者登入,執行命令:dbca
650) this.width=650;" title="clip_image035" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image035" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_ehQhAsAAD72X8weM0261.jpg" height="424" />
Create a Database
650) this.width=650;" title="clip_image037" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image037" src="http://s3.51cto.com/wyfs02/M02/71/74/wKioL1XRTgHQMviTAADo5781rE8411.jpg" height="400" />
預設的選擇即可:一般用途/交易處理
650) this.width=650;" title="clip_image039" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image039" src="http://s3.51cto.com/wyfs02/M01/71/74/wKioL1XRTgGBinOmAAEtDo5me0w719.jpg" height="400" />
根據環境變數中設定的ORACLE_SID設定資料庫名稱和SID,這裡設定的是:orcl
650) this.width=650;" title="clip_image041" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image041" src="http://s3.51cto.com/wyfs02/M02/71/74/wKioL1XRTgHhnhxVAAD0icb-VHo266.jpg" height="400" />
由於未啟動監聽,所以在以下菜單切換會有警告
650) this.width=650;" title="clip_image043" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image043" src="http://s3.51cto.com/wyfs02/M00/71/74/wKioL1XRTgKilJg8AAE3wVr4FCY489.jpg" height="400" />
使用oracle使用者登入,啟動監聽。監聽啟動後回圖形介面點OK
[[email protected] ~]$ lsnrctl start
650) this.width=650;" title="clip_image045" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image045" src="http://s3.51cto.com/wyfs02/M00/71/74/wKioL1XRTgLzPawLAAA8-Q-nT_4836.jpg" height="67" />
選擇所有使用者佈建相同密碼(正式業務中請為這些使用者分別設定密碼)
650) this.width=650;" title="clip_image047" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image047" src="http://s3.51cto.com/wyfs02/M01/71/75/wKioL1XRTgKiOD_SAAEC7r-WYHE851.jpg" height="400" />
提示上一步設定密碼不夠安全,Yes繼續
650) this.width=650;" title="clip_image049" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image049" src="http://s3.51cto.com/wyfs02/M01/71/78/wKiom1XRS_mgyUrzAAEdZMqPEPY571.jpg" height="400" />
選擇:Use Oracle-Managed Files
650) this.width=650;" title="clip_image051" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image051" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_nzkJZlAAFcqBaEFq8561.jpg" height="400" />
保持預設,Next
650) this.width=650;" title="clip_image053" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image053" src="http://s3.51cto.com/wyfs02/M00/71/75/wKioL1XRTgPDmsOeAAEmPE0SHjc193.jpg" height="400" />
Next
650) this.width=650;" title="clip_image055" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image055" src="http://s3.51cto.com/wyfs02/M02/71/75/wKioL1XRTgSBN9f2AAEPohoOjN4459.jpg" height="400" />
其他不用設定,字元集選擇:UTF8
650) this.width=650;" title="clip_image057" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image057" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_qg8E3WAAFixEIImNE204.jpg" height="400" />
Next
650) this.width=650;" title="clip_image059" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image059" src="http://s3.51cto.com/wyfs02/M01/71/75/wKioL1XRTgSjUziVAAFy7HJyA1k596.jpg" height="400" />
保持預設,Finish
650) this.width=650;" title="clip_image061" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image061" src="http://s3.51cto.com/wyfs02/M01/71/78/wKiom1XRS_uTyW5OAAD-qBV14L8750.jpg" height="400" />
OK
650) this.width=650;" title="clip_image063" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image063" src="http://s3.51cto.com/wyfs02/M01/71/78/wKiom1XRS_vjaX5qAAFw4xtNNAE806.jpg" height="558" />
資料庫開始安裝,請耐心等待
650) this.width=650;" title="clip_image065" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image065" src="http://s3.51cto.com/wyfs02/M02/71/75/wKioL1XRTgWiTfzEAAEbWmTmBI4749.jpg" height="400" />
Exit(剛剛已經設定了密碼,這裡就不在進密碼管理了)
退出後圖形介面自動關閉,資料庫安裝完成
650) this.width=650;" title="clip_image067" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image067" src="http://s3.51cto.com/wyfs02/M02/71/78/wKiom1XRS_zweb5EAAGLKjbxJuY976.jpg" height="400" />
4 查看資料庫4.1 監聽
在oracle使用者下執行。
4.1.1 查看監聽狀態
按之前步驟安裝完畢後,預設監聽已經啟動,查看監聽狀態。
[[email protected] ~]$ lsnrctl status
650) this.width=650;" title="clip_image069" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image069" src="http://s3.51cto.com/wyfs02/M00/71/75/wKioL1XRTgaSFHZ-AAG1St9p5B8135.jpg" height="383" />
4.1.2 啟動/關閉監聽
啟動監聽
[[email protected] ~]$ lsnrctl start
關閉監聽
[[email protected] ~]$ lsnrctl stop
650) this.width=650;" title="clip_image071" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image071" src="http://s3.51cto.com/wyfs02/M00/71/78/wKiom1XRS_zjNwAwAACT6Mk4Bqo122.jpg" height="148" />
650) this.width=650;" title="clip_image073" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image073" src="http://s3.51cto.com/wyfs02/M01/71/75/wKioL1XRTgbwSYNyAAHlj5pEoMg339.jpg" height="461" />
4.2 資料庫
在oracle使用者下執行。
4.2.1 查看資料庫狀態
預設資料庫已經啟動,串連資料庫,查看資料庫狀態
[[email protected] ~]$ sqlplus / as sysdba
SQL> select status from v$instance;
SQL> select open_mode from v$database;
650) this.width=650;" title="clip_image075" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image075" src="http://s3.51cto.com/wyfs02/M01/71/78/wKiom1XRS_3igrRlAAEZQk82tfM843.jpg" height="370" />
4.2.2 啟動/關閉資料庫
啟動資料庫
SQL> startup
關閉資料庫
SQL> shutdown immediate
650) this.width=650;" title="clip_image077" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" border="0" alt="clip_image077" src="http://s3.51cto.com/wyfs02/M02/71/75/wKioL1XRTgeRqTfeAACqRjsj72k573.jpg" height="215" />
本文出自 “漫步網路” 部落格,請務必保留此出處http://leihenzhimu.blog.51cto.com/3217508/1685164
Red Hat Enterprise 6.4安裝Oracle 11gR2