在ubuntu 下安裝Oracle 11g

來源:互聯網
上載者:User
$ sudo su -
# apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm

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

# echo "Red Hat Linux release 4" > /etc/redhat-release

root@hardy:/bin# cd
root@hardy:~# pwd
   /root
root@hardy:~# addgroup oinstall
   Adding group `oinstall' (GID 1001) ...
   Done.
root@hardy:~# addgroup dba
   Adding group `dba' (GID 1002) ...
   Done.
root@hardy:~# addgroup nobody
   Adding group `nobody' (GID 1003) ...
   Done.
root@hardy:~# usermod -g nobody nobody
root@hardy:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
root@hardy:~# passwd -l oracle
   Password changed.
root@hardy:~# mkdir /home/oracle
root@hardy:~# chown -R oracle:dba /home/oracle
root@hardy:~# ln -s /usr/bin/awk /bin/awk
root@hardy:~# ln -s /usr/bin/rpm /bin/rpm
root@hardy:~# ln -s /usr/bin/basename /bin/basename
root@hardy:~# mkdir /etc/rc.d
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
root@hardy:~# mkdir -p /u01/app/oracle
root@hardy:~# chown -R oracle:dba /u01
root@hardy:~#

修改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

現在將oracle11g的安裝包解壓到/home/oracle/install/目錄下。然後進入目錄,設定DISPLAY參數(不設定Oracle裝不上,可以一試),開始安裝:
root@hardy:~# cd /home/oracle
root@hardy:/home/oracle# chown -R oracle:dba install
root@hardy:/home/oracle# su - oracle
Your account has expired; please contact your system administrator
su: User account has expired
(Ignored)
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

oracle@hardy:~$./runInstaller -ignoreSysPrereqs -jreLoc /usr/lib/jvm/java-6-sun/jre

在安裝第二個介面,將使用者組選擇為dba,選擇"Enterprise Edition",將檢查到的所有非“Succeeded”的都打上勾,在建立完資料庫後,先不點擊OK.
進行如下操作:
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:~#

然後,在/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(注意user為你當前使用的使用者,每個人的都不一定相同。)

好了,至此,Oracle 11g就安裝完了。重新登入後,你就可以使用oracle的命令了。
你可以通過netca增加LISTENER,通過dbca增加資料庫。測試一下是否安裝成功:
(ORACLE_SID=heron 是你安裝時候設定的值)

oracle@hardy:~$ export ORACLE_SID=orcl
oracle@hardy:~$ sqlplus '/as sysdba'

--startup nomount
startup open
--shutdown immediate

sql> select count(*) from dba_users;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.