ITPub博客

首页 > Linux操作系统 > Linux操作系统 > DBCA和手工建库

DBCA和手工建库

原创 Linux操作系统 作者:yuecaibo 时间:2012-03-05 23:56:33 0 删除 编辑

dbca
 数据库创建助手
  确认主机名,DNS和glogin.sql文件中书写正确(里面不要写DDL语句) 基本都能创建成功

ps -ef |grep ora_

export ORACLE_SID=test
conn / as sysdba
show parameter name

export ORACLE_SID=orcl
conn / as sysdba
show parameter name


手工建库

一.准备数据库物理文件存放的相关路径
     1.trace file(实例管理目录): 默认位置 $ORACLE_BASE/admin//
 
 SYS@test> !echo $ORACLE_BASE
 /home/oracle

 SYS@test>
 SYS@test> !echo $ORACLE_SID
 seker

 SYS@test>
 SYS@test> ! mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump

 SYS@test> ! mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/bdump

 SYS@test> ! mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/cdump

 SYS@test> ! mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/udump

 SYS@test>

 
    2.存放数据文件的目录:
 SYS@test> ! mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID/

 SYS@test>
 
 
二.设置环境变量
 vim  .bash_profile
  export ORACLE_BASE=/home/oracle
  export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
  export ORACLE_SID=seker
  export PATH=$PATH:$ORACLE_HOME/bin
  export LANG=zh_CN.UTF-8
  export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
  alias sqlplus='rlwrap sqlplus'
  alias sql='rlwrap sqlplus'
  alias rman='rlwrap rman'
  alias lsnrctl='rlwrap lsnrctl'
 :wq
 
三.创建口令文件
   orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=1 force=y

 

四.准备参数文件
vim $ORACLE_HOME/dbs/init$ORACLE_SID.ora
shared_pool_size=200M
compatible='10.2.0.1.0'
db_name='seker'
control_files='/u01/oracle/oradata/seker/control01.ctl'
audit_file_dest='/u01/oracle/admin/seker/adump'
background_dump_dest='/u01/oracle/admin/seker/bdump'
core_dump_dest='/u01/oracle/admin/seker/cdump'
user_dump_dest='/u01/oracle/admin/seker/udump'
undo_management='AUTO'
undo_tablespace='UNDOTBS1'
:wq

五.启动数据库到nomount
[oracle@seker ~]$ export ORACLE_SID=seker
[oracle@seker ~]$ echo $ORACLE_SID
seker
[oracle@seker ~]$ sql /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 21 07:32:30 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

idle> conn / as sysdba
Connected to an idle instance.
idle> startup nomount
ORACLE instance started.

Total System Global Area  289406976 bytes
Fixed Size      1219016 bytes
Variable Size    234882616 bytes
Database Buffers    50331648 bytes
Redo Buffers      2973696 bytes
idle> show parameter name

NAME         TYPE          VALUE
------------------------------------ --------------------------------- ------------------------------
db_file_name_convert       string
db_name         string          seker
db_unique_name        string          seker
global_names        boolean          FALSE
instance_name        string          seker
lock_name_space        string
log_file_name_convert       string
service_names        string          seker
idle>

六. 创建数据库

CREATE database seker
maxinstances 8
maxloghistory 1
maxlogfiles 16
maxlogmembers 3
maxdatafiles 100
DATAFILE '/u01/oracle/oradata/seker/system01.dbf'  size 300m autoextend on next 10m extent management local
sysaux datafile '/u01/oracle/oradata/seker/sysaux01.dbf'  size 120m autoextend on next 10m
default temporary tablespace temp tempfile '/u01/oracle/oradata/seker/temp01.dbf' size 20m
undo tablespace undotbs1 datafile '/u01/oracle/oradata/seker/undotbs01.dbf' size 50m
CHARACTER set AL32UTF8
NATIONAL character set AL16UTF16
SET TIME_ZONE='+08:00'
LOGFILE
group 1 '/u01/oracle/oradata/seker/redo01.log' size 50M,
group 2 '/u01/oracle/oradata/seker/redo02.log' size 50M;

 

ERROR:
ORA-06553: PLS-213: package STANDARD not accessible

Database created.

idle>

创建完成 但有错误 退出SQLPLUS 再重新登录

 

七.创建数据字典
@?/rdbms/admin/catalog
@?/rdbms/admin/catproc

 

八.创建users表空间 建立scott用户
SQL> create tablespace users datafile '/u01/oracle/oradata/seker/user01.dbf' size 10m autoextend on;

Tablespace created.

Elapsed: 00:00:00.15
SQL> @?/rdbms/admin/utlsampl

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dba dbs]$ sql /nolog

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 7 06:06:50 2011

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> conn / as sysdba
Connected.
SQL> alter user scott account unlock identified by seker;

User altered.

Elapsed: 00:00:00.61


九.连接到scott用户有错误提示 根据提示执行PUPBLD脚本
SQL> conn scott/seker
Error accessing PRODUCT_USER_PROFILE
Warning:  Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM
Connected.
SQL>
SQL> conn system/manager
Connected.
SQL>
SQL> show user
USER is "SYSTEM"
创建安全审核概要表:
SQL> @?/sqlplus/admin/pupbld
SQL> conn scott/seker
Connected.

十.重新启动 测试数据库是否正常
SQL> conn / as sysdba
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> create spfile from pfile;

File created.

Elapsed: 00:00:00.04
SQL> startup
ORACLE instance started.

Total System Global Area  184549376 bytes
Fixed Size      1266488 bytes
Variable Size    130026696 bytes
Database Buffers    50331648 bytes
Redo Buffers      2924544 bytes
Database mounted.
Database opened.
SQL>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24756465/viewspace-717773/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 数据库的停止
下一篇: 建立裸设备库
请登录后发表评论 登录
全部评论

注册时间:2012-03-03

  • 博文量
    42
  • 访问量
    36150