Ubuntu上Oracle10g安裝指南

安裝體驗版的Oracle 10g
體驗版的Oracle10g比較適合在本子上或者開發的機器上使用,它提供了Oracle10g的大多數功能,並且僅需要更小的安裝空間和運行環境。
[編輯] 下載體驗版Oracle 10g的deb包


從下列地址下載:


http://www.oracle.com/technology/software/products/database/oracle10g/index.html
http://www.oracle.com/technetwork/database/express-edition/downloads/102xelinsoft-102048.html
根本不好下載,每次註冊時都提示用戶名已被使用。


用gmail的郵箱,密碼8位大寫小寫數字——by zero_coder
[編輯] 安裝下載的deb包
安裝oracle很簡單,比如下載的文件在/home/xxx/download目錄,只要執行即可:


sudo dpkg -i /home/xxx/download/oracle-xe-universal_10.2.0.1-1.0_i386.deb
安裝的時候需要注意控制檯輸出,在安裝過程中需要設定監聽端口和密碼。 如果沒有提示設置,可以手工設置 /etc/init.d/oracle-xe configure。 安裝後如果一切正常的話Oracle應該會自動啓動,是用ps命令可以查看當前運行的oracle進行,判斷Oracle是否正確運行:


sudo ps aux |grep oracle


輸出的結果應該類似如下:


oracle   16282  0.0  0.2  22076  6068 ?        Ss   22:08   0:00 /usr/lib/o
oracle   16290  0.0  0.4 671464 10248 ?        Ss   22:08   0:00 xe_pmon_XE
oracle   16292  0.0  0.4 670772  8828 ?        Ss   22:08   0:00 xe_psp0_XE
oracle   16294  0.0  0.9 670772 20028 ?        Ss   22:08   0:00 xe_mman_XE
oracle   16296  0.0  0.5 672844 11400 ?        Ss   22:08   0:00 xe_dbw0_XE
oracle   16298  0.0  1.3 686324 28228 ?        Ss   22:08   0:00 xe_lgwr_XE
oracle   16300  0.0  0.6 670780 14000 ?        Ss   22:08   0:00 xe_ckpt_XE
oracle   16302  0.0  1.4 671316 29752 ?        Ss   22:08   0:00 xe_smon_XE
oracle   16304  0.0  0.6 670776 14096 ?        Ss   22:08   0:00 xe_reco_XE
oracle   16306  0.0  1.1 672376 22916 ?        Ss   22:08   0:00 xe_cjq0_XE
oracle   16308  0.2  2.0 673520 43060 ?        Ss   22:08   0:00 xe_mmon_XE
oracle   16310  0.0  0.4 670772  9944 ?        Ss   22:08   0:00 xe_mmnl_XE
oracle   16312  0.0  0.4 671440  8952 ?        Ss   22:08   0:00 xe_d000_XE
oracle   16314  0.0  0.4 671324  8668 ?        Ss   22:08   0:00 xe_s000_XE
oracle   16316  0.0  0.4 671324  8676 ?        Ss   22:08   0:00 xe_s001_XE
oracle   16318  0.0  0.4 671320  8668 ?        Ss   22:08   0:00 xe_s002_XE
oracle   16320  0.0  0.4 671320  8676 ?        Ss   22:08   0:00 xe_s003_XE
oracle   16333  0.0  0.4 670772  9956 ?        Ss   22:08   0:00 xe_qmnc_XE
oracle   16353  0.0  0.5 670772 11000 ?        Ss   22:08   0:00 xe_q000_XE
oracle   16358  0.0  0.4 670772  9284 ?        Ss   22:08   0:00 xe_q001_XE




默認安裝好以後,Oracle會自動運行,如果Oracle沒有啓動起來,需要手動去運行init.d下面的腳本:


sudo /etc/init.d/oracle-xe start
如果輸出如下則表示啓動成功:


Starting Oracle Net Listener.
Starting Oracle Database 10g Express Edition Instance.


[編輯] 使用網頁瀏覽器訪問Oracle的http管理界面
啓動firefox或者其他瀏覽器,在地址欄輸入地址(此處的8080端口是在安裝時給定的):


http://localhost:8080/apex


就可以進入到管理界面,在這個管理界面中,可以完成如創建數據庫、用戶管理、表管理和存儲與運行時管理的諸多配置工作。注意默認的安裝設定sys/system是同一個密碼,這個要注意。




詳細安裝方式請參考Oracle的官方說明。


[編輯] 安裝企業版的Oracle 10g
written by flexitime, 2007-10-15〔http://flexitime.blog.sohu.com/)


今天終於在Ubuntu7.04上成功安裝Oracle10g。爲了安裝Oracle,花了不少時間到網上查資料,不過更多的時間用於自己的真正實踐,當中走了不少的彎路,現在把安裝過程記下來。(我一共在兩臺機器上安裝了三次,這篇文章是在安裝第三次的時候一邊操作一邊在另外的電腦上寫的) 在網上有不少Oracle的安裝教程,但這些教程更多的只是針對較低版本的Ubuntu(如6.X,5.X等等),而且安裝Oracle的過程中也有些問題是沒有描述和解決的。因此,我覺得有必要自己寫一下安裝我的實踐過程,當然,我主要還是參考了孫高勇先生的《Oracle 10g for Ubuntu安裝指南》的內容。 現在開始吧!


[編輯] 第一步,我們需要一個Ubuntu
當然在網上可以免費下載得到,我用的是桌面版,而不是網站上提供的服務器版,很多剛由Windows轉過來的朋友可能會認爲服務器版總會比桌面版多些功能,爲此而下載了服務版來用。其實Ubuntu網上提供的下載卻不然,服務器版只不過比桌面版多了amp的軟件(a-apache, m-mysql, p-php),但卻沒有圖形用戶界面(可以另外再安裝,但比較麻煩)。爲此,我使用了桌面版的Ubuntu來完成這次的安裝。安裝的時候雖然有中文可以選擇,但我還是選用了英文,這不是我的英文特別好(再好也好不過母語)的緣故,而是因爲Ubuntu的漢化未如理想,漢字的支持也不怎麼樣(特別是在純 CUI模式下)。所以還是用英文會更好(不必擔心,在英文版Ubuntu下一樣可以用中文的輸入法,同樣也可以讓Oracle支持中文),要安裝 ubuntu,可以參考網上的其它教程。


[編輯] 第二步,安裝必需的包
apt-get install gcc make binutils lesstif2 libc6 libc6-dev rpm libmotif3 libaio1 libstdc++6 alien
Note: 在我使用Ubuntu 10.10安裝oracle時,會報一個makefile到錯誤。這是因爲新版本到ubuntu默認安裝了libstdc++6,而oracle安裝程序要使用的是libstdc++5,所以如果遇到這個錯誤可以執行 sudo apt-get install libstdc++5 然後在安裝程序的報錯對話框中點retry就可以繼續了。




64位:sudo apt-get install gcc libaio1 lesstif2 lesstif2-dev make libc6 libc6-i386 libc6-dev-i386 libstdc++5 lib32stdc++6 lib32z1 ia32-libs


[編輯] 第三步,創建用戶
# adduser oracle
正在添加用戶"oracle"...
正在添加新組"oracle" (1001)...
正在添加新用戶"oracle" (1002) 到組"oracle"...
創建主目錄"/home/oracle"...
正在從"/etc/skel"複製文件...
輸入新的 UNIX 密碼: 
重新輸入新的 UNIX 密碼: 
passwd:已成功更新密碼
Changing the user information for oracle
Enter the new value, or press ENTER for the default
Full Name []: oracle
Room Number []: 
Work Phone []: 
Home Phone []: 
Other []: 
adduser 命令系統會自動創建oracle用戶的文件


[編輯] 第四步,修改設置
[編輯] A.設置swap區
Oracle10g至少需要500M的內存和400M的交換空間,要查看swap區是否足夠大小,用 fdisk -l 命令去查,如果小於400M的空間,那麼就要增加swap的大小 重設交換分區可以使用如下操作:


dd if=/dev/zero of=tmp_swap bs=1k count=900000
chmod 600 tmp_swap
mkswap tmp_swap
swapon tmp_swap
完成安裝以後,可以釋放這個空間:


swapoff tmp_swap
rm tmp_swap
count 值是根據你需要調整的交換分區大小而定。


[編輯] B.修改 sysctl.conf
添加如下的行到/etc/sysctl.conf 中:


kernel.shmmax = 3147483648
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
[編輯] C.修改 limits.conf
添加如下的行到/etc/security/limits.conf中:


* soft nproc 2407
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536
[編輯] D.讓修改生效
修改了以上文件後,必須讓其生效,或重啓系統,或切換到 root 用戶下用以下的方式改變內核運行參數: sysctl -p


[編輯] E.產生相應的軟連接
創建一個文件如 kk,內容如下:


#!/bin/bash
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
mkdir /etc/rc.d
ln -s /etc/rc0.d /etc/rc.d/rc0.d
ln -s /etc/rc2.d /etc/rc.d/rc2.d
ln -s /etc/rc3.d /etc/rc.d/rc3.d
ln -s /etc/rc4.d /etc/rc.d/rc4.d
ln -s /etc/rc5.d /etc/rc.d/rc5.d
ln -s /etc/rc6.d /etc/rc.d/rc6.d
ln -s /etc/init.d /etc/rc.d/init.d
創建後,切換到 root 用戶去執行一下。


[編輯] F.創建RedHat的版本聲明文件
在/etc/redhat-release中添加以下語句,以使安裝程序認爲正在一個RedHat的系統上安裝:


Red Hat Linux release 3.1 (drupal)
[編輯] G.修改環境變量
編輯 /home/oracle/.bashrc,增加以下export 的內容。 (注意,在Ubnutu 7.04中用戶的profile文件已改名爲~/.profile,有很多安裝教程都是用 ~/.bash_profile,在7.04中不行的)


export ORACLE_HOME=/opt/ora10
export ORACLE_OWNER=oracle
export ORACLE_SID=ora1
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH


[編輯] 第五步,開始安裝
註銷原來的用戶,改用oracle用戶登錄。用env查看一下環境變量是否生效。 然後進行/ora_ins_disk中進行安裝,執行安裝腳本時還需要以root權限創建目錄/opt/ora10


sudo mkdir /opt/ora10
sudo chown -R oracle:oracle /opt/ora10
sudo chmod -R 770 /opt/ora10 
cd/ora_ins_disk
./runInstaller
在安裝過程中,請使用 Advanced Installation,然後一路按默認的設置進行往下設置,到窗單名爲 “Specify Database Configuration Options”的時候,要修改以下設置: Database Character Set 中選擇 Simplified Chinese ZHS16GBK 在安裝的後期,系統提示需要用 root 用戶去運行兩個腳本文件orainstRoot.sh和root.sh,安裝完畢後,Oracle是正常啓動着的,你可以試一下連接數據庫,同時也可以使用瀏覽器去設置一下Oracle,(url:http: //localhost:1158/em/)(Oracle 10g與之前的版本都不一樣,使用WEB頁的企業管理器來代替以前的C/S版JAVA企業管理器)


[編輯] 第六步,設置自啓動
創建自啓動腳本 創建 oracledb 腳本到/etc/init.d/oracledb,內容如下


#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface


export ORACLE_HOME=/opt/ora10
export ORACLE_SID=ora1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH


ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "[Oracle Error] dbstart command does not exist, quitting..."
exit 1
else
echo "[Oracle Info] dbstart existance check OK"
fi


# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo "[Oracle Info] Starting oracle"
echo "[Oracle Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
if [ $? -ne 0 ] 
then
echo "[Oracle Error] listener failed to start"
exit 1
else 
echo "[Oracle Info] listener start OK"
fi


su $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
echo "[Oracel Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
if [ $? -ne 0 ] 
then
echo "[Oracle Error] dbstart failed to start"
exit 1
else
echo "[Oracle Info] dbstart OK"
fi
touch /var/lock/oracle
echo "[Oracle Info]su $ORA_OWNR -c ""$ORACLE_HOME/bin/emctl start dbconsole"
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
if [ $? -ne 0 ] 
then
echo "[Oracle Error] dbconsole failed to start"
exit 1
else
echo "[Oracle Info] dbconsole start OK"
fi
echo "[Oracle Info] Starting oracle ended OK"
;;
stop)
# Oracle listener and instance shutdown
echo "[Oracle Info] Shutdown Oracle: "
echo "[Oracle Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/lsnrctl stop"
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
echo "[Oracle Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f /var/lock/oracle
echo "[Oracle Info]su $ORA_OWNR -c ""$ORACLE_HOME/bin/emctl stop dbconsole"
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "[Oracle Info] Shutdown Oracle ended OK"
;;
reload|restart)
echo "[Oracle Info]: $1 oracle"
$0 stop
$0 start
;;
*)
echo "[Oracle Error] Unknown context: $1"
echo "[Oracle Info]  Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0




設置權限,放到啓動腳本中去


chmod 755 /etc/init.d/oracledb
update-rc.d oracledb defaults 99
還需要編輯一下/etc/oratab,把其中的N改成Y,不然上述腳本中所調用的$ORACLE_HOME/bin/dbstart在執行時不會自動啓動相應的數據庫實例(這裏的數據庫實例是ora1)。文件內容如下:


#






# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.


# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
ora1:/opt/ora10:Y
我的 oralce 的安裝盤中可能有些問題,所以如果只用上述的腳本是不能啓動 listener的,要修改一下: 修改 /opt/ora10/bin/dbstart文件 查找:(本步驟修改後需重新安裝?——(不需要重新安裝呀Sutra 2010年6月10日 (四) 21:31 (CST)))


# Set this to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
將其改爲:


# Set this to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$ORACLE_HOME
設置後,測試一下


/etc/init.d/./oracledb reload
如果一切正常的話,會關閉一次Oracle又再重新打開。
發佈了30 篇原創文章 · 獲贊 13 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章