1. 程式人生 > >怎樣手動創建oracle數據庫

怎樣手動創建oracle數據庫

from pro bsp 1.0 fixed root there cte process

以下的實驗室是怎樣不要通過DBCA創建ORACLE 數據庫,而是通過ORACLE ONLINE HELP DOCUMENT進行手動的創建數據庫的具體步驟:

1,編輯Oracle profile
[[email protected] ~]# su - oracle
[[email protected] ~]$ vi ./.bash_profile
PATH=$PATH:$HOME/bin

export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=PROD
export PATH=$ORACLE_HOME/jdk/bin:$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

2,創建對應的ORACLE數據文件的文件夾
[[email protected] ~]$ mkdir -p /u01/app/oracle/oradata/PROD/DISK1
[[email protected] ~]$ mkdir -p /u01/app/oracle/oradata/PROD/DISK2
[[email protected] ~]$ mkdir -p /u01/app/oracle/oradata/PROD/DISK3
[[email protected] ~]$ mkdir -p /u01/app/oracle/admin/PROD/{a,b,c,u,dp}dump

3,創建ORACLE數據庫的password文件
[[email protected] ~]$ cd $ORACLE_HOME/dbs
[[email protected] dbs]$ ll
total 28
-rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora
[[email protected] dbs]$ orapwd
Usage: orapwd file=<fname> password=<password> entries=<users> force=<y/n>

where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA and force - whether to overwrite existing file (opt),
OPERs (opt),
There are no spaces around the equal-to (=) character.
[[email protected] dbs]$ orapwd file=orapwPROD password=oracle entries=5 force=y;
[[email protected] dbs]$ ll
total 32
-rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora
-rw-r----- 1 oracle oinstall 2048 Nov 25 20:45 orapwPROD

4,創建啟動數據庫的參數文件
[[email protected] dbs]$ vi initPROD.ora
db_block_size=8192
db_name=PROD
control_files=(‘/u01/app/oracle/oradata/PROD/DISK1/control01.ctl‘,‘/u01/app/oracle/oradata/PROD/DISK2/control02.ctl‘)
compatible=10.2.0.1.0
processes=150
pga_aggregate_target=90m
UNDO_TABLESPACE=UNDOTBS
undo_management=AUTO
sga_target=300m

5,在幫助文檔裏查找手動創建數據庫的腳本。並做對應的改動。

[[email protected] dbs]$ vi createDB.sql
CREATE DATABASE PROD
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 (‘/u01/app/oracle/oradata/PROD/DISK1/redo01a.log‘,‘/u01/app/oracle/oradata/PROD/DISK2/redo01b.log‘) SIZE

100M,
GROUP 2 (‘/u01/app/oracle/oradata/PROD/DISK1/redo02a.log‘,‘/u01/app/oracle/oradata/PROD/DISK2/redo02b.log‘) SIZE

100M,
GROUP 3 (‘/u01/app/oracle/oradata/PROD/DISK1/redo03a.log‘,‘/u01/app/oracle/oradata/PROD/DISK2/redo03b.log‘) SIZE

100M
MAXLOGFILES 15
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE ‘/u01/app/oracle/oradata/PROD/DISK1/system01.dbf‘ SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE ‘/u01/app/oracle/oradata/PROD/DISK1/sysaux01.dbf‘ SIZE 325M REUSE
DEFAULT TEMPORARY TABLESPACE TEMP
TEMPFILE ‘/u01/app/oracle/oradata/PROD/DISK1/temp01.dbf‘
SIZE 20M REUSE
UNDO TABLESPACE UNDOTBS
DATAFILE ‘/u01/app/oracle/oradata/PROD/DISK1/undotbs01.dbf‘
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;


6,把數據庫啟動到nomount狀態下進行創建數據庫
[[email protected] dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 25 21:06:32 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 314572800 bytes
Fixed Size 1219160 bytes
Variable Size 96470440 bytes
Database Buffers 213909504 bytes
Redo Buffers 2973696 bytes
SQL> @createDB.sql

Database created.


7,執行對應的數據庫的基礎腳本
以下的5個腳本是在sys schema下運行的:
創建數據字典視圖
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catalog.sql;(必須先運行它。才幹夠運行catproc.sql)
創建ORACLE中一些鎖機制相關的視圖
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catblock.sql;
創建ORACLE一些存儲過程和包
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catproc.sql;
創建須要使用PL/ SQL加密工具的接口
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catoctk.sql;
安裝SQL*Plus的表PRODUCT_USER_PROFILE, 好像是與數據倉庫有關的東西.
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/owminst.plb;

以下的2個腳本是在system schema下運行的。
connect system/oracle
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/pupbld.sql;
connect system/oracle
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/help/hlpbld.sql helpus.sql;


8。創建spfile文件
SQL> conn / as sysdba
Connected.
SQL> create spfile from pfile;

File created.


9,關閉數據庫,又一次用spfile啟動數據庫
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 314572800 bytes
Fixed Size 1219160 bytes
Variable Size 96470440 bytes
Database Buffers 213909504 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.

到此手動創建數據庫成功!

怎樣手動創建oracle數據庫