本文簡單介紹通過oracle數據庫的create database命令創建一個符合OFA規范的oracle數據庫。
1 設置環境變量(vi .bash_profile或者是保存為一個可執行文件執行創建)
ORACLE_BASE=/u01/app
ORACLE_HOME=$ORACLE_HOME/oracle
ORACLE_SID=hsj
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
DISPLAY==192.168.138.1:0.0
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH DISPLAY
2 創建某些目錄(存放日志目錄,存放數據文件目錄,存放控制文件目錄,歸檔目錄)
mkdir -p /u01/app/flash_recovery_area/hsj
mkdir -p /u01/app/diag/rdbms/hsj #用來存放alert trace 跟蹤日志
mkdir -p /u01/app/oradata/hsj/archive # 用來存放歸檔日志,上一級目錄用來存放控制文件和數據文件、聯機日志文件
mkdir -p /u01/app/admin/hsj/adump
mkdir -p /u01/app/admin/hsj/dpdump
mkdir -p /u01/app/admin/hsj/pfile
mkdir -p /u01/app/admin/hsj/scripts
3 創建參數文件 inithsj.ora,並且通過inithsj.ora 創建spfile,spfile文件必須存放$ORACLE_HOME/dbs/目錄下面
mkdir
inithsj.ora 文件類容(某些參數需要根據實際環境進行修改)
v inithsj.ora
hsj.__db_cache_size=327155712
hsj.__java_pool_size=4194304
hsj.__large_pool_size=4194304
hsj.__oracle_base='/u01/app'#ORACLE_BASE set from environment
hsj.__pga_aggregate_target=331350016
hsj.__sga_target=490733568
hsj.__shared_io_pool_size=0
hsj.__shared_pool_size=146800640
hsj.__streams_pool_size=0
audit_file_dest='/u01/app/admin/hsj/adump'
audit_trail='db'
compatible='11.2.0.0.0'
control_files='/u01/app/oradata/hsj/control01.ctl','/u01/app/flash_recovery_area/hsj/control02.ctl'
db_block_size=8192
db_domain=''
db_name='hsj'
db_recovery_file_dest='/u01/app/flash_recovery_area'
db_recovery_file_dest_size=4039114752
diagnostic_dest='/u01/app'
dispatchers='(PROTOCOL=TCP) (SERVICE=hsjXDB)'
log_archive_format='%t_%s_%r.dbf'
memory_target=818937856
nls_language='AMERICAN'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
sqlplus / as sysdba
create spfile from pfile #需要確保是在dbs目錄下,否則需要指定具體的pfile文件路徑和名稱
4 啟動數據庫到nomount狀態
Startup nomount;
5 創建數據庫腳本 createdb.sql
spool createdb.log
create database hsj
user sys identified by root
user system identified by root
logfile group 1
('/u01/app/oradata/hsj/redo01.log') size 50M blocksize 512,
group 2
('/u01/app/oradata/hsj/redo02.log') size 50M blocksize 512,
group 3
('/u01/app/oradata/hsj/redo03.log') size 50M blocksize 512
maxlogfiles 30
maxlogmembers 5
maxloghistory 1
maxdatafiles 100
character set al32utf8
national character set al16utf16
extent management local
datafile '/u01/app/oradata/hsj/system01.dbf' size 300M reuse
sysaux datafile '/u01/app/oradata/hsj/sysaux01.dbf' size 300M reuse
default tablespace users
datafile '/u01/app/oradata/hsj/users01.dbf' size 300M reuse
autoextend on maxsize unlimited
default temporary tablespace tempts1
tempfile '/u01/app/oradata/hsj/temp01.dbf' size 20M reuse
undo tablespace UNDOTBS1
datafile '/u01/app/oradata/hsj/undotbs01.dbf'
size 200M reuse autoextend on maxsize unlimited;
spool off
6 進入到sqlplus執行創建數據庫的腳本
@createdb.sql
7 如果有報錯,請查看createdb.log alert日志 和trace日志
8 進入到 $ORACLE_HOME/rdbms/admin目錄,執行創建數據字典的sql和創建系統包的sql
@catalog.sql
@catproc.sql