在ubuntu 8.04下安裝Oracle 11g
本文是參考了:http://hi.baidu.com/wuxicn/blog/item/0cfdc24ac5ae372609f7ef94.html"文章,是翻譯下面的這篇文章的。我主要參考的是中文的,我只是在實際操作中做了一點小小的修改,在此表示感謝!紫色為我的注釋。
原文是英文,地址是:
http://www.pythian.com/blogs/968/instal ... ardy-heron,(轉載注明出處,謝謝??! )
共9步:
Step 1
下載和安裝 Ubuntu 8.04 Hardy Heron (x86-32位) 版。略。
Step 2
下載Oracle 11g: Download Oracle 11g for Linux (x86, 32-bit).
現不要急著解壓,一會我會告訴你解壓在哪的。
Step 3
修改X server 的默認設置,點菜單的System -> Administration -> Login Window(系統->管理->登錄窗口),選擇“Security(安全)”選項卡,取消“Deny TCP connections to the Xserver(拒絕TCP連接到X服務器)”的勾,重啟Xserver(或者重啟系統)。然后在終端輸入:
user@hardy:~$ xhost +127.0.0.1
127.0.0.1 being added to access control list
Step 4
打開終端,轉換為超級用戶:(注意,這里用sudo su -而不是sudo -s是有原因的:sudo su - 將用戶轉換為超級用戶,并新起一個會話(空的會話),而不是像sudo -s那樣將當前會話傳遞個新的超級用戶,減少環境變量可能造成的影響和危害。
user@hardy:~$ sudo su -
[sudo] password for user:
root@hardy:~# apt-get update
...
root@hardy:~# apt-get dist-upgrade
...
root@hardy:~# reboot
Step 5
用apt安裝一些必要的工具:
user@hardy:~$ sudo su -
[sudo] password for user:
root@hardy:~# apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm
...
root@hardy:~#
Step 6
在裝完那些工具以后,我們需要做的就是修改一些Ubuntu的/bin/sh的默認連接,千萬不要略過這一步,否則安裝的時候會出現很多錯誤。
root@hardy:~# cd /bin
root@hardy:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-04-28 19:59 /bin/sh -> dash
root@hardy:/bin# ln -sf bash /bin/sh
root@hardy:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-05-01 22:51 /bin/sh -> bash
如果你想知道為什么Ubuntu用dash作為默認的shell,看這個:a detailed explanation of why dash is the default system shell 。
Step 7
增加用戶和組,并修改一些配置。這一步很重要!如果不是很有把握,不要隨便改。(為了便于解釋,增加了行號):
01 root@hardy:/bin# cd
02 root@hardy:~# pwd
/root
04 root@hardy:~# addgroup oinstall
Adding group `oinstall' (GID 1001) ...
Done.
07 root@hardy:~# addgroup dba
Adding group `dba' (GID 1002) ...
Done.
10 root@hardy:~# addgroup nobody
Adding group `nobody' (GID 1003) ...
Done.
13 root@hardy:~# usermod -g nobody nobody
14 root@hardy:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
15 root@hardy:~# mkdir /home/oracle
16 root@hardy:~# chown -R oracle:dba /home/oracle
17 root@hardy:~# ln -s /usr/bin/awk /bin/awk
18 root@hardy:~# ln -s /usr/bin/rpm /bin/rpm
19 root@hardy:~# ln -s /usr/bin/basename /bin/basename
20 root@hardy:~# mkdir /etc/rc.d
21 root@hardy:~# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
22 root@hardy:~# mkdir -p /u01/app/oracle
23 root@hardy:~# chown -R oracle:dba /u01
24 root@hardy:~#
Lines 04-12: 增加我們需要的用戶和組
Line 13: 讓nobody用戶的組變為nobody,這樣Oracle的安裝程序不會出問題。Ubuntu默認nobody的組是nogroup。
Lines 14-18: 創建一個oracle用戶。注意,oracle用戶的HOME目錄不要與ORACLE_HOME相同。
Lines 19-23: 創建一些Oracle安裝程序需要的工具的連接。因為Oracle安裝程序是為Red Hat準備的,所以有些工具的位置和Ubuntu不一樣。
Finally, on lines 24-25 創建ORACLE_BASE目錄。
Step 8
修改一些系統默認值。這些修改將會增加系統文件描述符的數量、增加共享內存大小和修改一些網絡子系統參數。這些修改是否會對你的系統帶來影響我就不得而知了。將下面這些增加到/etc/sysctl.conf文件的末尾:
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
再增加下面這些到/etc/security/limits.conf文件末尾:
oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
為了強制使用剛才我們增加的東西,我們再增加下面這些到/etc/pam.d/login文件末尾:
session required /lib/security/pam_limits.so
session required pam_limits.so
然后通過命令:sysctl -p 讓剛才增加的東西生效:
root@hardy:~# sysctl -p
kernel.printk = 4 4 1 7
kernel.maps_protect = 1
fs.inotify.max_user_watches = 524288
vm.mmap_min_addr = 65536
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
root@hardy:~#
Step 9
現在我們將剛才下載的oracle11g的安裝包解壓到/home/oracle/install/目錄下。然后進入目錄,設置DISPLAY參數,開始安裝:
root@hardy:~# cd /home/oracle
root@hardy:/home/oracle# chown -R oracle:dba install
用oracle用戶登陸,(不然會出安裝界面出不來)
oracle@hardy:~$ export DISPLAY=127.0.0.1:0.0
oracle@hardy:~$ pwd
/home/oracle
oracle@hardy:~$ ls -l
total 4
drwxr-xr-x 6 oracle dba 4096 2007-09-18 18:50 install
oracle@hardy:~$ cd install
oracle@hardy:~/install$ ls -l
total 28
drwxr-xr-x 11 oracle dba 4096 2007-08-06 16:02 doc
drwxr-xr-x 5 oracle dba 4096 2007-08-03 13:28 install
drwxr-xr-x 2 oracle dba 4096 2007-09-18 18:52 response
-rwxr-xr-x 1 oracle dba 2911 2007-08-03 13:28 runInstaller
drwxr-xr-x 14 oracle dba 4096 2007-08-03 13:27 stage
-rw-r--r-- 1 oracle dba 4835 2007-08-06 18:19 welcome.html
oracle@hardy:~/install$ ./runInstaller -ignoreSysPrereqs
輸入完上面命令后,就進入了Oracle 的同一安裝程序了(OUI),不要急,繼續按照本文一步一步的通過安裝:
注意:OUI安裝完后,并不是真正完全安裝完成,還需要就行最后的收尾工作(在最后有),而且這是必須做的工作!
點(Next)下一步。
修改“Specify Operating System group name:”為:"dba",然后點"Next".
按照上圖設置,點下一步。
選擇"Enterprise Edition",然后下一步。
安圖設置,下一步。
繼續下一步。
等待系統檢查,不要擔心有錯誤和警告。
將檢查到的所有非“Succeeded”的都打上勾,下一步。
,下一步。在這一步選"Create a Database"來安裝數據庫。
([color=red]原文是通過netca建立監聽,dbca建庫,我第一次也是這樣做的,dbca建庫時會報錯,因為ubutunbu 不支持RPM包)。[/color]
將所有組都設為:dba,下一步。
現在可以點“Install”了:)時間比較長。
到了這一步不要記著點“OK”,需要做下面操作:(另起一個終端,用sudo su - 轉為超級用戶)
root@hardy:~# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory to 770.
Changing groupname of /u01/app/oraInventory to dba.
The execution of the script is complete
root@hardy:~# /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.
root@hardy:~#
好了,這個完成后可以點“OK”了。
安后點“Exit”退出OUI,現在可以祝賀你,OUI安裝完成了:)但是還是不要急,記住咱們還有收尾工作需要做。
在/etc/profile文件中加入下面幾句:
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export PATH=$PATH:/u01/app/oracle/product/11.1.0/db_1/bin
創建一個Oracle 11g數據庫的啟動腳本,名字可以叫做:oracledb,在/u01/app/oracle/product/11.1.0/db_1/bin下建立文件:oracledb,內容:
#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab
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"
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"
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
修改腳本為可執行的:
root@hardy:~# chmod a+x /u01/app/oracle/product/11.1.0/db_1/bin/oracledb
如果你希望開機自動啟動Oracle 11g數據庫,那么就作下面的工作:
root@hardy:~# ln -s /u01/app/oracle/product/11.1.0/db_1/bin/oracledb /etc/init.d/oracledb
root@hardy:~# sudo sysv-rc-conf --level 2345 oracledb on
如果沒有sysv-rc-conf命令,就apt-get一個。
最后,增加你自己的用戶名到dba組:
root@hardy:~# usermod -G dba -a user
好了,至此,Oracle 11g就安裝完了。重新登錄后,你就可以使用oracle的命令了。
(ORACLE_SID=orcl 是你安裝時候設置的值)
oracle@hardy:~$ export ORACLE_SID=orcl
oracle@hardy:~$ sqlplus '/as sysdba'
SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 5 02:39:27 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>connect /as sysdba
Connected to an idle instance.
SQL>startup 啟動數據庫命令。
.
ORACLE instance started.
Total System Global Area 418484224 bytes
Fixed Size 1300324 bytes
Variable Size 281020572 bytes
Database Buffers 130023424 bytes
Redo Buffers 6139904 bytes
Database mounted.
Database opened.
oracle@hardy:~$ export ORACLE_SID=orcl
oracle@hardy:~$ emctl start dbconsole
啟動EM,地址為https://yourip:1158/em/console.這樣你就可以通過IE登陸了。不過界面為亂碼。呵呵?。〗鉀Q方法自己在網上找吧??!
如果你看到了上面的結果,證明你的oracle安裝成功了。
sudo apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm
2.
4.
mkdir /home/oracle
chown -R oracle:dba /home/oracle
5.
mkdir /etc/rc.d
for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
10.
以上命令需以root用戶執行,接下來切換至oracle用戶.
11.切換至安裝目錄,開始安裝.我選擇了英語作為安裝時顯示的語言.
12.安裝過程中檢測到系統未裝有GLIBC環境,忽略后,未發現對安裝和運行有多大影響.
因為忘記了這個選項,我只好刪掉數據庫,重新建了一個,浪費了半個小時的時間.
14.安裝完成后,數據庫的連接和查詢異常之慢,GOOGLE之,然后嘗試著把網絡的DNS服務器全給刪了,解決.
15.兩個常用的工具:dbca和netca.