一直就想把这篇文章加进来,只可以一直没有时间。刚好今天给我在测试机器上来了个误操作rm * backup/*,把正在运行的数据库中的数据文件全部删除了,真是郁闷!还好这个是给我们新人们测试玩的,要不然就死定了!在此也做一个提醒,身为DBA,要永远记住甚用或者禁止使用rm命令,万不得以的情况下,使用时在敲enter也要看了又看、慎重又慎重才行!好了,费话不说了,下面请看我的过程。


Red Hat Enterprise 3 + Oracle 10g Release 2

$su – oracle

1--- 设置系统环境变量:

ORACLE_HOME=/opt/oracle/product/10.2

ORACLE_BASE=/opt/oracle

ORACLE_SID=dbtest

......

2--- 系统规划:

实例名称ORACLE_SID=dbtest

数据库名称DB_NAME=dbtest

3--- 手工创建如下目录:

/opt/oracle/admin/dbtest/cdump

/opt/oracle/admin/dbtest/bdump

/opt/oracle/admin/dbtest/udump

/opt/oracle/admin/dbtest/pfile

/opt/oracle/oradata/dbtest/

/opt/oracle/oradata/dbtest/archive

4--- 建立密码文件:

orapwd file=/opt/oracle/product/10.2/dbs/orapwd_dbtest password=superman

5---修改参数文件:

格式:/opt/oracle/product/10.2/dbs/init.ora

实例:/opt/oracle/product/10.2/dbs/initdbtest.ora

内容如下:

---------------------------------------------------

dbtest.__db_cache_size=331350016

dbtest.__java_pool_size=4194304

dbtest.__large_pool_size=8388608

dbtest.__shared_pool_size=138412032

dbtest.__streams_pool_size=0

*._kgl_large_heap_warning_threshold=8388608

*.audit_file_dest='/opt/oracle/admin/dbtest/adump'

*.background_dump_dest='/opt/oracle/admin/dbtest/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/opt/oracle/oradata/dbtest/control01.ctl','/opt/oracle/oradata/dbtest/control02.ctl','/opt/oracle/oradata/dbtest/control03.ctl'

*.core_dump_dest='/opt/oracle/admin/dbtest/cdump'

*.db_2k_cache_size=33554432

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=128

*.db_files=4000

*.db_name='dbtest'

*.db_recovery_file_dest_size=4294967296

*.db_recovery_file_dest=''

*.log_archive_dest='/opt/oracle/oradata/dbtest/archive'

*.log_checkpoints_to_alert=FALSE

*.open_cursors=300

*.parallel_execution_message_size=65535

*.parallel_max_servers=128

*.pga_aggregate_target=209715200

*.processes=150

*.recyclebin='OFF'

*.remote_login_passwordfile='EXCLUSIVE'

*.replication_dependency_tracking=FALSE

*.session_cached_cursors=100

*.sga_target=500m

*.shared_pool_size=100m

*.undo_management='AUTO'

*.undo_retention=0

*.undo_tablespace='UNDOTS'

*.user_dump_dest='/opt/oracle/admin/dbtest/udump'

*.workarea_size_policy='AUTO'

_allow_resetlogs_corruption=true

---------------------------------------------------

可将此文件复制到:/opt/oracle/admin/dbtest/pfile/init.ora

6--- 登陆oracle

> sqlplus “/ as sysdba”

7--- 启动实例:

SQL> startup nomount pfile=/opt/oracle/admin/dbtest/pfile/init.ora

8--- 创建数据库的脚本:

-----------------------------------------------------------

CREATE DATABASE dbtest

LOGFILE

GROUP 1 ('/opt/oracle/oradata/dbtest/redo01.log','/opt/oracle/oradata/dbtest/redo01_1.log') size 100m reuse,

GROUP 2 ('/opt/oracle/oradata/dbtest/redo02.log','/opt/oracle/oradata/dbtest/redo02_1.log') size 100m reuse,

GROUP 3 ('/opt/oracle/oradata/dbtest/redo03.log','/opt/oracle/oradata/dbtest/redo03_1.log') size 100m reuse

MAXLOGFILES 50

MAXLOGMEMBERS 5

MAXLOGHISTORY 200

MAXDATAFILES 500

MAXINSTANCES 5

ARCHIVELOG

CHARACTER SET UTF8

NATIONAL CHARACTER SET UTF8

DATAFILE '/opt/oracle/oradata/dbtest/system01.dbf' SIZE 1000M EXTENT MANAGEMENT LOCAL

SYSAUX DATAFILE '/opt/oracle/oradata/dbtest/sysaux01.dbf' SIZE 1000M

UNDO TABLESPACE UNDOTS DATAFILE '/opt/oracle/oradata/dbtest/undo.dbf' SIZE 500M

DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/opt/oracle/oradata/dbtest/temp.dbf' SIZE 500M

;

-----------------------------------------------------------

9--- 运行如下文件(安装下面的先后顺序)

/opt/oracle/product/10.2/rdbms/admin/catalog.sql

/opt/oracle/product/10.2/rdbms/admin/catproc.sql

10--- 创建相关表空间与用户:

CREATE TABLESPACE USERS DATAFILE '/opt/oracle/oradata/dbtest/users01.dbf' SIZE 1000M;---数据表空间

CREATE TABLESPACE INDX DATAFILE '/opt/oracle/oradata/dbtest/indx01.dbf' SIZE 1000M;---在建立索引的时候把此表空间作为存储空间,即单独用一个表空间来存储索引,这是个好习惯,虽然我们没有办法建立一个默认的索引表空间!

CREATE USER test IDENTIFIED BY test DEFAULT TABLESPACE users ;---测试用户

GRANT CONNECT,RESOURCE TO test;

11--- 一点注意的地方:

1>.相关文件的目录要设置正确,有数据文件,控制文件,参数文件等,还有就是它们的位置要与控制文件中指定的要一致。

2>.init.ora中的undo_tablespace的名字必须要与create database的相同,包括大小写等注意。否则很麻烦,报的错误你都不知道是不是在忽悠你!总之,一句话,控制文件中的内容要和init文件中的内容以及要和实际文件的实际情况要相同。

3>.分析数据库出错可以到/opt/oracle/admin/dbtest/bdump/alert_dbtest.log中查找。