# 掛載安裝光碟
mount /dev/cdrom /media
# 核心開發套件與相容性庫
cd /media/Server
rpm -Uvh glibc-2*.rpm
rpm -Uvh glibc-devel-2*.rpm
rpm -Uvh libaio-0*.rpm
rpm -Uvh libaio-devel-0*.rpm
rpm -Uvh compat-libstdc++-33-3*.rpm
rpm -Uvh compat-gcc-34-3*.rpm
rpm -Uvh compat-gcc-34-c++-3*.rpm
rpm -Uvh gcc-4*.rpm
rpm -Uvh gcc-c++-4*.rpm
rpm -Uvh make-3*.rpm
rpm -Uvh libXp-1*.rpm
rpm -Uvh openmotif-2*.rpm
rpm -Uvh compat-db-4*.rpm
rpm -Uvh setarch-2*.rpm
# /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.203.11 dbserver.example.com dbserver
# 備份
cp /etc/redhat-release /etc/redhat-release.bak
# 修改為紅帽 4 相容字串
echo "Red Hat Enterprise Linux AS release 4 (Nahant Update 8)" > /etc/redhat-release
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
useradd -u 54321 -g oinstall -G dba,oper -d /home/oracle -s /bin/bash oracle
mkdir -p /opt/oracle/or10g
chown -R oracle:oinstall /opt/oracle
chmod -R 775 /opt/oracle
passwd oracle # 設定複雜密碼
# Oracle 10g 推薦值
kernel.shmmni = 4096
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 = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
# 套用
sysctl -p
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
session required pam_limits.so
# Oracle Settings
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/or10g
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
# Shell limits for oracle user
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
# 以 oracle 用戶登入圖形介面
xhost +localhost
su - oracle
cd /path/to/10201_database_linux32
./runInstaller
依嚮導選擇:Enterprise Edition → 自訂安裝 → 指定 ORACLE_HOME → 建立資料庫 (General Purpose) → 完成。
# 編輯 $ORACLE_HOME/bin/dbstart
# 找到 ORACLE_HOME_LISTNER=$ORACLE_HOME 確認正確
# 或手動修正為實際路徑
#!/bin/bash
# chkconfig: 345 99 10
# description: Oracle 10g Auto Start/Stop
ORACLE_OWNER=oracle
ORACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/or10g
ORACLE_SID=orcl
export ORACLE_BASE ORACLE_HOME ORACLE_SID
export PATH=$ORACLE_HOME/bin:$PATH
case "$1" in
start)
echo -n "Starting Oracle: "
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
echo -n "Shutting down Oracle: "
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
echo "OK"
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
chmod +x /etc/init.d/oracle
chkconfig --add oracle
chkconfig --level 345 oracle on
service oracle start # 測試
# 將 N 改為 Y
orcl:/opt/oracle/or10g:Y
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP n; ALTER DATABASE OPEN;/var/log/messages、alert_SID.log、listener.log。