当前位置:  数据库>oracle

手工创建Oracle数据库

    来源: 互联网  发布时间:2017-05-21

    本文导语: 一、初始化1、创建初始化文件[Oracle@sigleNode dbs]$ more initdw.ora|grep -v '#'|grep -v '^$'>initprod.ora编辑初始化文件,进行参数设置,在原来参数设置基础之上增加以下设置db_name=proddb_cache_size = 100Mshared_pool_size = 60Mparallel_threads_per_cpu = 4backg...

一、初始化
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

  default storage (initial 10K next 10K) EXTENT MANAGEMENT DICTIONARY online
Sun Feb 15 00:28:41 2015
Completed: create tablespace SYSTEM datafile  '$ORACLE_BASE/oradata/prod/system01.dbf' size 400m
  default storage (initial 10K next 10K) EXTENT MANAGEMENT DICTIONARY online
Sun Feb 15 00:28:41 2015
create rollback segment SYSTEM tablespace SYSTEM
  storage (initial 50K next 50K)
Completed: create rollback segment SYSTEM tablespace SYSTEM
  storage (initial 50K next 50K)
Sun Feb 15 00:28:50 2015
CREATE UNDO TABLESPACE RTBS DATAFILE  '$ORACLE_BASE/oradata/prod/undo01.dbf' size 100m

Sun Feb 15 00:28:52 2015
Successfully onlined Undo Tablespace 1.
Completed: CREATE UNDO TABLESPACE RTBS DATAFILE  '$ORACLE_BASE/oradata/prod/undo01.dbf' size 100m
Sun Feb 15 00:28:52 2015
create tablespace SYSAUX datafile  '$ORACLE_BASE/oradata/prod/sysaux01.dbf' size 100m

  EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online
Completed: create tablespace SYSAUX datafile  '$ORACLE_BASE/oradata/prod/sysaux01.dbf' size 100m
  EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online
Sun Feb 15 00:28:55 2015
CREATE TEMPORARY TABLESPACE TEMP TEMPFILE  '$ORACLE_BASE/oradata/prod/temp01.dbf' size 100m

Completed: CREATE TEMPORARY TABLESPACE TEMP TEMPFILE  '$ORACLE_BASE/oradata/prod/temp01.dbf' size 100m
Sun Feb 15 00:28:56 2015
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP
Completed: ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP
Sun Feb 15 00:28:56 2015
ALTER DATABASE DEFAULT TABLESPACE SYSTEM
Completed: ALTER DATABASE DEFAULT TABLESPACE SYSTEM
Sun Feb 15 00:29:01 2015
SMON: enabling tx recovery
Sun Feb 15 00:29:03 2015
Threshold validation cannot be done before catproc is loaded.
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=13, OS id=18386
Sun Feb 15 00:29:04 2015
Completed: 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

3、建立数据字典
[oracle@sigleNode dbs]$ vi cr_dict.sql

@$ORACLE_HOME/rdbms/admin/catalog.sql
@$ORACLE_HOME/rdbms/admin/catproc.sql
conn system/prod
@$ORACLE_HOME/sqlplus/admin/pupbld.sql

  直接执行脚本
SQL>@ORACLE_HOME/dbs/cr_dict.sql;
即可

4、创建用户表空间
SQL> create tablespace users datafile '$ORACLE_BASE/oradata/prod/user01.dbf' size 500m;

Tablespace created.

SQL> alter database default tablespace users;

Database altered.

创建数据库prod完成

相关阅读:


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 怎样手工删除在XANDROS安装的软件?
  • 如何用代码手工实现激活事件发生
  • 如何手工扩大交换分区
  • wu-ftp在redhat7.3上怎么手工安装?
  • 高手救命,很急——ORACLE817安装在UNIXWARE711上,手工启动数据库后在netasst中连接错误,高手帮我看看? iis7站长之家
  • 手工删除/var/spool/pkg/下的文件包后,pkgadd还是提示软件包有安装,为什么?
  • IBM 7133 磁盘阵列更换硬盘是自动同步还是要手工?
  • ubuntu 如何手工安装ssh
  • 如何手工安装应用程序??
  • 文本模式下安装redhat到disk druid手工分区时……
  • 怎么手工启动和停止sco unix 的服务,另外怎么看服务所占的端口号
  • 请教高手:可不可以手工改tomcat的jdk?
  • java里面有类似VC++的Class wizzard 吗?每个方法都要自己手工加太麻烦了吧?
  • 有没有开发Applet的RAD开发工具? 我手工添加Applet设置按钮位置的代码太麻烦了
  • java中有没有destructor的东东,好像一般的class里都没有嘛,难道不要手工做这些事情,全部交给gc处理吗?
  • linux环境下,java程序手工运行不乱码,crontab自动运行就乱码
  • SQL Server手工插入标识列的方法
  • >>>>手工编译安装与rpm软件管理器>>>>
  • 请问一个初级问题,我在手工编译一个EJB的文件时包错,如下
  • sqlserver 手工实现差异备份的步骤


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,