手工建库步骤
环境:
OS:WIN2003
ORACLE:10G R1
CPU:AMD 2.8*1
MEMORY:1G
1、建立目录:
取巧办法是从$ORACLE_HOME/ADMIN/SAMPLE中把该目录下的所有文件和文件夹拷贝到$ORACLE_BASE下
我这里是:
将E:\oracle\product\10.1.0\db_1\admin\sample下的文件拷贝到:E:\oracle\product\10.1.0\admin下
创建目录E:\oracle\product\10.1.0\oradata\oratest用来存放数据
2、修改参数文件
1)拷贝oracle的样例参数文件:E:\oracle\product\10.1.0\db_1\admin\sample\pfile\initsmpl.ora到
E:\oracle\product\10.1.0\admin\pfile下,并改名为init.ora
2)修改参数文件的如下几个部分:
修改:
db_name=oratest
control_files=('E:\oracle\product\10.1.0\oradata\oratest\control01.ctl',
'E:\oracle\product\10.1.0\oradata\oratest\control02.ctl',
'E:\oracle\product\10.1.0\oradata\oratest\control03.ctl'
)
db_block_size = 8192
background_dump_dest=E:\oracle\product\10.1.0\admin\bdump
user_dump_dest=E:\oracle\product\10.1.0\admin\udump
shared_pool_size = 100000000--(10g中,这个参数必须大于 52132659)
compatible = 10.1.0.0.0
注释以下部分:(因为这些参数在10g中已经取消)
#distributed_transactions = 5
#job_queue_interval = 10
#text_enable = TRUE
3、创建密码文件
C:\>orapwd file=E:\oracle\product\10.1.0\db_1\database\pwdoratest.ora password=space6212 entries=5
(注意:创建密码文件时各个参数的值都不要用引号括起来)
4、创建实例
C:\>oradim -NEW -SID oratest -startmode a -pfile E:\oracle\product\10.1.0\admin\pfile\init.ora
例程已创建。
5、创建spfile
C:\SET ORACLE_SID=ORATEST
C:\SQOPLUS /NOLOG
SQL>CONN / AS SYSDBA
SQL> create spfile='E:\oracle\product\10.1.0\db_1\database\spfileoratest.ora' from pfile='E:\oracle\product\10.1.0\admin\pfile\init.ora'
SQL>SHUTDOWN IMMEDIATE
6、建立数据库
SQL>STARTUP NOMOUNT
SQL>CREATE DATABASE oratest
LOGFILE GROUP 1 ('E:\oracle\product\10.1.0\oradata\oratest\redo01.log') SIZE 50M,
GROUP 2 ('E:\oracle\product\10.1.0\oradata\oratest\redo02.log') SIZE 50M,
GROUP 3 ('E:\oracle\product\10.1.0\oradata\oratest\redo03.log') SIZE 50M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE 'E:\oracle\product\10.1.0\oradata\oratest\system01.dbf' SIZE 325M AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE 'E:\oracle\product\10.1.0\oradata\oratest\sysaux01.dbf' SIZE 325M
;
有两点需要注意:
(1)在10g中,如果system01.dbf这个文件用extent management local的话,必须创建一个temporary表空间。
(2)10g必须创建sysaux01.dbf这个文件
(3)如果以上步骤出现错误,而错误提示为乱码的话,可以退出SQLPLUS,然后set nls_lang=american_america.zhs16gbk,然后再登录数据库
可以参照oracle提供的例子:
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY pz6r58
USER SYSTEM IDENTIFIED BY y1tz5p
LOGFILE GROUP 1 ('/u01/oracle/oradata/mynewdb/redo01.log') SIZE 100M,
GROUP 2 ('/u01/oracle/oradata/mynewdb/redo02.log') SIZE 100M,
GROUP 3 ('/u01/oracle/oradata/mynewdb/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/u01/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/oracle/oradata/mynewdb/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/u01/oracle/oradata/mynewdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
7、创建表空间
(1)创建UNDO表空间
SQL> create undo tablespace undo datafile 'E:\ORACLE\PRODUCT\10.1.0\ORADATA\ORATEST\UNDO01.DBF' SIZE 1000M EXTENT MANAGEMENT LOCAL;
ALTER SYSTEM SET UNDO_MANAGEMENT='AUTO' SCOPE=SPFILE;
ALTER SYSTEM SET UNDO_TABLESPACE='UNDO' SCOPE=SPFILE;
(2)创建临时表空间
SQL> CREATE TEMPORARY TABLESPACE TEMP TEMPFILE 'E:\ORACLE\PRODUCT\10.1.0\ORADATA\ORATEST\TEMP01.DBF' SIZE 1000M EXTENT MANAGEMENT LOCAL;
SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP;
(3)创建USERS表空间
SQL> create tablespace USERS datafile 'E:\ORACLE\PRODUCT\10.1.0\ORADATA\ORATEST\USERS01.DBF' SIZE 100M EXTENT MANAGEMENT LOCAL;
(4)创建数据库默认表空间
SQL> create tablespace TBS datafile 'E:\ORACLE\PRODUCT\10.1.0\ORADATA\ORATEST\TBS01.DBF' SIZE 1000M EXTENT MANAGEMENT LOCAL;
SQL> ALTER DATABASE DEFAULT TABLESPACE TBS;
8、创建数据字典
SQL>@E:\oracle\product\10.1.0\db_1\rdbms\admin\catalog.sql
SQL>@E:\oracle\product\10.1.0\db_1\rdbms\admin\catproc.sql
SQL>@E:\oracle\product\10.1.0\db_1\rdbms\admin\catexp7.sql
SQL>@E:\oracle\product\10.1.0\db_1\sqlplus\admin\caths.sql
SQL>@E:\oracle\product\10.1.0\db_1\sqlplus\admin\help\hlpbld.sql helpus.sql--安装帮助
至此,数据库创建完毕。
--------------------------------------------------------------------------------------------
刚刚见好库,参考了好多文章,都是比较凌乱的,版本各异,自己总结如下。
RedHat WS3+Oracle10g Release 2
Oracle10gR2下手动创建数据库
$su - oracle
1.设置系统环境变量:
ORACLE_HOME=/home/oracle/product/10.2.0 ORACLE_BASE=/home/oracle
2.系统规划:
实例名称ORACLE_SID=test
数据库名称:test
3.手工创建如下目录:
/home/oracle/admin/test/cdump
/home/oracle/admin/test/bdump
/home/oracle/admin/test/udump
/home/oracle/admin/test/pfile
/home/oracle/oradata/test
4.建立密码文件:
/home/oracle/product/10.2.0/bin/orapwd file=/home/oracle/product/10.2.0/dbs/orapwtest password=test
5.修改参数文件:
格式:/home/oracle/product/10.2.0/dbs/init.ora
实例:/ home/oracle/product/10.2.0/dbs/inittest.ora
内容如下:
large_pool_size=4194304
shared_pool_size=48265318
core_dump_dest='/home/oracle/admin/test/cdump'
db_block_size=8192
db_domain='com'
db_file_multiblock_read_count=16
db_name='test'
db_recovery_file_dest='/home/oracle/flash_recovery_area'
db_recovery_file_dest_size=2147483648
dispatchers='(PROTOCOL=TCP) (SERVICE=testXDB)'
job_queue_processes=10
open_cursors=300
pga_aggregate_target=12777216
processes=150
undo_management='auto'
undo_tablespace='undotbs1'
user_dump_dest='/home/oracle/admin/test/udump'
NLS_DATE_FORMAT="Mon DD YYYY HH24:MI:SS"
NLS_DATE_LANGUAGE=AMERICAN
6.设置当前工作实例:
export ORACLE_SID=test
7.登陆oracle:
>;sqlplus “/ as sysdba”
8.启动实例:
SQL>;startup nomount
9.创建数据库的脚本:
create database test
logfile group 1 '/home/oracle/oradata/test/redo01.log' size 10m reuse,
group 2 '/home/oracle/oradata/test/redo02.log' size 10m reuse,
group 3 '/home/oracle/oradata/test/redo03.log' size 10m reuse
datafile '/home/oracle/oradata/test/test01.dbf' size 500m reuse
maxdatafiles 100
archivelog
character set UTF8
national character set UTF8
sysaux datafile '/home/oracle/oradata/test/sys01.dbf' size 230m autoextend on next 10m maxsize unlimited
undo tablespace undotbs1 datafile '/home/oracle/oradata/test/undo.dbf' size 100m
create temporary tablespace temp tempfile '/home/oracle/oradata/test/temp01.dbf' size 100m autoextend on next 10m maxsize unlimited
create tablespace users datafile '/home/oracle/oradata/test/users01.dbf' size 500m autoextend on next 10m maxsize unlimited;
create user test identified by test default tablespace users;
grant connect,resource to test;
create tablespace rbs datafile '/home/oracle/oradata/test/rbs01.dbf' size 200m
reuse autoextend on next 5m
create tablespace tools datafile '/home/oracle/oradata/test/tools01.dbf' size
64m reuse autoextend on next 320k
create tablespace indx datafile '/home/oracle/oradata/test/indx01.dbf' size
32m reuse autoextend on next 1280k
create public rollback segment rbs0 tablespace rbs storage (optimal 4096k)
create public rollback segment rbs1 tablespace rbs storage (optimal 4096k)
create public rollback segment rbs2 tablespace rbs storage (optimal 4096k)
create public rollback segment rbs3 tablespace rbs storage (optimal 4096k)
alter rollback segment "rbs0" online
alter rollback segment "rbs1" online
alter rollback segment "rbs2" online
alter rollback segment "rbs3" online
10.运行如下文件:
/home/oracle/product/10.2.0/rdbms/admin/catalog.sql
/home/oracle/product/10.2.0/rdbms/admin/catproc.sql
11.经验总结:
①inittest.ora中的control_files关键字所指示的目录必需存在。
②inittest.ora中undo_tablespace中的名字必需与Create Database中的相同。我可是在这点上走了不少弯路啊。以前的建库过程总是出现ORA-01092:ORACLE instance terminated.Disconnection forced.郁闷至极不知如何解决。重装几次还是这样,最后仔细检查inittest.ora文件,发现undo_tablespace=’UNDOTBS1’,而Create Database中undo_tablespace=’undotbs1’,大小写的差别浪费了我几天的时间。
③分析数据库出错可以到/home/oracle/admin/test/bdump目录下的alert_test.log中查找。
阅读(2534) | 评论(0) | 转发(0) |