[20171124]手工使用种子库建库.txt

[20171124]手工使用Seed_Database.dfb和Seed_Database.ctl建库.txt

--//昨天看yueli34的帖子,链接http://www.itpub.net/thread-2094530-1-1.html,注解与说明来自链接,感谢yueli34操作提示.
--//自己测试看看:

1.建立参数文件
--//建立参数文件,目录为$ORACLE_HOME/dbs:

$ cat /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/initseeddata.ora
db_name=seeddata
sga_target=1024M
control_files=/u01/app/oracle/oradata/ora11g/control01.ctl
compatible=11.2.0.4

$ mkdir -p /u01/app/oracle/oradata/ora11g/

--//启动到nomount状态进行验证
$ export ORACLE_SID=seeddata

SYS@seeddata> startup nomount;
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size                  2260088 bytes
Variable Size             297796488 bytes
Database Buffers          759169024 bytes
Redo Buffers                9711616 bytes

2.建立控制文件
$ cd $ORACLE_HOME/assistants/dbca/templates

$ ls $ORACLE_HOME/assistants/dbca/templates  -l
total 301856
-rw-r--r-- 1 oracle oinstall      5104 2013-08-24 12:08:38 Data_Warehouse.dbc
-rwxr-xr-x 1 oracle oinstall  21741568 2015-01-29 11:12:03 example01.dfb
-rwxr-xr-x 1 oracle oinstall   1507328 2015-01-29 11:12:03 example.dmp
-rw-r--r-- 1 oracle oinstall      4984 2013-08-24 12:08:44 General_Purpose.dbc
-rw-r--r-- 1 oracle oinstall     11489 2013-05-01 08:24:26 New_Database.dbt
-rwxr-xr-x 1 oracle oinstall   9748480 2015-01-29 11:11:15 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall 275750912 2015-01-29 11:11:15 Seed_Database.dfb

$ cp $ORACLE_HOME/assistants/dbca/templates/Seed_Database.ctl  /u01/app/oracle/oradata/ora11g/control01.ctl

$ ls -l /u01/app/oracle/oradata/ora11g/control01.ctl
-rwxr-xr-x 1 oracle oinstall 9748480 2017-11-23 10:43:13 /u01/app/oracle/oradata/ora11g/control01.ctl

--//启动到mount状态进行验证:
SYS@seeddata> alter database mount ;
Database altered.

--//处理日志文件路径,控制文件中日志文件路径为:
SYS@seeddata> @ &r/logfile
GROUP# STATUS TYPE       MEMBER                                               IS_REC GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARCHIV STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ------ ---------- ---------------------------------------------------- ------ ------ ------- --------- ----------- --------- ------- ------ ---------- ------------- ------------------- ------------ -------------------
     1        ONLINE     /ade/b/2232964209/oracle/oradata/seeddata/redo01.log NO          1       1        70    52428800       512       1 NO     INACTIVE          889458 2013-08-24 12:03:35       894960 2013-08-24 12:03:36
     2        ONLINE     /ade/b/2232964209/oracle/oradata/seeddata/redo02.log NO          2       1        71    52428800       512       1 NO     INACTIVE          894960 2013-08-24 12:03:36       920281 2013-08-24 12:04:15
     3        ONLINE     /ade/b/2232964209/oracle/oradata/seeddata/redo03.log NO          3       1        72    52428800       512       1 NO     CURRENT           920281 2013-08-24 12:04:15 2.814750E+14

--//是一个不存在的路径,需要rename到/u01/app/oracle/oradata/ora11g/路径。
alter database rename file '/ade/b/2232964209/oracle/oradata/seeddata/redo01.log' to '/u01/app/oracle/oradata/ora11g/redo01.log';
alter database rename file '/ade/b/2232964209/oracle/oradata/seeddata/redo02.log' to '/u01/app/oracle/oradata/ora11g/redo02.log';
alter database rename file '/ade/b/2232964209/oracle/oradata/seeddata/redo03.log' to '/u01/app/oracle/oradata/ora11g/redo03.log';

SYS@seeddata> @ &r/logfile
GROUP# STATUS     TYPE       MEMBER                                    IS_REC GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARCHIV STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- ----------------------------------------- ------ ------ ------- --------- ----------- --------- ------- ------ ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /u01/app/oracle/oradata/ora11g/redo01.log NO          1       1        70    52428800       512       1 NO     INACTIVE          889458 2013-08-24 12:03:35       894960 2013-08-24 12:03:36
     2            ONLINE     /u01/app/oracle/oradata/ora11g/redo02.log NO          2       1        71    52428800       512       1 NO     INACTIVE          894960 2013-08-24 12:03:36       920281 2013-08-24 12:04:15
     3            ONLINE     /u01/app/oracle/oradata/ora11g/redo03.log NO          3       1        72    52428800       512       1 NO     CURRENT           920281 2013-08-24 12:04:15 2.814750E+14

--OK.

3.注册数据文件备份集
--//注册备份集Seed_Database.dfb:

RMAN> catalog start with '$ORACLE_HOME/assistants/dbca/templates/Seed_Database.dfb';
searching for all files that match the pattern $ORACLE_HOME/assistants/dbca/templates/Seed_Database.dfb
List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/product/11.2.0.4/dbhome_1/assistants/dbca/templates/Seed_Database.dfb

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/product/11.2.0.4/dbhome_1/assistants/dbca/templates/Seed_Database.dfb

--//查看备份集,可以看到一个相同的备份集有两个copy。一个是控制文件原有的,一个是catalog新注册进去。其中原有是其实不存在
--//,可以通过crosscheck加delete去除。

RMAN> list backup ;
List of Backup Sets
===================
BS Key  Type LV Size
------- ---- -- ----------
1       Full    262.97M
  List of Datafiles in backup set 1
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 925701     2013-08-24 12:07:43 /ade/b/2232964209/oracle/oradata/seeddata/system01.dbf
  2       Full 925701     2013-08-24 12:07:43 /ade/b/2232964209/oracle/oradata/seeddata/sysaux01.dbf
  3       Full 925701     2013-08-24 12:07:43 /ade/b/2232964209/oracle/oradata/seeddata/undotbs01.dbf
  4       Full 925701     2013-08-24 12:07:43 /ade/b/2232964209/oracle/oradata/seeddata/users01.dbf
  Backup Set Copy #1 of backup set 1
  Device Type Elapsed Time Completion Time     Compressed Tag
  ----------- ------------ ------------------- ---------- ---
  DISK        00:00:31     2013-08-24 12:08:24 YES
    List of Backup Pieces for backup set 1 Copy #1
    BP Key  Pc# Status      Piece Name
    ------- --- ----------- ----------
    1       1   AVAILABLE   /ade/b/2232964209/oracle/oradata/Seed_Database.dfb
  Backup Set Copy #2 of backup set 1
  Device Type Elapsed Time Completion Time     Compressed Tag
  ----------- ------------ ------------------- ---------- ---
  DISK        00:00:31     2017-11-23 10:47:42 YES
    List of Backup Pieces for backup set 1 Copy #2
    BP Key  Pc# Status      Piece Name
    ------- --- ----------- ----------
    2       1   AVAILABLE   /u01/app/oracle/product/11.2.0.4/dbhome_1/assistants/dbca/templates/Seed_Database.dfb

--//校验和删除expired backup
--//RMAN> crosscheck backup;
RMAN> crosscheck backup;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/ade/b/2232964209/oracle/oradata/Seed_Database.dfb RECID=1 STAMP=824299673
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/product/11.2.0.4/dbhome_1/assistants/dbca/templates/Seed_Database.dfb RECID=2 STAMP=960806862
Crosschecked 2 objects

--//RMAN> delete expired backup;
RMAN> delete expired backup;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1       1       1   1   EXPIRED     DISK        /ade/b/2232964209/oracle/oradata/Seed_Database.dfb

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/ade/b/2232964209/oracle/oradata/Seed_Database.dfb RECID=1 STAMP=824299673
Deleted 1 EXPIRED objects

--//以上步骤感觉不需要做.

--//修改数据文件路径,我注解recover database;因为这步没有归档,写不写都一样.
run{
set newname for datafile 1 to '/u01/app/oracle/oradata/ora11g/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/ora11g/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/ora11g/undotbs01.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/ora11g/users01.dbf';
restore database;
switch datafile all;
##recover database;
}

executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting restore at 2017-11-23 10:49:53
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1409 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ora11g/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ora11g/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ora11g/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: reading from backup piece /ade/b/2232964209/oracle/oradata/Seed_Database.dfb
channel ORA_DISK_1: errors found reading piece handle=/ade/b/2232964209/oracle/oradata/Seed_Database.dfb
channel ORA_DISK_1: failover to piece handle=/u01/app/oracle/product/11.2.0.4/dbhome_1/assistants/dbca/templates/Seed_Database.dfb tag=NULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 2017-11-23 10:50:39

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=960807039 file name=/u01/app/oracle/oradata/ora11g/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=960807039 file name=/u01/app/oracle/oradata/ora11g/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=960807039 file name=/u01/app/oracle/oradata/ora11g/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=960807039 file name=/u01/app/oracle/oradata/ora11g/users01.dbf

Starting recover at 2017-11-23 10:50:39
using channel ORA_DISK_1

starting media recovery

RMAN-08187: WARNING: media recovery until SCN 925701 complete
Finished recover at 2017-11-23 10:50:41

3.打开数据库:
SYS@seeddata> alter database open read only ;
Database altered.
--// 补充测试open read only可以打开.

SYS@seeddata> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SYS@seeddata> alter database open NORESETLOGS;
alter database open NORESETLOGS
*
ERROR at line 1:
ORA-01588: must use RESETLOGS option for database open

SYS@seeddata> select CONTROLFILE_TYPE from v$database ;
CONTROLFILE_TY
--------------
BACKUP

4.尝试使用建立新控制文件是否可行:

SYS@seeddata> alter database backup controlfile to trace ;
Database altered.

$ cat cc.txt
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "SEEDDATA" NORESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/ora11g/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/ora11g/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/ora11g/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/u01/app/oracle/oradata/ora11g/system01.dbf',
  '/u01/app/oracle/oradata/ora11g/sysaux01.dbf',
  '/u01/app/oracle/oradata/ora11g/undotbs01.dbf',
  '/u01/app/oracle/oradata/ora11g/users01.dbf'
CHARACTER SET US7ASCII
;
--//注意这样安装的数据库字符集是US7ASCII,这也很好理解US7ASCII是所有字符集的子集.

SYS@seeddata> @ /tmp/cc.txt
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size                  2260088 bytes
Variable Size             297796488 bytes
Database Buffers          759169024 bytes
Redo Buffers                9711616 bytes
CREATE CONTROLFILE REUSE DATABASE "SEEDDATA" NORESETLOGS  NOARCHIVELOG
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-01192: must have at least one enabled thread

$ oerr ora 01192
01192, 00000, "must have at least one enabled thread"
// *Cause:  You must specify at least two logfiles from at least one thread
//        at the create contolfile command line.
// *Action:  Find the missing logfiles and resubmit the command with the newly
//        found logfiles included in the command line.

--//重来!!
SYS@seeddata> alter database clear logfile group 1 ;
Database altered.

SYS@seeddata> alter database clear logfile group 2 ;
Database altered.

SYS@seeddata> alter database clear logfile group 3 ;
Database altered.

--//依旧不行.
--//安装一些文章的提示建立的控制文件只能RESETLOGS.

SYS@seeddata> alter database open RESETLOGS;
Database altered.

--//关闭数据库重新建立控制文件ok.

SYS@seeddata> @ /tmp/cc.txt
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size                  2260088 bytes
Variable Size             297796488 bytes
Database Buffers          759169024 bytes
Redo Buffers                9711616 bytes
Control file created.

SYS@seeddata> alter database open ;
Database altered.

RMAN> list incarnation;

using target database control file instead of recovery catalog

List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       SEEDDATA 4152976186       CURRENT 925702     2017-11-23 11:43:14

5.补充建立临时文件:
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/ora11g/temp01.dbf' REUSE;
--//这样建立报错.

$ touch /u01/app/oracle/oradata/ora11g/temp01.dbf
SYS@seeddata> ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/ora11g/temp01.dbf' size 100m REUSE;
Tablespace altered.

6.最后yueli34想实现NORESETLOGS开库,而原始的控制文件本身是备份类型,如果能修改为当前,估计可以.
SYS@seeddata> select CONTROLFILE_TYPE from v$database ;
CONTROLFILE_TY
--------------
BACKUP

时间: 2024-10-23 14:07:26

[20171124]手工使用种子库建库.txt的相关文章

oracle 10G手工建库及OEM配置

今天闲来无事,天气太热,坐在办公室就像练蒸功夫一样,于是乎,就实施了一次手工建库,并启用OEM来管理数据库 以下操作都是用 oracle 用户组 1.创建文本初始化参数文件init$SID.ora及相应的dump目录 vi  $ORACLE_HOME/dbs/initLHZ.ora compatible='10.2.0.4.0' db_name='LHZ' sga_max_size=500M sga_target=200M undo_management='AUTO' undo_tablespa

手工建库

手工建库步骤: 1.创建数据库所需的目录,包括数据文件存放目录,日志存放目录,归档存放目录等2.创建密码文件3.创建参数文件4.通过刚创建的pfile参数将数据库启动的nomount状态5.开始执行create database 命令创建数据库6.创建数据库相关视图和数据字典7.检查数据库状态,是否创建完成8.将创建数据库用的pfile参数创建成spfile,以后启动的时候不需要指定.9.重启数据库,验证第八步骤10.数据库创建完成. ------------------------------

Oracle手工建库

000  环境:OEL6.5+Oracle 11g R2 前提:数据库软件已安装完毕 001 建立参数文件 1.1 进入init.ora所在目录 cd $ORACLE_HOME/dbs 1.2 利用init.ora生成init.ora文件,即所谓的pfile. cat init.ora | grep -v ^# | grep -v ^$ > initPROD.ora 1.3 修改pfile 需要修改的参数:db_name.audit_file_dest.db_recovery_file_dest

SqlServer编写数据库表的操作方式(建库、建表、修改语句)_MsSql

学习要点: SQL之-建库.建表.建约束.关系SQL基本语句大全.txt举得起放得下叫举重,举得起放不下叫负重.头要有勇气,抬头要有底气.学习要加,骄傲要减,机会要乘,懒惰要除.人生三难题:思,相思,单相思. SQL之-建库.建表.建约束.关系.部分T-sql语句 ---创建库 创建库之前 先进行 查看数据库中是否 已存在 次数据库 有便删除 --- if exists(select * from sys.sysdatabases where name='ConstructionDB')begi

DBCA静默建库中的两个小问题

创建数据库,主要有手工建库,DBCA建库,OMF建库.手工建库会重新初始化数据字典,过程相对比较耗时,但是完全定制化:OMF建库的场景比较特别,一般都是糅合在ASM中使用;DBCA图形化建库使用场景受限较大,其实DBCA还有另外一种快捷的方式就是DBCA静默建库,整个过程分分钟即可搞定. 如果说想简单使用,可以参考下面的例子,比如我们创建数据库为testdb,字符集为ZHS16GBK,命令如下:  dbca -silent -createDatabase -templateName $ORACL

MySQL的数据类型和建库策略详解

mysql|策略|数据|数据类型|详解 无论是在小得可怜的免费数据库空间或是大型电子商务网站,合理的设计表结构.充分利用空间是十分必要的.这就要求我们对数据库系统的常用数据类型有充分的认识.下面我就将我的一点心得写出来跟大家分享. 一.数字类型.数字类型按照我的分类方法分为三类:整数类.小数类和数字类. 我所谓的"数字类",就是指DECIMAL和NUMERIC,它们是同一种类型.它严格的说不是一种数字类型,因为他们实际上是将数字以字符串形式保存的:他的值的每一位(包括小数点)占一个字节

在线建库

在线 <%on error resume nextclass createdb'''建立一个数据库'用法:'dim cdb'set cdb=new createdb'cdb.setdbname=数据库名 'if cdb.ifok then response.end 数据库已经存在 'cdb.run'检查是否运行成功'if cdb.ifok then'response.write cdb.errs'end if private dbname '数据库名字private ifsure '用来保存是否

MySQL数据类型及建库策略

无论是在小得可怜的免费数据库空间或是大型电子商务网站,合理的设计表结构.充分利用空间是十分必要的.这就要求我们对数据库系统的常用数据类型有充分的认识.下面我就将我的一点心得写出来跟大家分享. 一.数字类型 数字类型按照我的分类方法分为三类:整数类.小数类和数字类. 我所谓的"数字类",就是指 DECIMAL 和 NUMERIC,它们是同一种类型.它严格的说不是一种数字类型,因为他们实际上是将数字以字符串形式保存的:他的值的每一位 (包括小数点) 占一个字节的存储空间,因此这种类型耗费空

MySQL的数据类型和建库策略

无论是在小得可怜的免费数据库空间或是大型电子商务网站,合理的设计表结构.充分利用空间是十分必要的.这就要求我们对数据库系统的常用数据类型有充分的认识.下面我就将我的一点心得写出来跟大家分享. 一.数字类型 数字类型按照我的分类方法分为三类:整数类.小数类和数字类. 我所谓的"数字类",就是指 DECIMAL 和 NUMERIC,它们是同一种类型.它严格的说不是一种数字类型,因为他们实际上是将数字以字符串形式保存的:他的值的每一位 (包括小数点) 占一个字节的存储空间,因此这种类型耗费空