oracle 11g手工建庫

winston_DBA發表於2015-03-19
1.設定環境變數

[oracle@TEST ~]$ vi .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=TEST
export PATH=$ORACLE_HOME/bin:/sbin:/usr/sbin:$PATH

[oracle@TEST ~]$ source .bash_profile

2.建立資料庫需要的相關目錄

[oracle@TEST ~]$ cd $ORACL_BASE
[oracle@TEST oracle]$ mkdir -p admin/TEST/audmp
[oracle@TEST oracle]$ mkdir -p oradata/TEST

3.準備密碼檔案及初始化引數檔案

[oracle@TEST oracle]$ cd $ORACLE_HOME/dbs
[oracle@TEST dbs]$ ls
init.ora
[oracle@TEST dbs]$ orapwd file=orapwTEST password=oracle entries=30
[oracle@TEST dbs]$ cat init.ora|grep -v ^$|grep -v ^# >initTEST.ora
[oracle@TEST dbs]$ vi initTEST.ora 

db_name='TEST'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/TEST/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle'
dispatchers='(protocal=tcp) (service=TESTXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (/u01/app/oracle/oradata/TEST/control01.ctl,/u01/app/oracle/oradata/TEST/control02.ctl)
compatible ='11.2.0'

4.開始建立資料庫

[oracle@TEST TEST]$ sqlplus / as sysdba
SQL> create spfile from pfile;
file created.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 1071333376 bytes
Fixed Size                  1349732 bytes
Variable Size             620758940 bytes
Database Buffers          444596224 bytes
Redo Buffers                4628480 bytes
SQL> exit      

[oracle@TEST ~]$ vi 1.sql
CREATE DATABASE TEST
   USER SYS IDENTIFIED BY oracle
   USER SYSTEM IDENTIFIED BY oracle
   LOGFILE GROUP 1 
('/u01/app/oracle/oradata/TEST/redo01a.log','/u01/app/oracle/oradata/TEST/redo01b.log') SIZE 100M 
BLOCKSIZE 512,
           GROUP 2 
('/u01/app/oracle/oradata/TEST/redo02a.log','/u01/app/oracle/oradata/TEST/redo02b.log') SIZE 100M 
BLOCKSIZE 512,
           GROUP 3 
('/u01/app/oracle/oradata/TEST/redo03a.log','/u01/app/oracle/oradata/TEST/redo03b.log') SIZE 100M 
BLOCKSIZE 512
   MAXLOGFILES 5
   MAXLOGMEMBERS 5
   MAXLOGHISTORY 1
   MAXDATAFILES 100
   CHARACTER SET AL32UTF8
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE '/u01/app/oracle/oradata/TEST/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE '/u01/app/oracle/oradata/TEST/sysaux01.dbf' SIZE 325M REUSE
   DEFAULT TABLESPACE users
      DATAFILE '/u01/app/oracle/oradata/TEST/users01.dbf'
      SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE tempts1
      TEMPFILE '/u01/app/oracle/oradata/TEST/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE undotbs1
      DATAFILE '/u01/app/oracle/oradata/TEST/undotbs01.dbf'
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

[oracle@TEST ~]$ sqlplus / as sysdba
SQL> @/home/oracle/1.sql
Database created.
SQL>@?/rdbms/admin/catalog.sql
SQL>@?/rdbms/admin/catproc.sql

注意: 
1.11g中,db_recovery_file_dest設定為’/u01/app/oracle/fast_recovery_area’,有別於10g的flash_recovery_area. 
2.引數檔案裡的undo_tablespace名undotbs1需要和建立資料庫指令碼里的undo tablespace 名一致,否則報表空間不存在錯誤。
3.如果引數檔案initTEST.ora中MEMORY_TARGET設定過大,則會報: “memory not support on this system” 的錯誤,解決方法可將該引數值調小。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30167136/viewspace-1465403/,如需轉載,請註明出處,否則將追究法律責任。

相關文章