Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1642288
  • 博文数量: 268
  • 博客积分: 8708
  • 博客等级: 中将
  • 技术积分: 3764
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-06 15:58
文章分类

全部博文(268)

文章存档

2014年(1)

2013年(15)

2012年(23)

2011年(60)

2010年(51)

2009年(12)

2008年(59)

2007年(47)

分类:

2007-04-13 09:01:09

 

1.         创建$ORACLE_BASE/admin/$ORACLE_SID/create/createTablespace.sql,其内容如下所示:

create tablespace "index" logging

datafile '/u01/oracle/oradata/INFA/index01.dbf' size 50M reuse autoextend on next 1280K maxsize 32767M blocksize 8192

extent management local

segment space management auto;

create tablespace "tools" logging

datafile '/u01/oracle/oradata/INFA/tools01.dbf' size 5M reuse autoextend on next 320K maxsize 32767M blocksize 8192

extent management local

segment space management auto;

create tablespace "users" logging

datafile '/u01/oracle/oradata/INFA/users01.dbf' size 100M reuse autoextend on next 1280K maxsize 32767M blocksize 8192

extent management local

segment space management auto;

 

2.         使用sqlplus建立数据库,操作如下:

$ cd $ORACLE_BASE/admin/$ORACLE_SID/create

$ sqlplus /nolog

SQL*Plus: Release 9.2.0.6.0 - Production on Thu Mar 22 00:50:16 2007

 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

 

SQL> connect sys/redondo as sysdba

Connected to an idle instance.

SQL> startup nomount pfile=$ORACLE_BASE/admin/$ORACLE_SID/pfile/init$ORACLE_SID.ora

ORACLE instance started.

 

Total System Global Area  135337540 bytes

Fixed Size                   452164 bytes

Variable Size             100663296 bytes

Database Buffers           33554432 bytes

Redo Buffers                 667648 bytes

SQL>@createDB.sql

Database created.

 

SQL> shutdown

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>exit

Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.6.0 - Production

$ sqlplus /nolog

 

SQL*Plus: Release 9.2.0.6.0 - Production on Thu Mar 22 00:59:52 2007

 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

 

SQL> connect sys/redondo as sysdba

Connected to an idle instance.

SQL> startup pfilE=$ORACLE_BASE/admin/$ORACLE_SID/pfile/init.ora

ORACLE instance started.

 

Total System Global Area  135337540 bytes

Fixed Size                   452164 bytes

Variable Size             100663296 bytes

Database Buffers           33554432 bytes

Redo Buffers                 667648 bytes

Database mounted.

Database opened.

SQL> select instance_name from v$instance;

 

INSTANCE_NAME

----------------

INFA

 

SQL>@createTablespace.sql

 

Tablespace created.

 

Tablespace created.

 

Tablespace created.

 

SQL>@$ORACLE_HOME/rdbms/admin/catalog.sql

SQL>@$ORACLE_HOME/rdbms/admin/catproc.sql

SQL>create spfile from pfile='$ORACLE_BASE/admin/$ORACLE_SID/pfile/init.ora';

SQL>create pfile from spfile;

SQL>exit

 

         上面的最后两步是建立数据库的数据字典视图,当成功执行两个脚本后,oracle9i9.2.0.6.0)数据库的建立就已经成功了。

 

3.         建立listener,编辑$ORACLE_HOME/network/admin/listener.ora,添加如下内容:

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS_LIST =

        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.17)(PORT = 1521))

      )

      (ADDRESS_LIST =

        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))

      )

    )

  )

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = INFA)

      (ORACLE_HOME = /u01/oracle/product/9.2.0.6.0)

      (SID_NAME = INFA)

    )

  )

 

注意:上面的红子部分请与真实环境环境对应,不容差错。

 

4.         建立network services,编辑$ORACLE_HOME/network/admin/tnsnames.ora,添加如下内容:

INFA.LOCAL =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.17)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = INFA)

    )

  )

 

注意:上面的红子部分请与真实环境环境对应,不容差错。

 

5.         修改/etc/oratab文件,添加以下一行

 

INFA:/u01/oracle/product/9.2.0.6.0:Y

 

6.         在系统的时候启动oracle的相关实例

a)         使用root用户身份编辑/etc/rc.d/init.d/dbINFA,内容如下

#!/bin/bash

 

export ORACLE_HOME=" /u01/oracle/product/9.2.0.6.0"

export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH

export ORACLE_OWNER="oracle"

export ORACLE_SID=INFA

 

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

    echo "oracle startup:cannot start"

    exit 1

fi

 

case "$1" in

start)

       #startup the listener and instance

    echo -n "oracle startup: "

    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"

    su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart

    touch /var/lock/subsys/oracle

    echo "finished"

   ;;

stop)

         # stop listener, apache and database

    echo -n "oracle shutdown:"

    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"

    su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut

    rm -f /var/lock/subsys/oracle

    echo "finished"

;;

reload|restart)

    $0 stop

    $0 start

;;

*)

   echo "Usage: dbINFA [start|stop|reload|restart]"

   exit 1

 

esac

exit 0

 

b)         改变dbINFA的属性

# chmod a+x /etc/rc.d/init.d/dbINFA

 

c)         建立连接

ln -s /etc/rc.d/init.d/dbINFA /etc/rc.d/rc0.d/K05dbINFA

# ln -s /etc/rc.d/init.d/dbINFA /etc/rc.d/rc2.d/S95dbINFA

# ln -s /etc/rc.d/init.d/dbINFA /etc/rc.d/rc3.d/S95dbINFA

# ln -s /etc/rc.d/init.d/dbINFA /etc/rc.d/rc5.d/S95dbINFA

# ln -s /etc/rc.d/init.d/dbINFA /etc/rc.d/rc6.d/K05dbINFA

 

阅读(1236) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~