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

来源:http://www.cnblogs.com/lfree/archive/2017/11/24/7888915.html
-Advertisement-
Play Games

[20171124]手工使用Seed_Database.dfb和Seed_Database.ctl建庫.txt--//昨天看yueli34的帖子,鏈接http://www.itpub.net/thread-2094530-1-1.html,註解與說明來自鏈接,感謝yueli34操作提示.--//自己 ...


[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



您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1.簡介 Redis是完全開源的ANSI C語言編寫、遵守BSD協議,高性能的key-value資料庫。 1.1特點 Redis支持數據的持久化,可以將記憶體中的數據保存在磁碟中,重啟的時候可以再次載入進行使用。 Redis不僅僅支持簡單的key-value類型的數據,同時還提供list,set,zs ...
  • 1.簡介 Redis是完全開源的ANSI C語言編寫、遵守BSD協議,高性能的key-value資料庫。 1.1特點 Redis支持數據的持久化,可以將記憶體中的數據保存在磁碟中,重啟的時候可以再次載入進行使用。 Redis不僅僅支持簡單的key-value類型的數據,同時還提供list,set,zs ...
  • max_connections 和 max_user_connections:max_connections預設是151,當MySQL與Apache Web伺服器一起使用時,可以提高性能。mysqld實際上允許max_connections + 1客戶端連接,額外的1個連接預留給具有超級許可權的帳戶使... ...
  • 上圖中即為redis中5種基本數據類型,在沒接觸過redis之前,聽過最多相關的字眼就是鍵值對key-value之類,立馬讓我想到了HashMap。在HashMap中,key和value的的數據類型都可以指定,value也可以是HashMap類型。而在這裡,redis的基本數據類型是針對的value ...
  • 昨天有幫助網友解決的個字元串截取的問題,《截取字元串中最後一個中文詞語(MS SQL)》http://www.cnblogs.com/insus/p/7883606.html 雖然實現了,但始終覺得代碼寫得很複雜。MS SQL Server中沒有一個如同C#一樣的函數LastIndexOf。沒有,我 ...
  • 1、zookeeper操作相關命令: 2、hdfs操作相關命令: 3、yarn操作相關命令: 4、hive相關操作命令: 5、hbase操作相關命令: ...
  • 工具:win10系統 orcl11G 問題:INS-13001環境不滿足最低要求 解決方法: 1 找到你解壓後的文件,點擊打開database文件夾 ==》stage文件夾 ==》cvu文件夾 ==》cvu_prereq.xml文件,用記事本打開cvu_prereq.xml文件; 2 在<CERTI ...
  • /etc/my.cnf 參考配置: [mysqld] #skip-grant-tables #default-character-set=utf8 #character-set-server=utf8 port= 3306 skip-external-locking key_buffer_size ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...