Oracle 11g (R1) Enterprise安裝研究 for Linux(CentOS 5.4)
這邊假設已經安裝好Linux
OS的情況下故不敘述linux的安裝
軟硬體需求建議如下:
RAM:1G(虛擬機建議1.1G)
HD空間:11GB(含swap)
解析度:1024x768
所支援的OS如下:
On Linux x86 and Linux x86-64:
Asianux 2.0
Asianux 3.0
Oracle Enterprise Linux 4.0
Oracle Enterprise Linux 5.0
Red Hat Enterprise Linux 4.0
Red Hat Enterprise Linux 5.0
SUSE Linux Enterprise Server 10.0
Oracle Database 11gR1(約1.8G)下載網址:
http://www.oracle.com/technology/softwa
... index.html
Oracle Express, Standard, Enterprise 功能比較表
http://www.oracle.com/database/product_editions.html
作業系統:CentOS-5.4(安裝於虛擬機上)
http://ftp.twaren.net/Linux/CentOS/5.4/isos/
虛擬機:xenserver下載處
http://www.citrix.com/lang/English/lp/lp_1688615.asp#top
(請先自行註冊後至電子郵件處點連結下載)
Oracle install參考資料:
http://www.oracle.com/pls/db111/homepage
安裝前重點整理:
請關閉SELINUX的工作模式
代碼:
[root@localhost ~]# vi /etc/selinux/config
把 SELINUX設定為disabled
代碼:
SELINUX=disabled
然後重新啟動系統 (修改SELinux必須重新啟動系統才能生效)
代碼:
[root@localhost ~]# reboot
先建立 /u01目錄
代碼:
[root@localhost ~]# mkdir /u01
下載
linux_11gR1_database.zip放置/u01目錄中,解壓縮,會產生database目錄:
代碼:
[root@localhost ~]# unzip linux_11gR1_database.zip
Oracle 建議用固定IP,檢查 /etc/sysconfig/network-scripts/ifcfg-eth0
代碼:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ ifcfg-eth0
#
Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29:C1:23:E1
ONBOOT=yes
[root@localhost network-scripts]#
改成固定IP,內容類似如下 (請依照自己環境修改)
代碼:
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0C:29:C1:23:E1
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.x.x
GATEWAY=192.168.x.x
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
修 改/etc/resolv.conf,設定DNS Server(請依照自己環境修改)
代 碼:
[root@localhost ~]# vi /etc/resolv.conf
nameserver
168.95.1.1
修改主機名稱/etc
/hosts,增加一筆
代碼:
[root@localhost ~]#vi /etc/hosts
192.168.128.128 oracle(請依自己環境修改)
修改作業系統名稱
代碼:
[root@oracle ~]# vi /etc/redhat-release
將CentOS release 5 (Final) 修改成
代碼:
Red Hat Enterprise Linux AS release 5 (Taroon)
Ps:原著說沒改也是可以安裝 不過在安裝過程會出現error訊息,不過還是可以安裝過去,所以還是改一下
重新啟動網路,讓設定生效
代碼:
[root@localhost ~]# service network restart
Shutting
down interface eth0:
[ OK ]
Shutting down loopback interface:
[ OK ]
Bringing up loopback interface:
[ OK ]
Bringing up interface eth0:
[ OK
]
安裝所需套件
- compat-libstdc++-33-3.2.3-61
- elfutils-libelf-0.125-3.el5
- elfutils-libelf-devel-0.125-3.el5
- glibc-2.5-12
- glibc-devel-2.5-12
- glibc-common-2.5-12
- gcc-4.1.1-52.el5
- gcc-c++-4.1.1-52.el5
- kernel-headers
- libgcc-4.1.1-52.el5
- libaio-0.3.106-3.2
- libaio-devel-0.3.106-3.2
- libstdc++-4.1.1-52.el5
- libstdc++-devel-4.1.1-52.el5
- unixODBC-2.2.11-7.1
- unixODBC-devel-2.2.11-7.1
- sysstat-7.0.0-3.el5
- binutils-2.17.50.0.6-2.el5
- make-3.81-1.1
- pdksh-5.2.14-30
用 yum安裝套件
代碼:
[root@oracle ~]# yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh (這全部是同一行)
如果沒有網路,必須用光碟安裝,請一一用rpm找出在哪個套件在檔案中
代碼:
[root@oracle u01]# rpm -qa | grep <package_name>
然後執行下面命令安裝
代碼:
[root@oracle u01]# rpm -ivh <package_name>.rpm
解壓縮oracle安裝套件
建立Oracle所需要的群組名稱(oinstall、 dba),建立用戶名稱(oracle)並加入oinstall和dba群組中,設定用戶oracle密碼:
代碼:
[root@oracle ~]#groupadd
oinstall
[root@oracle ~]# groupadd dba
[root@oracle ~]# useradd -g
oinstall -G dba oracle
[root@oracle ~]# passwd oracle
建立安裝目錄和設定權限:
代碼:
[root@oracle ~]# mkdir -p /u01/app/oracle/product/
[root@oracle ~]# chown
-R oracle:oinstall /u01
[root@oracle ~]# chmod -R
775 /u01
修改核心參數:
代 碼:
[root@oracle ~]# vi /etc/sysctl.conf
先將預設的 kernel.shmal、 kernel.shmmax用# 字號註解掉
在最末尾的地方加上如下:
代 碼:
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
fs.file-max = 65536
讓設定生效
代碼:
[root@oracle ~]# sysctl –p
為oracle用戶設置Shell限制
代碼:
[root@oracle ~]# vi /etc/security/limits.conf
在最後面加上
代碼:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
修改/etc/pam.d/login
代碼:
[root@oracle ~]#
vi /etc/pam.d/login
增加一行
代 碼:
session required pam_limits.so
修改/etc/profile
代碼:
[root@oracle ~]# vi /etc/profile
在最後面增加
代碼:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384
-n 65536
fi
fi
切換到oracle用戶修改環境變數
代碼:
[root@oracle ~]# su - oracle
修改.bash_profile,此文件為oracle用戶的環境變數
代碼:
[oracle@oracle ~]$ vi .bash_profile
在最後面增加
代 碼:
# User specific environment and startup programs
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1; export ORACLE_HOME
ORACLE_SID=ORCL; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
PATH=$ORACLE_HOME/bin:$PATH; export PATH
#NLS_LANG="TRADITIONAL CHINESE_TAIWAN".ZHT16BIG5;export NLS_LANG
export NLS_LANG
#LC_CTYPE=zh_TW.Big5; export LC_CTYPE
export LC_CTYPE
#LC_ALL=zh_TW.UTF8; export LC_ALL
export LC_ALL
#LANG=zh_TW.Big5; export LANG
export LANG
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jdk/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH
umask 022
讓設定生效
代碼:
[oracle@oracle ~]$ source .bash_profile
再次以oracle用戶登錄,切換到/u01/database目錄準備安裝
代碼:
[root@oracle ~]#
su - oracle
[oracle@oracle ~]$ cd
/u01/database
執行./runInstaller安裝,開始進入圖形介面安裝
代碼:
[oracle@oracle database]$ ./runInstaller
Select Installation Method畫面:輸入Database Password和Confirm Password
Specify Inventory directory and credentials畫面:按下Next繼續
Product-Specific Prerequisite Checks畫面:環境驗證,有問題則會顯示在下方,如果沒問題就按下Next
Oracle Configuration Manager Registration畫面:Oracle
Enterprise雖然可以從官方網站下載安裝,但是下載Patch是要花錢的,此處只是安裝研究,按下Next過去就好
Summary畫面,按下Install開始安裝了
Install畫面
Database Configuration Assistant安裝畫面
Database Configuration Assistant部分安裝完成
ps:建議這邊可以先進入password Management修改sys、system相關帳號密碼
Execute Configurations Scripts畫面:要在終端機下用root執行兩個命令,然後才能按下OK繼續
請到終端機以root命令執行
代碼:
[root@oracle ~]#
/u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory to 770.
Changing groupname /u01/app/oraInventory to oinstall.
The execution of the script is complete
[root@oracle ~]#
/u01/app/oracle/product/11.1.0/db_1/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.1.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
修改/etc/oratab內容
代碼:
[root@oracle ~]# vi /etc/oratab
將
ORCL:/u01/app/oracle/product/11.1.0/db_1:N
改為
ORCL:/u01/app/oracle/product/11.1.0/db_1:Y
End of Isntallation畫面:安裝結束了
安裝完以後,oracle服務預設是沒有被啟動的,則需要手工進行啟動。請以oracle用戶身份登入,登入之後主要服務的啟動方式如下:
數據庫服務啟動 (這個執行需要點時間,執行完成會回提示字元)
代碼:
[root@localhost ~]# su - oracle
[oracle@oracle ~]$ dbstart
ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Usage: /u01/app/oracle/product/11.1.0/db_1/bin/dbstart ORACLE_HOME
Processing Database instance "orcl": log file
/u01/app/oracle/product/11.1.0/db_1/startup.log
監聽器 啟動
代碼:
[oracle@oracle bin]$ lsnrctl start
LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 20-2-2009 21:07:11
Copyright (c) 1991, 2007, Oracle. All rights reserved.
TNS-01106: 已啟動名稱為
LISTENER 的監聽器
Oracle服務需要自己設定,否則reboot後不會自動重啟
先切換到oracle帳號,手動測試幾個需要啟動的程式:
代碼:
[roor@oracle ~]# su - oracle
測試dbstart
代 碼:
[oracle@oracle ~]$ dbstart
ORACLE_HOME_LISTNER
is not SET, unable to auto-start Oracle Net Listener
Usage: /u01/app/oracle/product/11.1.0/db_1/bin/dbstart ORACLE_HOME
Processing Database instance "orcl": log file
/u01/app/oracle/product/11.1.0/db_1/startup.log
測試lsnrctl
代碼:
[oracle@oracle ~]$ lsnrctl start
LSNRCTL for Linux: Version
11.1.0.6.0 - Production on 26-FEB-2009 10:07:17
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.1.0.6.0 - Production
System parameter file is
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Log messages written to
/u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias
LISTENER
Version
TNSLSNR for Linux: Version 11.1.0.6.0 - Production
Start Date 26-FEB-2009
10:07:20
Uptime 0
days 0 hr. 0 min. 1 sec
Trace Level off
Security ON:
Local OS Authentication
SNMP
OFF
Listener Parameter File
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
The listener supports no services
The command completed successfully
測試 emctl
(Enterprise Manager Control是Oracle的Web管理介面)
代碼:
[oracle@oracle ~]$ emctl start dbconsole(出現問題訊息)
OC4J Configuration issue.
/u01/app/oracle/product/11.1.0/db_1/oc4j/j2ee/OC4J_DBConsole_oracle_ORCL not found.
解決方法如下,到root權限的終端機建立一個連結
代碼:
[root@oracle ~]# cd /u01/app/oracle/product/11.1.0/db_1/oc4j/j2ee
[root@oracle j2ee]# ln -s
OC4J_DBConsole_oracle_orcl OC4J_DBConsole_oracle_ORCL
回到oracle權限的終端機,再測試一次
代碼:
[oracle@oracle ~]$ emctl start dbconsole
EM Configuration issue. /u01/app/oracle/product/11.1.0/db_1/oracle_ORCL not
found.
還是不行
再到root權限的終端機,再設定一個連結
代 碼:
[root@oracle j2ee]# cd /u01/app/oracle/product/11.1.0/db_1
[root@oracle db_1]# ln -s
oracle_orcl oracle_ORCL
回到oracle權限的終端機,再測試一次 (會花點時間),正常了
代碼:
[oracle@oracle ~]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.1.0.6.0
Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved.
https://oracle:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ........... started.
------------------------------------------------------------------
Logs are generated in directory
/u01/app/oracle/product/11.1.0/db_1/oracle_ORCL/sysman/log
進 入em控制台(Web管理介面)點選瀏覽器https://localhost:1158/em
選擇Or you can add exception來增加例外網站
按下Add
Exception按鈕
按下Get Certificate嘗試取得憑證
按下Confirm
Security Exception(確認安全性例外)按鈕
輸入安裝過程中設定的密碼(Oracle有幾個預設的帳號,例如SYS、SYSTEM)
英文管理畫面
如果要看中文化面,可以logout,切換語系再login,再次用瀏覽器連上。
這就是繁體中文介面
看到管理介面 完成!
※※接下來建立一個稱為oracledb的Shell Script,讓開機的時候自動執行它
代碼:
root@lu-desktop:~# vim /u01/app/oracle/product/11.1.0/db_1/bin/oracledb
檔案內容如下
代碼:
#!/bin/bash
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
su oracle -c "/u01/app/oracle/product/11.1.0/db_1/bin/emctl start
dbconsole"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
修改Shell Script為可執行的:
代 碼:
root@lu-desktop:~# chmod a+x /u01/app/oracle/product/11.1.0/db_1/bin/oracledb
編輯開機自動執行設定檔/etc/rc.local
代碼:
root@lu-desktop:~# vim /etc/rc.local
加 入一行
代碼:
/u01/app/oracle/product/11.1.0/db_1/bin/oracledb start
重開機reboot後觀看服務是否會自動正常開啟
root@lu-desktop: reboot
使用netstat觀看服務是否有啟動
[oracle@test-CentOS5 ~]$ netstat -tunlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN 2696/Xvnc
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 2696/Xvnc
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 2696/Xvnc
tcp 0 0 0.0.0.0:8797 0.0.0.0:* LISTEN 7435/ora_d000_orcl
tcp 0 0 :::6000 :::* LISTEN -
tcp 0 0 :::80 :::* LISTEN -
tcp 0 0 :::6001 :::* LISTEN 2696/Xvnc
tcp 0 0 :::22 :::* LISTEN -
udp 0 0 0.0.0.0:38695 0.0.0.0:* -
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
udp 0 0 ::1:47801 :::* 7437/ora_s000_orcl
udp 0 0 ::1:35393 :::* 7403/ora_pmon_orcl
udp 0 0 :::16706 :::* 7431/ora_mmon_orcl
udp 0 0 :::25559 :::* -
udp 0 0 ::1:26857 :::* 7435/ora_d000_orcl
udp 0 0 :::5353 :::* -
或用ps aux | grep oracle檢查
代碼:
[root@oracle db_1]# ps aux | grep oracle
如果有出現類似下面的訊息,表示emctl正在啟動中
代碼:
root 5688 0.3
0.1 4888 1232 ? S
09:49 0:00 su oracle -c
/u01/app/oracle/product/11.1.0/db_1/bin/emctl start dbconsole
oracle 5689 11.3 0.1 4484 1224 ?
Ss 09:49 0:00 /bin/sh -f
/u01/app/oracle/product/11.1.0/db_1/bin/emctl start dbconsole
oracle 6101 0.0 0.2 6072 2396 ?
R 09:49 0:00
/u01/app/oracle/product/11.1.0/db_1/perl/bin/perl
/u01/app/oracle/product/11.1.0/db_1/bin/emctl.pl start dbconsole
確認完成後打開瀏覽器查看是否能否連上
完成!
參考來源:http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=16411
留言列表