oracle手工建库过程记录

环境:VM6.0 + REDHAT9.0 + ORACLE9.2
在尝试多次用DBCA建库未能成功的情况下(最后一步迟迟不开始,仍未找到原因)
决定用手工建库,实践成功!
虽然其中的参数设置,有很多不合理的地方,但至少前进了一大步,
终于把linux + oracle 环境搭建起来了

step1:
创建脚本demo.env
ORACLE_HOME=/u01/app/oracle/product/9.2.0
ORACLE_SID=demo
ORACLE_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
PATH=.:$ORACLE_HOME/bin:$PATH:$HOME/shbin:$HOME/sh
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_NLS33 PATH LD_LIBRARY_PATH
在.profile 添加 . ./demo.env
编译 . ./.profile
   
step2:
创建口令文件
在/u01/app/oracle/product/9.2.0/dbs 目录下
orapwd是一个unix命令:直接在命令行下执行, 不是在SQL>
orapwd file=orapwdemo password=demo entries=10
step3:
建好数据库需要的目录
存放进程跟踪文件
/u01/app/oracle/product/9.2.0/admin/demo/bdump
/u01/app/oracle/product/9.2.0/admin/demo/cdump
/u01/app/oracle/product/9.2.0/admin/demo/udump
/u01/app/oracle/product/9.2.0/admin/demo/create
/u01/app/oracle/product/9.2.0/admin/demo/pfile
存放控制文件/数据文件
/u01/app/oracle/product/9.2.0/oradata/demo/
存放参数/密码文件:
/u01/app/oracle/product/9.2.0/dbs/
initdemo.ora
orapwdemo
step4:
创建初始化参数文件initdemo.ora
aq_tm_processes=1
background_dump_dest='/u01/app/oracle/product/9.2.0/admin/demo/bdump'
compatible='9.2.0.0.0'
control_files='/u01/app/oracle/product/9.2.0/oradata/demo/control01.ctl','/u01/app/oracle/product/9.2.0/oradata/demo/control02.ctl','/u01/app/oracle/product/9.2.0/oradata/demo/control03.ctl'
core_dump_dest='/u01/app/oracle/product/9.2.0/admin/demo/cdump'
db_block_size=8192
db_cache_size=33554432
db_domain=''
db_file_multiblock_read_count=16
db_name='demo'
dispatchers='(PROTOCOL=TCP) (SERVICE=demoXDB)'
fast_start_mttr_target=300
hash_join_enabled=TRUE
instance_name='demo'
java_pool_size=83886080
job_queue_processes=10
large_pool_size=16777216
open_cursors=300
pga_aggregate_target=25165824
processes=150
query_rewrite_enabled='FALSE'
remote_login_passwordfile='EXCLUSIVE'
shared_pool_size=83886080
sort_area_size=524288
star_transformation_enabled='FALSE'
timed_statistics=TRUE
undo_management='AUTO'
undo_retention=10800
undo_tablespace='UNDOTBS1'
user_dump_dest='/u01/app/oracle/product/9.2.0/admin/demo/udump'
将initdemo.ora 移到 /u01/app/oracle/product/9.2.0/dbs/
step5:
登录sqlplus
$sqlplus /nolog
SQL> conn / as sysdba;
Connected to an idle instance.
SQL>create spfile from pfile;
SQL>startup nomount
查看
ps -ef | grep demo

step6:
创建数据库
创建脚本crdb01.sql
CREATE DATABASE "demo"
    MAXDATAFILES 500
    MAXINSTANCES 8
    MAXLOGFILES  32
    CHARACTER SET "ZHS16GBK"
    NATIONAL CHARACTER SET AL16UTF16
    ARCHIVELOG
    DATAFILE '/u01/app/oracle/product/9.2.0/oradata/demo/system01.dbf' size 300M
    EXTENT MANAGEMENT LOCAL
    DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/u01/app/oracle/product/9.2.0/oradata/demo/tempts01.dbf' SIZE 100M EXTENT MANAGEMENT LOCAL
    UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/app/oracle/product/9.2.0/oradata/demo/undotbs01.dbf' SIZE 200m
    LOGFILE
  GROUP 1 (
     '/u01/app/oracle/product/9.2.0/oradata/demo/redo01a.rdo',
     '/u01/app/oracle/product/9.2.0/oradata/demo/redo01b.rdo'
     )SIZE 100M,
  GROUP 2 (
     '/u01/app/oracle/product/9.2.0/oradata/demo/redo02a.rdo',
     '/u01/app/oracle/product/9.2.0/oradata/demo/redo02b.rdo'     
    )SIZE 100M,
  GROUP 3 (
     '/u01/app/oracle/product/9.2.0/oradata/demo/redo03a.rdo',
     '/u01/app/oracle/product/9.2.0/oradata/demo/redo03b.rdo'     
    )SIZE 100M;
   
SQL>start $crdb01.sql;
step7:
跟踪创建过程
tail -f /u01/app/oracle/product/9.2.0/admin/demo/bdump/alter_demo.log
step8:
创建数据字典
在数据库创建结束后,数据库自动处于OPEN状态下,
这时所有V$××××类数据字典都可以查询。
而其它数据字典,如DBA_DATA_FILES、DBA_TABLESPACES等都不存在,
必须通过下列骤为系统创建数据字典。
1)加载常用的数据字典包
sql>@/u01/app/oracle/product/9.2.0/rdbms/admin/catalog.sql;
2)加载PL/SQL程序包
sql>@/u01/app/oracle/product/9.2.0/rdbms/admin/catproc.sql;
3)加载数据复制支持软件包
sql>@/u01/app/oracle/product/9.2.0/rdbms/admin/catrep.sql;
4)加载Java程序包
sql>@/u01/app/oracle/product/9.2.0/rdbms/admin/initjvma.sql;
sql>@/u01/app/oracle/product/9.2.0/rdbms/admin/initjvm2.sql;
sql>@/u01/app/oracle/product/9.2.0/rdbms/admin/initjvm4.sql;
sql>@/u01/app/oracle/product/9.2.0/rdbms/admin/initjvm5.sql;
5)加载系统环境文件
sql>connect system/manager
sql>@/u01/app/oracle/product/9.2.0/sqlplus/admin/pupbld.sql;
step9:
正常启动
SQL>shutdown immediate
SQL>startup
所遇问题
Errors in file /u01/app/oracle/product/9.2.0/rdbms/log/demo_ora_24629.trc:
ORA-01501: CREATE DATABASE failed
ORA-01990: error opening password file '/u01/app/oracle/product/9.2.0/dbs/orapw'
orapwdemo 写成了orapwddemo

手工删除一个库:
删除控制文件/数据文件
cd /u01/app/oracle/product/9.2.0/oradata/demo/
rm -f *.*
删除参数/密码文件:
cd /u01/app/oracle/product/9.2.0/dbs/
rm -f initdemo.ora
rm -f spfiledemo.ora;
rm -f orapwdemo.ora
删除所建数据库目录
cd /u01/app/oracle/product/9.2.0/admin/
rm -fR demo