分类:
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 extent management local segment space management auto; create tablespace "tools" logging datafile '/u01/oracle/oradata/INFA/tools01.dbf' size extent management local segment space management auto; create tablespace "users" logging datafile '/u01/oracle/oradata/INFA/users01.dbf' size extent management local segment space management auto; |
2. 使用sqlplus建立数据库,操作如下:
$ cd $ORACLE_BASE/admin/$ORACLE_SID/create
$ sqlplus /nolog
SQL*Plus: Release
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
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release
$ sqlplus /nolog
SQL*Plus: Release
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
上面的最后两步是建立数据库的数据字典视图,当成功执行两个脚本后,oracle9i(
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/ (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/
6. 在系统的时候启动oracle的相关实例
a) 使用root用户身份编辑/etc/rc.d/init.d/dbINFA,内容如下
#!/bin/bash export ORACLE_HOME=" /u01/oracle/product/ 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