当前位置:Gxlcms > mysql > 手工创建Oracle数据库

手工创建Oracle数据库

时间:2021-07-01 10:21:17 帮助过:38人阅读

一、初始化1、创建初始化文件[Oracle@sigleNode dbs]$ more initdw.ora|grep -v

一、初始化
1、创建初始化文件
[Oracle@sigleNode dbs]$ more initdw.ora|grep -v '#'|grep -v '^$'>initprod.ora
编辑初始化文件,进行参数设置,在原来参数设置基础之上增加以下设置
db_name=prod
db_cache_size = 100M
shared_pool_size = 60M
parallel_threads_per_cpu = 4
background_dump_dest = $ORACLE_BASE/admin/prod/bdump
user_dump_dest = $ORACLE_BASE/admin/prod/udump
core_dump_dest = $ORACLE_BASE/admin/prod/cdump
control_files = $ORACLE_BASE/oradata/prod/control01.ctl
undo_management = auto
undo_tablespace = rtbs
2、创建转储目录和文件路径
[oracle@sigleNode dbs]$ mkdir -p $ORACLE_BASE/admin/prod/bdump
[oracle@sigleNode dbs]$ mkdir -p $ORACLE_BASE/admin/prod/udump
[oracle@sigleNode dbs]$ mkdir -p $ORACLE_BASE/admin/prod/cdump
[oracle@sigleNode oradata]$ mkdir -p $ORACLE_BASE/oradata/prod
3、创建口令文件
[oracle@sigleNode dbs]$ orapwd file=orapwprod entries=5 force=y password=prod
可以看到在dbs下面增加实例orapwprod口令文件
[oracle@sigleNode dbs]$ ls -lt|grep orapwprod
-rw-r----- 1 oracle oinstall 2048 Feb 14 23:49 orapwprod
二、手工建库
1、创建建库语句
[oracle@sigleNode dbs]$ vi cr_db.sql

create database prod
user sys identified by prod
user system identified by prod
datafile '$ORACLE_BASE/oradata/prod/system01.dbf' size 400m
sysaux datafile '$ORACLE_BASE/oradata/prod/sysaux01.dbf' size 100m
default temporary tablespace temp tempfile '$ORACLE_BASE/oradata/prod/temp01.dbf' size 100m
undo tablespace rtbs datafile '$ORACLE_BASE/oradata/prod/undo01.dbf' size 100m
logfile
group 1 '$ORACLE_BASE/oradata/prod/redo01.log' size 50m,
group 2 '$ORACLE_BASE/oradata/prod/redo02.log' size 50m
character set zhs16gbk;

注意建库语句创建system和sysaux表空间特殊语法,不要带tablespace关键字,否则会创建失败
undo tablespace表空间的名字必须与undo_tablesapce参数设置保持一致,,否则在告警日志中会报类似下面的错误
ORA-30012 signalled during: CREATE UNDO TABLESPACE UNDO01 DATAFILE '$ORACLE_BASE/oradata/prod/undo01.dbf' size 100m
...
Sun Feb 15 00:27:01 2015
Errors in file /u01/app/oracle/admin/prod/udump/prod_ora_18355.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-30012: undo tablespace 'rtbs' does not exist or of wrong type
Sun Feb 15 00:27:01 2015
Errors in file /u01/app/oracle/admin/prod/udump/prod_ora_18355.trc:
ORA-01501: CREATE DATABASE failed
ORA-01519: error while processing file '?/rdbms/admin/sql.bsq' near line 5792
ORA-00604: error occurred at recursive SQL level 1
ORA-30012: undo tablespace 'rtbs' does not exist or of wrong type
Error 1519 happened during db open, shutting down database
找不到rtbs这个undo表空间导致创建失败
2、创建数据库
首先启动实例到nomount状态
[oracle@sigleNode dbs]$ export ORACLE_SID=prod
[oracle@sigleNode dbs]$ sqlplus / as sysdba
SQL> startup nomount;
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.

Total System Global Area 205520896 bytes
Fixed Size 1218508 bytes
Variable Size 92276788 bytes
Database Buffers 104857600 bytes
Redo Buffers 7168000 bytes
实例成功启动到nomount状态,但是报了废弃参数问题
通过告警日志发现具体如下
Deprecated system parameters with specified values:
parallel_automatic_tuning
End of deprecated system parameter listing
指明参数parallel_automatic_tuning已经废弃,编辑初始化文件
[oracle@sigleNode dbs]$ vi initprod.ora
注释掉下面一行
#parallel_automatic_tuning = true
重启启动实例到nomount状态
SQL> startup nomount;
ORACLE instance started.

Total System Global Area 201326592 bytes
Fixed Size 1218484 bytes
Variable Size 88082508 bytes
Database Buffers 104857600 bytes
Redo Buffers 7168000 bytes
执行建库脚本cr_db.sql
SQL> @$ORACLE_HOME/dbs/cr_db.sql;

Database created.
通过告警日志看到建库的详细过程如下:
create database prod
user sys identified by ****user system identified by *datafile '$ORACLE_BASE/oradata/prod/system01.dbf' size 400m
sysaux datafile '$ORACLE_BASE/oradata/prod/sysaux01.dbf' size 100m
default temporary tablespace temp tempfile '$ORACLE_BASE/oradata/prod/temp01.dbf' size 100m
undo tablespace rtbs datafile '$ORACLE_BASE/oradata/prod/undo01.dbf' size 100m
logfile
group 1 '$ORACLE_BASE/oradata/prod/redo01.log' size 50m,
group 2 '$ORACLE_BASE/oradata/prod/redo02.log' size 50m
character set zhs16gbk
Sun Feb 15 00:28:30 2015
Database mounted in Exclusive Mode
Sun Feb 15 00:28:33 2015
Successful mount of redo thread 1, with mount id 283499181
Assigning activation ID 283499181 (0x10e5daad)
Thread 1 opened at log sequence 1
Current log# 1 seq# 1 mem# 0: /u01/app/oracle/oradata/prod/redo01.log
Successful open of redo thread 1
Sun Feb 15 00:28:33 2015
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Sun Feb 15 00:28:33 2015
SMON: enabling cache recovery
Sun Feb 15 00:28:33 2015
create tablespace SYSTEM datafile '$ORACLE_BASE/oradata/prod/system01.dbf' size 400m

人气教程排行