ORACLE 手动建库

 

ORACLE10GR2手动建库大致分为以下几个步骤
编辑.bash_profile文件,设置环境变量
创建所需目录结构
创建初始化参数文件
执行建库脚本

 

下面以创建test数据库为例

1、编辑.bash_profile文件,添加ORACLE_SID环境变量
在.bash_profile文件中指定ORACLE_SID
export ORACLE_SID=test

[oracle@target scripts]$ source  /home/oracle/.bash_profile
[oracle@target scripts]$ echo $ORACLE_SID
test

 

2、创建所需目录结构

mkdir -p /home/oracle/admin/test/adump
mkdir -p /home/oracle/admin/test/bdump
mkdir -p /home/oracle/admin/test/cdump
mkdir -p /home/oracle/admin/test/dpdump
mkdir -p /home/oracle/admin/test/pfile
mkdir -p /home/oracle/admin/test/udump
mkdir -p /home/oracle/oradata/test

 

3、创建初始化参数文件

--1、生成初始化参数文件
[oracle@target pfile]$ cd /home/oracle/admin/test/pfile
[oracle@target pfile]$ vi init.ora
db_block_size=8192
db_file_multiblock_read_count=8
open_cursors=300
db_domain=""
db_name=test
background_dump_dest=/home/oracle/admin/test/bdump
core_dump_dest=/home/oracle/admin/test/cdump
user_dump_dest=/home/oracle/admin/test/udump
control_files=("/home/oracle/oradata/test/control01.ctl", "/home/oracle/oradata/test/control02.ctl", "/home/oracle/oradata/test/control03.ctl")
job_queue_processes=100
compatible=10.2.0.3.0
processes=500
sga_target=274726912
audit_file_dest=/home/oracle/admin/test/adump
remote_login_passwordfile=EXCLUSIVE
dispatchers="(PROTOCOL=TCP) (SERVICE=testXDB)"
pga_aggregate_target=91226112
undo_management=AUTO
undo_tablespace=UNDOTBS1

--2、连接ORACLE_SID=test实例,并以spfile启动数据库到nomount状态
[oracle@target pfile]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on 星期六 12月 14 23:35:09 2013
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Connected to an idle instance.
SQL> create spfile='$ORACLE_HOME/dbs/spfiletest.ora' from pfile='$ORACLE_BASE/admin/test/pfile/init.ora';
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area  276824064 bytes
Fixed Size          2083304 bytes
Variable Size         100664856 bytes
Database Buffers      167772160 bytes
Redo Buffers            6303744 bytes

 

4、执行建库脚本

--1、执行create database脚本
SQL> create database test
user sys identified by oracle
user system identified by oracle
logfile group 1 ('/home/oracle/oradata/test/redo01.log') size 50m,
group 2 ('/home/oracle/oradata/test/redo02.log') size 50m,
group 3 ('/home/oracle/oradata/test/redo03.log') size 50m
maxlogfiles 16
maxlogmembers 3
maxloghistory 1
maxdatafiles 100
maxinstances 8
character set zhs16gbk
national character set al16utf16
datafile '/home/oracle/oradata/test/system01.dbf' size 100m
autoextend on next 10m maxsize unlimited
extent management local
sysaux datafile '/home/oracle/oradata/test/sysaux01.dbf' size 100m
autoextend on next 10m maxsize unlimited
default tablespace users
datafile '/home/oracle/oradata/test/users01.dbf' size 100m
autoextend on next 20m segment space management auto
default temporary tablespace temp
tempfile '/home/oracle/oradata/test/temp01.dbf' size 100m
autoextend on next 20m maxsize unlimited
undo tablespace undotbs1
datafile '/home/oracle/oradata/test/undotbs101.dbf' size 100m
autoextend on next 20m maxsize unlimited;
--2、生成数据字典
SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql
SQL> @$ORACLE_HOME/rdbms/admin/catproc.sql
--以system用户,运行pupbld.sql脚本
SQL> conn system/oracle
Connected.
SQL> @$ORACLE_HOME/sqlplus/admin/pupbld.sql

 

最后全备份数据库。