1、create database plan |
|
1、库类型: OLTP : 在线事务处理系统 OLAP : 在线应用处理系统 DSS : 数据决策系统
2、数据库名字及字符集 3、存储空间 4、数据库的物理和逻辑的结构以及存储结构
|
|
2、建库的准备 |
|
|
|
[oracle@oracle dbs]$more initdw.ora |grep -v '^#'|grep -v '^$' >initcuug.ora
建立目录 [oracle@oracle dbs]$ mkdir -p $ORACLE_BASE/admin/cuug [oracle@oracle dbs]$ mkdir bdump cdump udump adump [oracle@oracle dbs]$ mkdir -p $ORACLE_BASE/oradata/cuug 【存放数据文件 控制文件的位置】
修改初始化参数文件
[oracle@oracle dbs]$ vi initcuug.ora
db_name = cuug sga_target = 300M db_block_size = 8192 pga_aggregate_target = 30M db_cache_size = 80M shared_pool_size = 60M parallel_threads_per_cpu = 4 optimizer_mode = choose star_transformation_enabled = true db_file_multiblock_read_count = 16 query_rewrite_enabled = true query_rewrite_integrity = trusted background_dump_dest = $ORACLE_BASE/admin/cuug/bdump user_dump_dest = $ORACLE_BASE/admin/cuug/udump core_dump_dest = $ORACLE_BASE/admin/cuug/cdump control_files = $ORACLE_BASE/oradata/cuug/control01.ctl undo_management = auto undo_tablespace = undotbs
3)建立建库脚本
1、库名 2、表空间及数据文件的位置和大小 3、redo 日志文件的位置和大小 4、字符集
CREATE DATABASE cuug USER SYS IDENTIFIED BY oracle USER SYSTEM IDENTIFIED BY oracle LOGFILE GROUP 1 ('/u01/app/oracle/oradata/cuug/redo01.log') SIZE 100M, GROUP 2 ('/u01/app/oracle/oradata/cuug/redo02.log') SIZE 100M, GROUP 3 ('/u01/app/oracle/oradata/cuug/redo03.log') SIZE 100M MAXLOGFILES 10 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 MAXDATAFILES 100 MAXINSTANCES 1 CHARACTER SET zhs16gbk NATIONAL CHARACTER SET AL16UTF16 DATAFILE '/u01/app/oracle/oradata/cuug/system01.dbf' SIZE 350M REUSE 默认system 表空间至少300m EXTENT MANAGEMENT LOCAL(启动本地管理空闲区) SYSAUX DATAFILE '/u01/app/oracle/oradata/cuug/sysaux01.dbf' SIZE 100M REUSE DEFAULT TEMPORARY TABLESPACE temp 注意格式 TEMPFILE '/u01/app/oracle/oradata/cuug/temp01.dbf' SIZE 20M REUSE UNDO TABLESPACE undotbs 【这个名字要和初始化文件的一致】 DATAFILE '/u01/app/oracle/oradata/cuug /undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED; 【根据自己的实际需求更改】
告警日志信息:
create tablespace SYSTEM datafile '$ORACLE_BASE/oradata/test/system01.dbf' size 400m
default storage (initial 10K next 10K) online Sat Aug 20 00:26:34 2011 Completed: create tablespace SYSTEM datafile '$ORACLE_BASE/oradata/test/system01.dbf' size 400m default storage (initial 10K next 10K) EXTENT MANAGEMENT DICTIONARY online Sat Aug 20 00:26:34 2011 create rollback segment SYSTEM tablespace SYSTEM storage (initial 50K next 50K) Completed: create rollback segment SYSTEM tablespace SYSTEM storage (initial 50K next 50K) Sat Aug 20 00:26:49 2011 Thread 1 advanced to log sequence 2 Current log# 2 seq# 2 mem# 0: /u01/app/oracle/oradata/test/redo02a.log Sat Aug 20 00:26:50 2011 CREATE UNDO TABLESPACE RTBS DATAFILE '$ORACLE_BASE/oradata/test/rtbs01.dbf' size 100m
Sat Aug 20 00:26:51 2011 Successfully onlined Undo Tablespace 1. Completed: CREATE UNDO TABLESPACE RTBS DATAFILE '$ORACLE_BASE/oradata/test/rtbs01.dbf' size 100m Sat Aug 20 00:26:51 2011 create tablespace SYSAUX datafile '$ORACLE_BASE/oradata/test/sysaux01.dbf' size 100m
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online Completed: create tablespace SYSAUX datafile '$ORACLE_BASE/oradata/test/sysaux01.dbf' size 100m EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online Sat Aug 20 00:26:54 2011 CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '$ORACLE_BASE/oradata/test/temp01.dbf' size 100m
Completed: CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '$ORACLE_BASE/oradata/test/temp01.dbf' size 100m Sat Aug 20 00:26:55 2011 ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP Completed: ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP Sat Aug 20 00:26:55 2011 ALTER DATABASE DEFAULT TABLESPACE SYSTEM Completed: ALTER DATABASE DEFAULT TABLESPACE SYSTEM Sat Aug 20 00:27:01 2011 SMON: enabling tx recovery Sat Aug 20 00:27:02 2011 Threshold validation cannot be done before catproc is loaded. replication_dependency_tracking turned off (no async multimaster replication found) Starting background process QMNC QMNC started with pid=13, OS id=6485 Sat Aug 20 00:27:03 2011 Completed: create database test user sys identified by **user system identified by *datafile '$ORACLE_BASE/oradata/test/system01.dbf' size 400m sysaux datafile '$ORACLE_BASE/oradata/test/sysaux01.dbf' size 100m undo tablespace rtbs datafile '$ORACLE_BASE/oradata/test/rtbs01.dbf' size 100m default temporary tablespace temp tempfile '$ORACLE_BASE/oradata/test/temp01.dbf' size 100m logfile group 1 '$ORACLE_BASE/oradata/test/redo01a.log' size 10m, group 2 '$ORACLE_BASE/oradata/test/redo02a.log' size 10m, group 3 '$ORACLE_BASE/oradata/test/redo03a.log' size 10m character set zhs16gbk
(2)export ORACLE_SID=cuug (3)启动数据库到nomount状态,startup nomount (4)启动告警日志 tail -f /$ORACLE_BASE/admin/cuug/bdump/alert_cuug.log (5)运行建库脚本:@/export/home/oracle/ct_db.sql 4)建立数据字典
创建数据字典脚本:vi ct_dict.sql @$ORACLE_HOME/rdbms/admin/catalog.sql 创建数据字典 系统提供的相关表 和视图 @$ORACLE_HOME/rdbms/admin/catproc.sql 创建系统提供的存数过程和 包 conn system/oracle @$ORACLE_HOME/sqlplus/admin/pupbld.sql @$ORACLE_HOME /rdbms/admin/utlsampl.sql 创建用户 scott 使用系统提供的 模板
执行数据字典脚本:@/export/home/oracle/ct_dict.sql
5)创建users 表空间,作为普通用户的默认表空间
SQL> select tablespace_name from dba_tablespaces;【如果执行不成功,说明上一步有问题】
TABLESPACE_NAME ------------------------------ SYSTEM RTBS SYSAUX TEMP
SQL> select file_id,file_name,tablespace_name from dba_data_files;
FILE_ID FILE_NAME TABLESPA ---------- -------------------------------------------------- -------- 1 /u01/app/oracle/oradata/orcl/system01.dbf SYSTEM 2 /u01/app/oracle/oradata/orcl/undotbs01.dbf UNDOTBS 3 /u01/app/oracle/oradata/orcl/sysaux01.dbf SYSAUX
SQL> create tablespace users datafile '/u01/app/oracle/oradata/orcl/user01.dbf' size 100m;【创建表空间】 SQL> select * from database_properties; 【查看数据库的属性】 SQL> alter database default tablespace users;【修改oracle数据库的默认表空间】 SQL> select file_id,file_name,tablespace_name from dba_data_files;【查看数据文件】
FILE_ID FILE_NAME TABLESPACE_NAME ---------- -------------------------------------------------- ------------------------------ 1 /u01/app/oracle/oradata/cuug/system01.dbf SYSTEM 2 /u01/app/oracle/oradata/cuug/rtbs01.dbf RTBS 3 /u01/app/oracle/oradata/cuug/sysaux01.dbf SYSAUX 4 /u01/app/oracle/oradata/cuug/user01.dbf USERS
SQL> select file_name,file_id,tablespace_name from dba_temp_files;【查看临时表空间,临时表不和数据文件放在一起】
FILE_NAME FILE_ID TABLESPACE_NAME -------------------------------------------------- ---------- ------------------------------------------------------------------------------------------ /u01/app/oracle/oradata/cuug/temp01.dbf 1 TEMP
SQL> select username,default_tablespace,temporary_tablespace from dba_users;【查看用户的默认表空间】 USERNAME DEFAULT_TABLESP TEMPORARY_TABLESPACE --------------- --------------- ------------------------------------------------------------------------------------------ OUTLN SYSTEM TEMP SYS SYSTEM TEMP SYSTEM SYSTEM TEMP SCOTT USERS TEMP TOM USERS TEMP DBSNMP SYSAUX TEMP TSMSYS USERS TEMP DIP USERS TEMP
|