Create Database
1. 設定環境變數ORACLE_SID
假設要求建立的資料庫的SID是ecmskf
假設要求建立的資料庫的SID是ecmskf
export ORACLE_SID=ecmskf
export ORALE_BASE=/oracle
export ORALE_BASE=/oracle
2.手工建立如下目錄:
mkdir -p $ORACLE_BASE/admin/ecmskf/cdump
mkdir -p $ORACLE_BASE/admin/ecmskf/bdump
mkdir -p $ORACLE_BASE/admin/ecmskf/udump
mkdir -p $ORACLE_BASE/admin/ecmskf/adump
mkdir -p $ORACLE_BASE/admin/ecmskf/dpdump
mkdir -p $ORACLE_BASE/admin/ecmskf/pfile
mkdir -p /oradata/ecmskf
mkdir -p $ORACLE_BASE/admin/ecmskf/bdump
mkdir -p $ORACLE_BASE/admin/ecmskf/udump
mkdir -p $ORACLE_BASE/admin/ecmskf/adump
mkdir -p $ORACLE_BASE/admin/ecmskf/dpdump
mkdir -p $ORACLE_BASE/admin/ecmskf/pfile
mkdir -p /oradata/ecmskf
cd $ORALE_HOME/dbs
cat init.ora | grep -v ^# | grep -v ^$ > initSID.ora
db_name=TEST
control_files=("/oracle/oradata/TEST/controlfile01.dbf")
sga_max_size=280M
sga_target=280M
note:刪除其他記憶體引數
[oracle@node2 dbs]$ more inittest.ora
3. 建立最簡單的initecmskf.ora檔案
$ vi $ORACLE_HOME/dbs/initecmskf.ora
#以下為建庫必需引數
control_files = (/oradata/ecmskf/control1.ctl,/oradata/ecmskf/control2.ctl,/oradata/ecmskf/control3.ctl)
undo_management = AUTO
undo_tablespace = UNDOTBS1
db_name = ecmskf
db_unique_name = ecmskf
db_block_size = 8192
sga_max_size = 512M
sga_target = 512M
#以下為一般建庫需設定的引數,不設定就採用預設值
audit_file_dest = /oracle/admin/ecmskf/bdump #不設定預設$ORACLE_HOME/rdbms/adump
background_dump_dest = /oracle/admin/ecmskf/bdump #不設定預設$ORACLE_HOME/rdbms/log
core_dump_dest = /oracle/admin/ecmskf/bdump #不設定預設$ORACLE_HOME/rdbms/dbs
user_dump_dest =/oracle/admin/ecmskf/bdump #不設定預設$ORACLE_HOME/rdbms/log
#db_domain = #不設定預設為空
open_cursors = 1500 #不設定預設50
processes = 300 #不設定預設40
log_archive_dest_1 = 'LOCATION=/oradata/archivelog/ecmskf' #不設定預設為空,歸檔儲存在$ORACLE_HOME/rdbms/dbs/arch
log_archive_format = 'log_%t_%s_%r.arc' #不設定預設為%t_%s_%r.dbf
job_queue_processes = 10 #不設定預設為0
undo_retention = 10800 #不設定預設為900
#如果需要開通審計功能,設定如下引數
#audit_sys_operations = TRUE
#audit_trail = db,extended #這裡注意,如果將來會轉換成物理備庫,這裡就不能設定db,否則將來物理備庫沒法開啟read only模式
#db_recovery_file_dest = /orahome/flash_recovery_area #OMF模式必需設定
#db_recovery_file_dest_size = 2G #OMF模式必需設定
#如果採用OMF管理資料庫檔案,則還需設定以下引數
#db_create_file_dest = /orahome/oradata #自動在該目錄下建立./{db_name}/datafile 目錄
#db_create_online_log_dest_1 = /orahome/oradata #自動在該目錄下建立./{db_name}/onlinelog 目錄
#db_create_file_dest = /orahome/oradata #自動在該目錄下建立./{db_name}/datafile 目錄
#db_create_online_log_dest_1 = /orahome/oradata #自動在該目錄下建立./{db_name}/onlinelog 目錄
control_files = (/oradata/ecmskf/control1.ctl,/oradata/ecmskf/control2.ctl,/oradata/ecmskf/control3.ctl)
undo_management = AUTO
undo_tablespace = UNDOTBS1
db_name = ecmskf
db_unique_name = ecmskf
db_block_size = 8192
sga_max_size = 512M
sga_target = 512M
audit_file_dest = /oracle/admin/ecmskf/bdump
background_dump_dest = /oracle/admin/ecmskf/bdump
core_dump_dest = /oracle/admin/ecmskf/bdump
user_dump_dest =/oracle/admin/ecmskf/bdump
open_cursors = 1500
processes = 300
log_archive_dest_1 = 'LOCATION=/oradata/archivelog/ecmskf'
log_archive_format = 'log_%t_%s_%r.arc'
job_queue_processes = 10
undo_retention = 10800
$ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=iamwangnc force=y
orapwdfile=$ORACLE_HOME/dbs/orapwecmskf password=oracle entries=5
---如下可選,
#job_queue_processes=5 #建立em時需要job_queue_processes>1
#db_create_file_dest = 考題中要求你建立資料檔案時存放的目錄
#db_create_online_log_dest_1 = 考題中要求你建立聯機重做日誌檔案時存放的目錄
#db_create_file_dest = 考題中要求你建立資料檔案時存放的目錄
#db_create_online_log_dest_1 = 考題中要求你建立聯機重做日誌檔案時存放的目錄
4. 啟動資料庫到nomount狀態
此時已經有可供啟動的初始化引數檔案了,將資料庫啟動到nomount狀態。
此時已經有可供啟動的初始化引數檔案了,將資料庫啟動到nomount狀態。
orapwdfile=$ORACLE_HOME/dbs/orapwecmskf password=oracle entries=5
startup nomount;
5. 建立spfile
例項啟動以後立刻建立spfile,然後重啟一次資料庫,讓資料庫能夠使用到spfile。
create spfile from pfile;
create spfile from pfile;
7. 要快速找到例句要查的是Administrator’s Guide這本文件中第二章 Creating an Oracle Database -> Creating the database -> Issue the CREATE DATABASE Statement,這裡有完整的一條SQL語句,copy出來,然後按照實際需求編輯相應的地方, 然後執行(NOTE:修改MAXLOGFILES,undo,default)。
具體如下:
[oracle@node2 ~]$ vi createdb.sql
CREATE DATABASE ecmskf
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/oradata/ecmskf/redo01.log') SIZE 50M,
GROUP 2 ('/oradata/ecmskf/redo02.log') SIZE 50M,
GROUP 3 ('/oradata/ecmskf/redo03.log') SIZE 50M
MAXLOGFILES 30
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 300
MAXINSTANCES 2
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/oradata/ecmskf/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/oradata/ecmskf/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TEMPORARY TABLESPACE temp1 TEMPFILE '/oradata/ecmskf/temp01.dbf' SIZE 100M REUSE
UNDO TABLESPACE undotbs1 DATAFILE '/oradata/ecmskf/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/oradata/ecmskf/redo01.log') SIZE 50M,
GROUP 2 ('/oradata/ecmskf/redo02.log') SIZE 50M,
GROUP 3 ('/oradata/ecmskf/redo03.log') SIZE 50M
MAXLOGFILES 30
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 300
MAXINSTANCES 2
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/oradata/ecmskf/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/oradata/ecmskf/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TEMPORARY TABLESPACE temp1 TEMPFILE '/oradata/ecmskf/temp01.dbf' SIZE 100M REUSE
UNDO TABLESPACE undotbs1 DATAFILE '/oradata/ecmskf/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
@createdb.sql
create tablespace users datafile '/oradata/ecmskf/users01.dbf' size 500M ;
alter database default tablespace users;
create tablespace users datafile '/oradata/ecmskf/users01.dbf' size 500M ;
alter database default tablespace users;
9. 執行catalog.sql(建資料字典檢視) 和 catproc.sql(建儲存過程包)
只需要執行這兩個SQL,都在$ORACLE_HOME/rdbms/admin中,建立必須的資料字典和內建的package等
只需要執行這兩個SQL,都在$ORACLE_HOME/rdbms/admin中,建立必須的資料字典和內建的package等
spool /home/oracle/cat.log
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
10.建立SQL PLUS屬性和幫助(可選)
connect system/oracle
@?/sqlplus/admin/pupbld.sql
@?/sqlplus/admin/help/hlpbld.sql helpus.sql
@?/sqlplus/admin/help/hlpbld.sql helpus.sql
connect /as sysdba
@?/rdbms/admin/catblock.sql(建鎖相關的檢視)
@?/rdbms/admin/catoctk.sql (建密碼工具包dbms_crypto_toolkit)
@?/rdbms/admin/owminst.plb(建工作空間管理相關物件,dbms_wm)
@?/rdbms/admin/catoctk.sql (建密碼工具包dbms_crypto_toolkit)
@?/rdbms/admin/owminst.plb(建工作空間管理相關物件,dbms_wm)
shutdown immediate;
connect /as sysdba
startup mount
alter database archivelog;
alter database open;
execute utl_recomp.recomp_serial();
最終可以檢視一些狀態
select open_mode, name from v$database;
select current_scn, CHECKPOINT_CHANGE# from v$database;
select startup_time,status from v$instance;
select current_scn, CHECKPOINT_CHANGE# from v$database;
select startup_time,status from v$instance;
10、建立和配置EM(可選):
SQL> @?/sysman/admin/emdrep/sql/emreposcre /u01/app/oracle/product/10.2.0/db_1 SYSMAN iamwangnc TEMP ON;
SQL> alter user SYSMAN identified by "iamwangnc" account unlock;
SQL> alter user DBSNMP identified by "iamwangnc" account unlock;
SQL> host emca -config dbcontrol db -silent -DB_UNIQUE_NAME WENDING -PORT 1521 -EM_HOME /u01/app/oracle/product/10.2.0/db_1 -LISTENER LISTENER -SERVICE_NAME WENDING.LK -SYS_PWD "iamwangnc" -SID WENDING -ORACLE_HOME /u01/app/oracle/product/10.2.0/db_1 -DBSNMP_PWD "iamwangnc" -HOST "vmone" -LISTENER_OH /u01/app/oracle/product/10.2.0/db_1 -LOG_FILE /orahome/emConfig.log -SYSMAN_PWD "iamwangnc";
到此建庫完畢!
--End--
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13750068/viewspace-735277/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PG create databaseDatabase
- Create database manuallyDatabase
- alter database create datafileDatabase
- CREATE DATABASE LINKDatabase
- alter database create datafile '' as ''Database
- create table of mysql databaseMySqlDatabase
- The method of create a replicate of the database .Database
- Create RAC Standby Database for RAC Primary DatabaseDatabase
- 【OH】Creating a Database with the CREATE DATABASE StatementDatabase
- create a database stepsDatabase
- Tasks of a Database Administrator : Create and Open the Database (10)Database
- 12CR2 using create database command for create non-CDB rac databaseDatabase
- db2 create database 命令DB2Database
- Understanding the CREATE DATABASE Statement (69)Database
- create database 字符集設定Database
- Step 7: Issue the CREATE DATABASE Statement (65)Database
- 4.3.3 使用CREATE DATABASE語句建立CDBDatabase
- 【翻譯】Specifying CREATE DATABASE Statement ClausesDatabase
- alter database ... create datafile的原理及用途Database
- 手動create database 的可用命令Database
- 恢復一則 alter database create datafile '' as ''Database
- 2.4.1 使用 CREATE DATABASE 子句建立資料庫Database資料庫
- create database link中的identified by valuesDatabaseIDE
- 2.4 使用 CREATE DATABASE 語句建立資料庫Database資料庫
- 【PDB】Oracle 建立pdb說明(create pluggable database)OracleDatabase
- 4、MySQL建立資料庫(CREATE DATABASE語句)MySql資料庫Database
- How to Create Oracle Database QoS Management Administrator AccountsOracleDatabase
- How to create and relocate an 11gr2 RAC DATABASE SERVICEDatabase
- Unable To Create Database Using ASM ORA-15055DatabaseASM
- 4.3.4 使用CREATE DATABASE語句建立一個CDB:示例Database
- ORA-01031 CREATE TRIGGER ON DATABASEDatabase
- oracle create a new database using backup controlfile to traceOracleDatabase
- How to Create or Remove Restore Point on Standby database (文件 ID 1672977.1)REMRESTDatabase
- How To Drop, Create And Recreate DB Control In A 10g DatabaseDatabase
- GET ORA-32700 WHEN TRYING TO CREATE DATABASE USING 9.2Database
- oracle create database link_資料庫連結測試OracleDatabase資料庫
- 12C-How to Create Oracle Database QoS Management Administrator AccountsOracleDatabase
- Step By Step Guide To Create Physical Standby Database Using RMAN [ID 469493.1]GUIIDEDatabase