ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Create Database

Create Database

原创 Linux操作系统 作者:yyp2009 时间:2012-07-12 14:20:52 0 删除 编辑
1. 设置环境变量ORACLE_SID
假设要求创建的数据库的SID是ecmskf
export ORACLE_SID=ecmskf
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

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 目录

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 = 考题中要求你创建联机重做日志文件时存放的目录
4. 启动数据库到nomount状态
此时已经有可供启动的初始化参数文件了,将数据库启动到nomount状态。
 orapwdfile=$ORACLE_HOME/dbs/orapwecmskf password=oracle entries=5
startup nomount;
5. 创建spfile
实例启动以后立刻创建spfile,然后重启一次数据库,让数据库能够使用到spfile。
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;
 @createdb.sql
 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等
spool /home/oracle/cat.log
@?/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
connect /as sysdba
 @?/rdbms/admin/catblock.sql(建锁相关的视图)
 @?/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;

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/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 冷迁
请登录后发表评论 登录
全部评论

注册时间:2008-10-17

  • 博文量
    330
  • 访问量
    1017278