Creating a DB Manually
Step 1: Specify an Instance Identifier (SID)
gwan (我GF)
Step 2: Ensure That the Required Environment Variables Are Set
[oracle@Oracle9iDemo dbs]$ touch gwan.env
ORACLE_SID=gwan
ORACLE_BASE=/u01
ORACLE_HOME=/u01/oracle
PATH=$ORACLE_HOME/bin:$PATH
ORACLE_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/$LD_LIBRARY_PATH
export ORACLE_SID ORACLE_BASE ORACLE_HOME PATH ORACLE_NLS33 LD_LIBRARY_PATH
Step 3: Choose a DB Administrator Authentification Methods
#已经拥有operating system authentification, 控制了操作系统边控制了oracle。
Step 4: Create the Initialization Parameter File
[oracle@node1 dbs]$ strings spfilewade.ora > initgwan.ora
#wade为DBCA创建,也可以create pfile from spfile;
[oracle@node1 dbs]$ vi initgwan.ora
#将里面的wade全部由gwan替换。
Step 5: (Windows Only) Create Parameter File
#我用的linux作为学习环境,不考虑!
Step 6: Connect to the Instance
[oracle@Oracle9iDemo dbs]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Dec 4 19:41:25 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
Step 7: Create a Server Parameter File
SQL> create spfile from pfile;
File created.
SQL> !
[oracle@Oracle9iDemo dbs]$ ls
crdb01.sql hc_wade.dat initgwan.ora lkWADE spfilegwan.ora
gwan.env initdw.ora init.ora orapwwade spfilewade.ora
[oracle@Oracle9iDemo dbs]$ ll
total 60
-rw-r--r-- 1 oracle oinstall 263 Dec 1 10:45 gwan.env
-rw-rw---- 1 oracle oinstall 1544 Nov 29 22:57 hc_wade.dat
-rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r--r-- 1 oracle oinstall 905 Dec 1 10:00 initgwan.ora
-rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora
-rw-rw---- 1 oracle oinstall 24 Nov 30 13:49 lkWADE
-rw-r----- 1 oracle oinstall 1536 Nov 30 13:51 orapwwade
-rw-r----- 1 oracle oinstall 2560 Dec 1 11:08 spfilegwan.ora
-rw-r----- 1 oracle oinstall 2560 Nov 30 13:57 spfilewade.ora
#注意两个一样大写的文件,spfilegwan.ora和spfilewade.ora
Step 8: Start the Instance
[oracle@Oracle9iDemo dbs]$ exit
exit
SQL> startup nomount; #启动数据库实例了,但是还没有mount到DB
ORACLE instance started.
Total System Global Area 192937984 bytes
Fixed Size 1218460 bytes
Variable Size 62916708 bytes
Database Buffers 125829120 bytes
Redo Buffers 2973696 bytes
SQL> !
[oracle@Oracle9iDemo dbs]$ ps -ef | grep oracle
root 5722 5690 0 09:45 pts/0 00:00:00 su - oracle
oracle 5723 5722 0 09:45 pts/0 00:00:00 -bash
oracle 5833 5723 0 10:13 pts/0 00:00:00 cat
root 5905 5873 0 10:16 pts/2 00:00:00 su - oracle
oracle 5906 5905 0 10:16 pts/2 00:00:00 -bash
oracle 7208 5906 0 11:08 pts/2 00:00:00 sqlplus
oracle 7231 1 0 11:09 ? 00:00:00 ora_pmon_gwan
oracle 7233 1 0 11:09 ? 00:00:00 ora_psp0_gwan
oracle 7235 1 0 11:09 ? 00:00:00 ora_mman_gwan
oracle 7237 1 0 11:09 ? 00:00:00 ora_dbw0_gwan
oracle 7239 1 0 11:09 ? 00:00:00 ora_lgwr_gwan
oracle 7241 1 0 11:09 ? 00:00:00 ora_ckpt_gwan
oracle 7243 1 0 11:09 ? 00:00:00 ora_smon_gwan
oracle 7245 1 0 11:09 ? 00:00:00 ora_reco_gwan
oracle 7247 1 0 11:09 ? 00:00:00 ora_cjq0_gwan
oracle 7249 1 0 11:09 ? 00:00:00 ora_mmon_gwan
oracle 7251 1 0 11:09 ? 00:00:00 ora_mmnl_gwan
oracle 7253 1 0 11:09 ? 00:00:00 ora_d000_gwan
oracle 7255 1 0 11:09 ? 00:00:00 ora_s000_gwan
oracle 7256 7208 0 11:09 ? 00:00:00 oraclegwan (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 7260 7208 0 11:10 pts/2 00:00:00 /bin/bash
oracle 7279 7260 0 11:11 pts/2 00:00:00 ps -ef
oracle 7280 7260 0 11:11 pts/2 00:00:00 grep oracle
#证明实例已经启动起来了!但是DB还没有!
Step 9: Issue the CREATE DATABASE statement.
[oracle@node1 dbs]$ touch crdb01.sql
[oracle@node1 dbs]$ vi credb01.sql
spool dbcreate.log;
CREATE DATABASE "gwan"
MAXDATAFILES 500
MAXINSTANCES 8
MAXLOGFILES 32
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
ARCHIVELOG
DATAFILE
'/u01/oradata/gwan/system01.dbf' size 300M REUSE
SYSAUX DATAFILE
'/u01/oradata/gwan/sysaux01.dbf' size 300M REUSE
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/u01/oradata/gwan/tempts01.dbf' SIZE 100M
EXTENT MANAGEMENT LOCAL
UNDO TABLESPACE "UNDOTBS1"
DATAFILE '/u01/oradata/gwan/undotbs01.dbf' SIZE 200M
LOGFILE
GROUP 1 (
'/u01/oradata/gwan/redo01a.rdo',
'/u01/oradata/gwan/redo01b.rdo'
) SIZE 100M,
GROUP 2 (
'/u01/oradata/gwan/redo02a.rdo',
'/u01/oradata/gwan/redo02b.rdo'
) SIZE 100M,
GROUP 3 (
'/u01/oradata/gwan/redo03a.rdo',
'/u01/oradata/gwan/redo03b.rdo')
SIZE 100M ;
spool off
#sysaux是10g新增表空间
#在create语句下可以USER SYS IDENTIFIED BY wade
USER SYS IDENTIFIED BY gwan,否则分别默认为
change_on_install, manager
Step 10: Create Additional Tablespaces
SQL> create tablespace mytbs datafile ‘/u01/oradata/gwan/mystbs01.dbf’
size 100M extent management local;
#额外表空间存放用户数据,而非系统表空间里面
Step 11: Run Scripts to Build Data Dictionary Views
SQL> spool log1.log
#打印出来便于检查错误,我的log在/home/oracle下面,9i的貌似在dbs下。
SQL> @/rdbms/admin/catalog.sql;
#Creates the views of the DD tables, the dynamic performance views, public synonyms for many the views. Grants PUBLIC access to the synonyms.
#漫长等待,电脑开始超级迟钝,cat log1.log | gre err | more 查看错误。
SQL> @/rdbms/admin/catproc.sql;
#Run all scripts required for or used with PL/SQL
SQL> spool log3.log
SQL> @/sqlplus/admin/pupbld.sql;
#Required for SQL*Plus. Enables SQL*sql to disable commands by user.
Step 12: Run Scripts to Install Additional Options (optional)
#想玩就去查看Oracle Database Reference
Step 13: Back Up the Database.
#先放着吧
Step 14: Enable Automatic Instance Startup(optional)