2.创建Database数据库。
[oracle@redhat6 /]$ cd $ORACLE_HOME/dbs
[oracle@redhat6 dbs]$ echo $ORACLE_SID
orcl
[oracle@redhat6 dbs]$ ls
init.ora
[oracle@redhat6 dbs]$ cp init.ora initorcl.ora
[oracle@redhat6 dbs]$ vi initorcl.ora
[oracle@redhat6 dbs]$ tail -20 initorcl.ora
# install time)
db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/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 = ('+DATA','+ARC')
compatible ='11.2.0'
[oracle@redhat6 dbs]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=oracle123
[oracle@redhat6 dbs]$ mkdir -p /u01/app/oracle/admin/orcl/adump
[oracle@redhat6 dbs]$ mkdir -p /u01/app/oracle/flash_recovery_area
[oracle@redhat6 dbs]$ df -ahT /dev/shm
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 2.0G 212M 1.8G 11% /dev/shm
[oracle@redhat6 dbs]$ sql
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 08:44:16 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 616563896 bytes
Database Buffers 444596224 bytes
Redo Buffers 5541888 bytes
SQL> CREATE DATABASE orcl
USER SYS IDENTIFIED BY oracle123
USER SYSTEM IDENTIFIED BY oracle123
CONTROLFILE REUSE
LOGFILE
GROUP 1 ('+DATA', '+ARC') SIZE 200M,
GROUP 2 ('+DATA', '+ARC') SIZE 200M,
GROUP 3 ('+DATA', '+ARC') SIZE 200M
MAXLOGFILES 5
MAXLOGHISTORY 100
MAXDATAFILES 10
MAXINSTANCES 2
ARCHIVELOG
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '+DATA' SIZE 1G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
SYSAUX DATAFILE '+DATA' SIZE 2G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
DEFAULT TABLESPACE USERS DATAFILE '+DATA' SIZE 50M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '+DATA' SIZE 2G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
UNDO TABLESPACE UNDOTBS1 DATAFILE '+DATA' SIZE 4G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
SET TIME_ZONE = '+08:00';
Database created.
执行CREATE DATABASE命令是在NOMOUNT下完成的,而使用dbca创建数据库(实际是使用dbms_backup_restore恢复模板)是在MOUNT模式下完成的。
3.执行数据库字典初始化脚本。
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
SQL> conn system/oracle123
SQL> @?/sqlplus/admin/pupbld.sql
4.修改控制文件及验证数据库。
SQL> show parameter control_file
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string +DATA/orcl/controlfile/current
.266.787999629, +ARC/orcl/cont
rolfile/current.256.787999629
[oracle@redhat6 dbs]$ tail -20 initorcl.ora
# install time)
db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/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 = ('+DATA/orcl/controlfile/current.266.787999629','+ARC/orcl/controlfile/current.256.787999629')
compatible ='11.2.0'
[oracle@redhat6 dbs]$ sql
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 09:56:02 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> create spfile from pfile;
File created.
在执行CREATE DATABASE命令之前创建并使用SPFILE是个好习惯,之后的建库操作SPFILE中的control_files参数会被自动的修改,这样就不需要在建库完成之后再来调整SPFILE。
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 616563896 bytes
Database Buffers 444596224 bytes
Redo Buffers 5541888 bytes
Database mounted.
Database opened.
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/db_1/dbs/spfileorcl.ora
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> select name ,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE
SQL> select COMP_NAME,VERSION,STATUS from dba_registry;
COMP_NAME
--------------------------------------------------------------------------------
VERSION STATUS
------------------------------ ----------------------
Oracle Database Catalog Views
11.2.0.3.0 VALID
Oracle Database Packages and Types
11.2.0.3.0 VALID
5.DROP数据库。
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount exclusive restrict
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 616563896 bytes
Database Buffers 444596224 bytes
Redo Buffers 5541888 bytes
Database mounted.
SQL> drop database;