OCM考试大纲针对创建数据库的要求:
﹡ Create the database
﹡ Determine and set sizing parameters for database structures
﹡ Createand manage database configuration files
OCM考试分两天时间,第一天上午首先要求通过手工创建数据库,这个环节不算分,但是这个库是今后的考试场景中需要用到的,所以是至关重要的一步。
1、检查环境
主要检查oracle软件是否已经装好,几台考试机器之间的网络访问是否正常。
2、设定SID
假定ORACLE_BASE=/u01/app/oracle,考试要求的SID为orcl,dbname为orcl。
切换到oracle账号,编辑home目录下的环境变量文件.bash_profile,修改ORACLE_SID=orcl
3、创建相关的目录
创建一系列dump目录:
mkdir -p $ORACLE_BASE/admin/orcl/adump
mkdir -p $ORACLE_BASE/admin/orcl/bdump
mkdir -p $ORACLE_BASE/admin/orcl/udump
mkdir -p $ORACLE_BASE/admin/orcl/cdump
如果不采用OMF,创建$ORACLE_BASE/oradata目录
4、创建参数文件
根据init.ora模板文件进行修改
cd $ORACLE_HOME/dbs
cp init.ora initorcl.ora
做如下修改:
1) db_name=orcl
2) control_files=(/oracle/app/oracle/oradata/ocmdb/cfile/ora_control1,/oracle/app/oracle/oradata/ocmdb/cfile/ora_control2,/oracle/app/oracle/oradata/ocmdb/cfile/control3)
3) 一系列dump参数
4) 删除db_cache_size、shared_pool_size等等参数,设置sga_max_size和sga_target_size为300m。
5、创建password file
$ orapwd file=orapworcl password=oracle entries=5
6、创建spfile
sql> create spfile from pfile
sqlplus> startup nomount
7、修改部分参数
sql> alter system set undo_management=auto scope=spfile;
sql> alter system set db_create_file_dest=/u01/app/oracle/oradata/orcl/datafile scope=spfile;
sql> alter system set job_queue_processes=5 scope=spfile;
修改dump路径
sql> shutdown
8、创建database
sql> startup nomount
通过create database语句创建数据库,可以到联机文档administrator guide-Part I Basic Database Administration-2 creating an oracle database – Step 7: Issue the CREATE DATABASE Statement下获取create database例子,稍加修改为:
CREATE DATABASE orcl
USER SYS IDENTIFIED BY change_on_install
USER SYSTEM IDENTIFIED BY manager
LOGFILE GROUP 1 ('/oracle/app/oracle/oradata/orcl/lfile/redo01.log’) SIZE 100M,
GROUP 2 ('/oracle/app/oracle/oradata/orcl/lfile/redo02.log') SIZE 100M,
GROUP 3 ('/oracle/app/oracle/oradata/orcl/lfile/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/oracle/app/oracle/oradata/orcl/datafile/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/oracle/app/oracle/oradata/orcl/datafile/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1 datafile '/oracle/app/oracle/oradata/orcl/datafile/tbs_1.dbf' size 50m
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/oracle/app/oracle/oradata/orcl/datafile/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/oracle/app/oracle/oradata/orcl/datafile/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
执行完成后,将datafile和 tempfile设置为自动扩展:
alter database datafile 1 autoextend on;
alter database datafile 2 autoextend on;
alter database datafile 3 autoextend on;
alter database datafile 4 autoextend on;
alter database tempfile 1 autoextend on;
9、执行catalog和catproc创建数据字典对象
sql>@?/rdbms/admin/catalog
sql>@?/rdbms/admin/catproc
10、开启归档功能
sql> shutdown immediate;
sql> startup mount
sql> alter database archivelog;
sql> alter database open;
11、备份数据库
每做一个重要操作,都要养成备份的习惯。通过rman做数据库全备:
rman> run {
backup full database format '$ORACLE_BASE/backup/full_db_%U.bpk' including current controlfile;
backup archivelog all format '$ORACLE_BASE/backup/arch_%U.bpk' delete input;
}
至此,手工创建database完成。 |