今天学习了小布老师的手工建库视频,自己也做了一遍,下面是创建过程记录:
本地环境oracle10.2.0.1
一.前期准备工作
1.设置环境变量
[oracle@app dbs]$ vi bbk.env
[oracle@app dbs]$ cat bbk.env
ORACLE_SID=bbk
[oracle@app dbs]$ . ./bbk.env
[oracle@app dbs]$ env |grep ORA
ORACLE_SID=bbk
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_2
[oracle@app dbs]$ sqlplus / as sysdba
2.建立bbk.ora pfile参数
processes = 150
sga_target = 599785472
control_files = ('/u01/app/oracle/oradata/bbk/control01.ctl', '/u01/app/oracle/oradata/bbk/control02.ctl', '/u01/app/oracle/oradata/bbk/control03.ctl')
db_block_size = 8192
compatible = '10.2.0.1.0'
db_file_multiblock_read_count= 16
db_recovery_file_dest = '/u01/app/oracle/flash_recovery_area'
db_recovery_file_dest_size= 2147483648
undo_management = 'AUTO'
undo_tablespace = 'UNDOTBS1'
remote_login_passwordfile= 'EXCLUSIVE'
db_domain =''
dispatchers = '(PROTOCOL=TCP) (SERVICE=bbkXDB)'
job_queue_processes = 10
background_dump_dest = '/u01/app/oracle/admin/bbk/bdump'
user_dump_dest = '/u01/app/oracle/admin/bbk/udump'
core_dump_dest = '/u01/app/oracle/admin/bbk/cdump'
audit_file_dest = '/u01/app/oracle/admin/bbk/adump'
db_name = 'bbk'
open_cursors = 300
pga_aggregate_target = 199229440
3.创建文件目录
在/u01/app/oracle/admin/下创建空的bbk、bbk/*dump 几个目录
在/u01/app/oracle/oradata/下创建空的bbk目录
4.创建建库脚本
建库db.sql脚本:
create database "bbk"
maxdatafiles 500
maxinstances 8
maxlogfiles 32
character set "UTF8"
national character set AL16UTF16
archivelog
datafile '/u01/app/oracle/oradata/bbk/system01.dbf' size 500M
sysaux datafile '/u01/app/oracle/oradata/bbk/sysaux01.dbf' size 200M
default temporary tablespace temp tempfile '/u01/app/oracle/oradata/bbk/temp01.dbf' size 50M
undo tablespace "undotbs1" datafile '/u01/app/oracle/oradata/bbk/undotbs01.dbf' size 100M
logfile
group 1('/u01/app/oracle/oradata/bbk/redo01.rdo')size 50M,
group 2('/u01/app/oracle/oradata/bbk/redo02.rdo')size 50M,
group 3('/u01/app/oracle/oradata/bbk/redo03.rdo')size 50M
;
二.建库过程
1.创建密码文件
[oracle@app dbs]$ orapwd file=orapwbbk password=oracle entries=10
2.生成spfile
SQL> create spfile from pfile='bbk.ora';
File created.
3.建库
[oracle@app dbs]$ env |grep ORA
ORACLE_SID=bbk
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_2
[oracle@app dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Oct 27 11:12:51 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2022632 bytes
Variable Size 167772952 bytes
Database Buffers 427819008 bytes
Redo Buffers 2170880 bytes
SQL> @$ORACLE_HOME/dbs/db.sql
Database created.
4.初始化数据库系统
在上面db.sql执行成功后,执行下面的系统脚本
SQL>@?/rdbms/admin/catalog.sql --创建系统的数据字典脚本
SQL>@?/rdbms/admin/catproc.sql --创建pl/sql需要的环境脚本
SQL>@?/rdbms/admin/pupbld.sql --创建sql*plus需要的环境脚本
我上面的这3个脚本是参照9i的,其实前2个是必须要执行的。
如果脚本执行没有报错,那么至此手工数据库创建完成;重启数据库查看一下即可。
三.建库过程中的问题处理
1.SQL> @$ORACLE_HOME/dbs/db.sql
create database "bbk"
*
ERROR at line 1:
ORA-13504: No SYSAUX datafile clause specified
10G的db.sql里面必须要有sysaux tablespace的定义。
2.SQL> @$ORACLE_HOME/dbs/db.sql
datafile temporary tablespace temp tempfile 'u01/app/oracle/oradata/bbk/temp01.dbf' size 50M
*
ERROR at line 11:
ORA-02164: DATAFILE clause specified more than once
db.sql里面的书写错误:datafile 应该是 default
3.SQL> @$ORACLE_HOME/dbs/db.sql
create database "bbk"
*
ERROR at line 1:
ORA-25146: EXTENT MANAGEMENT option already specified
之前表空间的定义后面是带了 datafile '/u01/app/oracle/oradata/bbk/system01.dbf' size 100M extent management local
--出现这个错误的原因,可能是在Oracle10.2.0.1中,这几个表空间的extent管
理必须是local方式的,这样,在创建时就不可指定extent参数。例如初始安装后,
查询如下:
SQL> select TABLESPACE_NAME, EXTENT_MANAGEMENT from user_tablespaces;
TABLESPACE_NAME EXTENT_MANAGEMENT
-----------------------------------
SYSTEM LOCAL
UNDO LOCAL
SYSAUX LOCAL
TEMP LOCAL
USERS LOCAL
4.如果执行db.sql 过程中失败了
SQL> @$ORACLE_HOME/dbs/db.sql
create database "bbk"
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
你需要重新连接,并且把已经创建的数据文件手工删除。
5.如果执行系统脚本出错
SQL> @?/rdbms/admin/catalog.sql -- 创建系统的数据字典脚本
SQL>@?/rdbms/admin/catproc.sql --创建pl/sql需要的环境脚本
SQL>@?/rdbms/admin/pupbld.sql --创建sql*plus需要的环境脚本
(最后这个脚本是小布老师9i上说要执行的,其实非必须执行。但是上面2个是必须要执行的)
SQL> startup
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2022632 bytes
Variable Size 184550168 bytes
Database Buffers 411041792 bytes
Redo Buffers 2170880 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced
SQL> startup nomount
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist
SQL>
查看了日志
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
Sun Oct 27 21:03:57 2013
Error 704 happened during db open, shutting down database
USER: terminating instance due to error 704
Instance terminated by USER, pid = 5074
ORA-1092 signalled during: ALTER DATABASE OPEN...
----解决办法:
若重新启动数据库时报错ORA-01092 可以使用如下方法解决:
SQL>shutdown immediate
SQL> startup upgrade
SQL>@?/rdbms/admin/catupgrd.sql
然后重新启动数据库即可。
如果执行catupgrd.sql 过程中有错误(
SELECT version_script AS file_name FROM DUAL
*
ERROR at line 1:
ORA-20000: Upgrade re-run not supported from version
ORA-06512: at "SYS.VERSION_SCRIPT", line 45
);完成后仍然无法正常启动,则这个脚本不可用,换其他两个脚本执行
SQL> startup upgrade
SQL>@?/rdbms/admin/catalog.sql
SQL>@?/rdbms/admin/catproc.sql 然后重启数据库即可。
四.测试数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2022632 bytes
Variable Size 192938776 bytes
Database Buffers 402653184 bytes
Redo Buffers 2170880 bytes
Database mounted.
Database opened.
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
bbk OPEN
SQL> create table x2(id int,name varchar2(10));
Table created.
SQL> insert into x2 values(1,'223');
1 row created.
SQL> commit ;
Commit complete.
SQL> select * from x2;
ID NAME
---------- ----------
1 223