在ubuntu 8.04下安装Oracle 11g(三)

2014-11-24 08:58:43 · 作者: · 浏览: 1
n ... 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安装完成了:) 但是还是不要急,记住咱们还有收尾工作需要做。

设置数据库文件夹和oratab文件的访问权限:(一定要加上这个,不然在使用中会有一些小问题)
$ sudo chown -R oracle:dba /u01/app/oracle/*
$ sudo chmod -R g+w /u01/app/oracle/*
$ sudo chown oracle:dba /etc/oratab
$ sudo chmod g+w /etc/oratab


然后,在/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的命令了。
你可以通过netca增加LISTENER,通过dbca增加数据库。测试一下是否安装成功:
(ORACLE_SID=heron 是你安装时候设置的值)
oracle@hardy:~$ export ORACLE_SID=heron
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>

如果你看到了上面的结果,证明你的oracle安装成功了。
现在就是真正安装完了:)

写得好累呀。。。