在RHEL4/Fedora4上安裝Oracle10g攻略(zt)

tolywang發表於2007-03-23
經過無數次的上網找教程,經過N次失敗,終於成功在RHEL4上成功安裝了Oracle10g資料庫並開啟WebEM服務,在Fedora4的安裝也透過了,現在把攻略記下來很有必要。


第一步,正確配置作業系統
作業系統版本:Red Hat Enterprise Linux AS release 4 (Sentenz)
       Kernel 2.6.9-4.EL on an i686

按照常規來安裝作業系統,記得要安裝開發工具(gcc等必要工具).


必要的硬體資訊檢查:

檢查內容


最小值


檢查命令參考

實體記憶體


512M


# grep MemTotal /proc/meminfo

交換空間


1.0 GB或者2倍記憶體大小


# grep SwapTotal /proc/meminfo

/tmp 空間


400 MB


# df -k /tmp

軟體所需空間


2.5 GB


# df -k (空間越大越好,如果是正式系統,應該進行詳盡的規劃)

資料庫檔案


1.2 GB


# df -k (空間越大越好,如果是正式系統,應該進行詳盡的規劃)


檢查完如上各項之後, 應該修改核心引數.執行如下命令:

#vi /etc/sysctl.conf
#註釋:#表示使用root使用者操作,$表示使用oracle 使用者進行操作.提示符後面的藍色部分表示需要輸入的命令,以下同.

在該檔案末尾加入如下內容:

#-----------Begin from here--------------------------------------
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
#--------------End here--------------------------------------------

編輯完之後,儲存,執行 # /sbin/sysctl -p 命令操作來使我們所做的變更生效.

注:上面kernel.shmmax/kernel.sem等是典型的核心引數配置.您可能需要根據您的實際環境進行適當的變動.

關於這些核心引數的說明在Oracle的Oracle9i Installation Guide Release 2 (9.2.0.1.0) for UNIX Systems
中有很詳細的說明.( )

然後,應該檢查一下上面的操作是否正確:

# /sbin/sysctl -a | grep sem
# /sbin/sysctl -a | grep shm
# /sbin/sysctl -a | grep file-max
# /sbin/sysctl -a | grep ip_local_port_range


為Oracle使用者設定Shell的限制

一般來說,出於效能上的考慮,還需要需要進行如下的設定,以便改進Oracle使用者的有關 nofile(可開啟的檔案
描述符的最大數)和nproc(單個使用者可用的最大程式數量)

# vi /etc/security/limits.conf
# 新增如下的行

* soft nproc 2047

* hard nproc 16384

* soft nofile 1024

* hard nofile 65536




新增如下的行到/etc/pam.d/login 檔案:

session required /lib/security/pam_limits.so



編輯 /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


之後,執行$ unlimit 驗證一下.

檢查並安裝相關補丁

在這個版本的RHEL上安裝Oracle,必須要有幾個軟體包. 確認以下 rpm包都已經安裝:

make-3.79
binutils-2.11
openmotif-2.2.2-16
setarch-1.3-1
compat-db-4.0.14.5
compat-gcc-7.3-2.96.122
compat-gcc-c++-7.3-2.96.122
compat-libstdc++-7.3-2.96.122
compat-libstdc++-devel-7.3-2.96.122

# rpm -qa | grep compat
# 在我的機器上輸出如下:
compat-gcc-c++-7.3-2.96.122
compat-libstdc++-7.3-2.96.122
compat-libstdc++-devel-7.3-2.96.122
compat-glibc-7.x-2.2.4.32.5
compat-db-4.0.14-5
compat-gcc-7.3-2.96.122

# rpm -qa | grep openmotif
openmotif-devel-2.2.2-16
openmotif-2.2.2-16

# rpm -qa | grep setarch
setarch-1.3-1

上面顯示的內容是在筆者已經安裝了具體的RPM包之後的結果.一般情況下,你的系統上的輸出結果和這個不同.如果個
別包沒有安裝,把系統安裝光碟mount上,找到具體的軟體包(大多數在第三張光碟上),然後利用如下的命令來安裝相應
的包:

# rpm -ivh compat.....rpm

要額外注意的是,這些軟體包之間是有依賴性的,先後的順序要找好.否則會報告不能安裝的錯誤.

此外,最好驗證一下 gcc和glibc的版本(要求是gcc-3.2.3-2 或者更高)

#gcc -v
#rpm -q glibc

建立使用者和相關的組

# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/useradd -g oinstall -G dba oracle 

如果只是測試目的的話,不建立oinstall組也沒什麼. 不過還是規範一點比較好.如果oracle 使用者和dba組等已經存在,作
適當的調整即可.

檢查並調整環境變數

登入為oracle使用者
# su – oracle
$ cd
$ vi .bash_profile

#新增如下內容,你的具體值應該不會和這個完全相同.

export ORACLE_BASE=/u/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1
export ORACLE_SID=TEST
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export LC_CTYPE=en_US.UTF-8

然後執行
$ source .bash_profile
使環境變數生效. /u/app/oracle 等目錄應該建立好並做合適的授權.

開始安裝10g

$ sh /u/install/runInstaller -ignoreSysPrereqs (此處參數列明不檢查作業系統版本)

如果不能出現安裝畫面,檢視本文後面的FAQ。

非常值得稱道的是,10g的安裝相比以前的多了一個 Checking operating system certification 的步驟。特別實用。
安裝檔案會自動檢測所需的條件。如果有不符合的地方,安裝程式會報告給你.並會給出具體原因。大大減少了出錯的可能.
===========

其他的步驟比較清晰,不再贅述.

最後系統會提示你執行root.sh檔案.按照提示做即可.


FAQ (在Linux平臺安裝Oracle比較常見)

1. 不能啟動安裝介面.執行runInstaller提示資訊類似如下:

xlib:connection to "localhost:0.0" refused by server
xlib:client is not authorized to connect to server

Exception in thread "main" java.lang.InternalError:can't connect to x11 window server using "localhost:0.0"
at .......

解決辦法: 設定你的DISPLAY環境引數.# export DISPLAY= your_IPaddress :0.0把your_IPaddress換成你的IP.或者
用root簡單的執行一下# xhost + (要注意這樣會有安全上的隱患)

建立資料庫:$ORACLE_HOME/bin/dbca
啟動WebEM:$ORACLE_HOME/bin/emctl start dbconsole


2.安裝介面顯示很多"口口"樣子的亂碼

解決辦法:檢視locale輸出
# locale
LANG=en_US.UTF-8
LC_CTYPE=zh_CN.GB18030
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

執行#export LC_CTYPE=en_US.UTF-8 然後重新呼叫安裝程式.


3. 用IE登入Linux伺服器上的em出現亂碼

 在Linux(Unix) 環境下成功安裝了Oracle 10g,從windows下用IE瀏覽器登入 10g 的em, 按鈕是"口口"這樣的方框.

解決辦法:
主要原因是Oracle10g自帶的JavaRuntime的問題
(1)停止em服務-emctl stop dbconsole
(2)把相關目錄(RHEL4裡是/etc/java/)下的font.properties用fontproperties.zh_CN.Redhat8.0或者font.properties.zh代替
(3)刪除$ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/em/em/cabo/images/
cache/zhs中的gif檔案
(4)重起服務 emctl start dbconsole



開機自動啟動Oracle10g方法(三種)
一、
1. 建立檔案/etc/oratab
新增

Code: [Copy to clipboard]
#新增如下內容到/etc/oratab檔案中,
#$ORACLE_SID是你的Oracle資料庫的sid
#$ORACLE_HOME是你的Oracle資料庫的Oracle_home
#Y表示要求在系統啟動的時候啟動Oracle資料庫.N表示不要在系統啟動的時候啟動Oracle
$ORACLE_SID:$ORACLE_HOME:Y

2. 修改檔案/etc/rc.local新增一下兩行

Code: [Copy to clipboard]
##
## 關於su的具體命令參看linux的manual文件
##
su - oracle -c 'dbstart'
su - oracle -c 'lsnrctl start'

3. 在本機使用dbstart,和dbshut測試設定的準確性.

Code: [Copy to clipboard]
[oracle@tzcenter oracle]$ dbshut

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Nov 11 21:02:35 2004

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> Connected.
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
Database "webora9" shut down.
[oracle@tzcenter oracle]$ dbstart

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Nov 11 21:02:43 2004

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> Connected to an idle instance.
SQL> ORACLE instance started.

Total System Global Area 437327188 bytes
Fixed Size 451924 bytes
Variable Size 134217728 bytes
Database Buffers 301989888 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production

Database "webora9" warm started.
[oracle@tzcenter oracle]$

二、

先z在oracle使用者目錄裡建立dbstart.sh , 內容如下:
#!/bin/sh
export oracle_HOME=/home/oracle/product/10.1.0/db_1
export oracle_SID=oracle10
$oracle_HOME/bin/sqlplus /nolog<
connect system/manager as sysdba
startup
exit
EOF
$oracle_HOME/bin/lsnrctl start

然後在local.rc裡面加一行:
su -c /home/oracle/dbstart.sh - oracle

這樣每次啟動的時候就會自動啟動oracle和監聽,記得修改相應的路徑啊。

三、(官方文件)
In this article I'll describe the installation of oracle Database 10g Release 2 (10.2.0.1) on RedHat Advanced Server 4.0. The article is based on a server installation with a minimum of 2G swap, secure linux disabled and the following package groups installed:

X Window System
GNOME Desktop Environment
Editors
Graphical Internet
Text-based Internet
Server Configuration Tools
Development Tools
Administration Tools
System Tools
Alternative installations may require additional packages to be loaded in addition to the ones listed below.

Download Software
Unpack Files
Hosts File
Set Kernel Parameters
Setup
Installation
Post Installation
Download Software
Download the following software:

oracle Database 10g Release 2 (10.2.0.1) Software
Unpack Files
Unzip the files:

unzip 10201_database_linux32.zip
You should now have a single directory (db/Disk1) containing installation files.

Hosts File
The /etc/hosts file must contain a fully qualified name for the server:


Set Kernel Parameters
Add the following lines to the /etc/sysctl.conf file:

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
Run the following command to change the current kernel parameters:

/sbin/sysctl -p
Add the following lines to the /etc/security/limits.conf file:

* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536
Add the following line to the /etc/pam.d/login file, if it does not already exist:

session required /lib/security/pam_limits.so
Note by Kent Anderson: In the event that pam_limits.so cannot set privilidged limit settings see Bug 115442.

Disable secure linux by editing the /etc/selinux/config file, making sure the SELINUX flag is set as follows:

SELINUX=disabled
Alternatively, this alteration can be done using the GUI tool (Applications > System Settings > Security Level). Click on the SELinux tab and disable the feature.

Setup
Install the following packages:

# From RedHat AS4 Disk 2
cd /media/cdrom/RedHat/RPMS
rpm -Uvh setarch-1.6-1.i386.rpm
rpm -Uvh compat-libstdc++-33-3.2.3-47.3.i386.rpm
rpm -Uvh make-3.80-5.i386.rpm
rpm -Uvh glibc-2.3.4-2.i386.rpm

# From RedHat AS4 Disk 3
cd /media/cdrom/RedHat/RPMS
rpm -Uvh openmotif-2.2.3-6.RHEL4.2.i386.rpm
rpm -Uvh compat-db-4.1.25-9.i386.rpm
rpm -Uvh libaio-0.3.102-1.i386.rpm
rpm -Uvh gcc-3.4.3-9.EL4.i386.rpm

# From RedHat AS4 Disk 4
cd /media/cdrom/RedHat/RPMS
rpm -Uvh compat-gcc-32-3.2.3-47.3.i386.rpm
rpm -Uvh compat-gcc-32-c++-3.2.3-47.3.i386.rpm
Create the new groups and users:

groupadd oinstall
groupadd dba
groupadd oper

useradd -g oinstall -G dba oracle
passwd oracle
Create the directories in which the oracle software will be installed:

mkdir -p /u01/app/oracle/product/10.2.0/db_1
chown -R oracle.oinstall /u01
Login as root and issue the following command:

xhost +
Login as the oracle user and add the following lines at the end of the .bash_profile file:

# oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

oracle_BASE=/u01/app/oracle; export oracle_BASE
oracle_HOME=$oracle_BASE/product/10.2.0/db_1; export oracle_HOME
oracle_SID=TSH1; export oracle_SID
oracle_TERM=xterm; export oracle_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$oracle_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$oracle_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$oracle_HOME/JRE:$oracle_HOME/jlib:$oracle_HOME/rdbms/jlib; export CLASSPATH
#LD_ASSUME_KERNEL=2.4.1; export LD_ASSUME_KERNEL

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
Installation
Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable:

DISPLAY=:0.0; export DISPLAY
Start the oracle Universal Installer (OUI) by issuing the following command in the Disk1 directory:

./runInstaller
During the installation enter the appropriate oracle_HOME and name then continue installation.

Post Installation
Edit the /etc/oratab file setting the restart flag for each instance to 'Y':

TSH1:/u01/app/oracle/product/10.2.0/db_1:Y
Create a file called /etc/init.d/dbora containing the following:

#!/bin/sh
# description: oracle auto start-stop script.
# chkconfig: - 20 80
#
# Set ORA_HOME to be equivalent to the $oracle_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
;;
'stop')
# Stop the oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esac
Use chmod to set the privileges to 750:

chmod 750 /etc/init.d/dbora
Link the file into the appropriate run-level script directories:

ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
Associate the dbora service with the appropriate run levels:

chkconfig --level 345 dbora on
The relevant instances should now startup/shutdown automatically at system startup/shutdown.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-84535/,如需轉載,請註明出處,否則將追究法律責任。

相關文章