1. 程式人生 > >Oracle11gR2手工建庫(附DBCA靜默建庫)

Oracle11gR2手工建庫(附DBCA靜默建庫)

參考官方文件:E25494-03
環境:CentOS6.5  Oracle11.2.0.4

1. 指定Oracle SID

[[email protected] ~]$ echo $ORACLE_SID
orcl

2. 設定環境變數

[[email protected] ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/db_1
[[email protected] ~]$ echo $ORACLE_BASE
/u01/app/oracle
由於這些引數已經在安裝oracle軟體的時候寫入了環境變數,這裡就不再修改

3. 選擇認證方式,建立密碼檔案

[[email protected] ~]$ cd $ORACLE_HOME/dbs
[[email protected] dbs]$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl entries=30

Enter password for SYS: 

4. 建立引數檔案

[[email protected] dbs]$ cp init.ora initorcl.ora
[[email protected] dbs]$ ls
init.ora  initorcl.ora  orapworcl
[[email protected]
dbs]$ vim initorcl.ora # Change '<ORACLE_BASE>' to point to the oracle base (the one you specify at # install time) db_name='ORCL' memory_target=900m processes = 150 audit_file_dest='/u01/app/orcle/admin/orcl/adump' audit_trail ='db' db_block_size=8192 db_domain='' db_recovery_file_dest='/u01/app/oracle/flash_recovery_area' db_recovery_file_dest_size=2G diagnostic_dest='/u01/app/oracle' dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)' open_cursors=300 remote_login_passwordfile='EXCLUSIVE' undo_tablespace='UNDOTBS1' # You may want to ensure that control files are created on separate physical # devices control_files = ('/u01/app/oracle/oradata/orcl/control01.ctl', '/u01/app/oracle/oradata/orcl/control02.ctl') compatible ='11.2.0' "initorcl.ora" 66L, 2856C written   
注:需要根據引數檔案中的引數建立相應的目錄,建立後重新賦一次許可權
[[email protected] ~]# mkdir -p /u01/app/orcle/admin/orcl/adump
[[email protected] ~]# mkdir -p /u01/app/oracle/flash_recovery_area
[[email protected] oradata]$ mkdir -p /u01/app/oracle/oradata/orcl
[[email protected] ~]# chown -R oracle:oinstall /u01/app
[[email protected] ~]# chmod -R 775 /u01/app

5. 連線到資料庫,啟動到nomount狀態

[[email protected] dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Nov 19 02:09:58 2016

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

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  939495424 bytes
Fixed Size                  2258840 bytes
Variable Size             595593320 bytes
Database Buffers          335544320 bytes
Redo Buffers      

6. 執行建庫指令碼

SQL> CREATE DATABASE orcl
  2     USER SYS IDENTIFIED BY oracle
  3     USER SYSTEM IDENTIFIED BY oracle
  4     LOGFILE GROUP 1 ('/u01/app/oracle/oradata/orcl/redo01a.log','/u01/app/oracle/oradata/orcl/redo01b.log') SIZE 100M BLOCKSIZE 512,
  5             GROUP 2 ('/u01/app/oracle/oradata/orcl/redo02a.log','/u01/app/oracle/oradata/orcl/redo02b.log') SIZE 100M BLOCKSIZE 512,
  6             GROUP 3 ('/u01/app/oracle/oradata/orcl/redo03a.log','/u01/app/oracle/oradata/orcl/redo03b.log') SIZE 100M BLOCKSIZE 512
  7     MAXLOGFILES 5
  8     MAXLOGMEMBERS 5
  9     MAXLOGHISTORY 1
 10     MAXDATAFILES 100
 11     CHARACTER SET ZHS16GBK
 12     NATIONAL CHARACTER SET AL16UTF16
 13     EXTENT MANAGEMENT LOCAL
 14     DATAFILE '/u01/app/oracle/oradata/orcl/system01.dbf' SIZE 325M REUSE
 15     SYSAUX DATAFILE '/u01/app/oracle/oradata/orcl/sysaux01.dbf' SIZE 325M REUSE
 16     DEFAULT TABLESPACE users
 17        DATAFILE '/u01/app/oracle/oradata/orcl/users01.dbf'
 18        SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
 19     DEFAULT TEMPORARY TABLESPACE temp
 20        TEMPFILE '/u01/app/oracle/oradata/orcl/temp01.dbf'
 21        SIZE 20M REUSE
 22     UNDO TABLESPACE UNDOTBS1
 23        DATAFILE '/u01/app/oracle/oradata/orcl/undotbs01.dbf'
 24        SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

Database created.

7. 執行建立資料字典指令碼

@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/sqlplus/admin/pupbld.sql #需使用system使用者執行

附帶一個DBCA靜默建庫的方法,可以快速建庫:

[[email protected]_dg database]$ dbca -silent -createDatabase -templateName $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc -gdbname dg -sid dg -characterSet ZHS16GBK
Enter SYS user password: 
 
Enter SYSTEM user password: 
 
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/dg/dg.log" for further details.
也可以手工編輯response目錄下的dbca.rsp來定製資料庫