2008年07月4日

10升11g的讀書筆記(2)

第二部份筆記

3、Oracle Database New Availability and Recovery Features
  •     Fault Diagnosability Infrastructure :
    • The Automatic Diagnostic Repository (ADR) : 主要是再次把相關的資料庫資訊目錄再次規範,這時引入一個新的參數 diagnostic_dest ,11g中取消 user_dump_dest,core_dump_dest,backgroup_dump_dest。預設的 diagnostic_dest 是指向 $ORACLE_BASE,假如 $ORACLE_BASE 沒有設的話,就指向 $ORACLE_HOME
      我們假設目錄為 /u01/oracle/diag/rdbms/mydb/MyInstanceName
      這時的oracle_home為 /u01/oracle
      ADR 的起始目錄 (root) 為 diag
      product_type 為 rdbms
      database name 為 mydb
      instance name 為 MyInstanceName
      • ADR 在 rac 可自定每個node都有自已的ADR目錄,官方是建議共用一個 ADR 設定,這樣子可帶來每個node都可查看到全部node相關的資料
      • 在MyInstanceName下面有幾個較重要的目錄
        • alert : 11g中引入xml格式的alert log,所以也提供了對應的查尋的方式,不過也有保留舊的純文字log
        • cdump : 跟以前相同
        • trace : 跟以前相同
        • incident : 跟以前相同
      • 可查尋 v$diag_info 就可知道現在 ADR 的目錄配置情況
    • Ths alert log
      • 11g 提供另一種新的格式,是由xml組成的,主要是方便其他的工具進行分析
      • 新的操作指令 : adrci
        • 較常用的語法
          • show alert -tail ;就跟 linux中的tail 功效相同
          • show homes : 查看現在有多少個home
          • set homepath xxxxxxx : 設定新的home為誰
    • Trace , dump , and core files : 主要是配合 11g 中增強 metalink 的功能
    • The Support Workbench :
      • 提供多個操作介面,如有 Oracle Enterprise Manager 、 PL/SQL package dbms_hm 、 dbms_sqldiag.
      • 把相關的check、ora-xxx 的錯誤訊習集中管理,並且提供較佳的介面可以查到較細節的錯誤。共有下列這幾種check
        • Database Structure Integrity Check : 資料庫在open、mount時會自動檢查檔案是否損壞、遺失,但當資料庫是在nomount時,將只檢查controlfile
        • Data Block Integrity Check : 檢查 image block是否有短錯誤,可在 V$DATABASE_BLOCK_CORRUPTION 看到較詳細的訊習
        • Redo Integrity Check : 檢查 redo log file是否都可讀取
        • Undo Segment Integrity Check : 查看logic undo 是否有錯誤,如有錯誤發現,oracle會試使用PMON(process monitor) 和 SMON (System Monitor)去recover 發生錯誤的交易(transaction),假如無法修覆的話,可查看 v$corrupt_xid_list 將會記錄,這是較偏向實體檔案方面
        • Transaction Integrity Check : 跟undo segment integrity check很像,只是較偏向羅輯面,當transaction發生錯誤時,oracle會試著用PMON、SMON去修復,如無法的話,將可於 v$corrupt_xid_list 中查看的到
        • Dictionary Integrity Check :檢查oracle最重要的 Dictionary 的object之間關連是否正確
      • health check
        • 有二個模式:
        •  
          • 模式一 : 被動式,固名思意,就是不是主動去檢查,只有當oracle發現在重大錯誤時,才會進行
          • 模式二 : 手動式,由dba自行執行  dbms_hm PL/SQL 去執行檢查,或是由 OEM web介面進行檢查
        • 資料庫在 open 、 mount的模式之下全部的check的選項都可執行;但在nomount時,只有特定的check才能執行,有 redo integrity check 、database structure integrity check
        • 手動執行check時,可由 v$hm_check 查看到檢查記錄,如: 
          1、執行
          Begin
          dbms_hm.run_check('Dictionary Integrity Check','test_run');
          End;
          /

          2、查看是否有在執行
          select run_id,name from v$hm_run;

          3、查看更進階的資訊
          set long 10000
          set longchunksize 1000
          set pagesuze 1000
          set linesize 512
          dbms_hm.get_run_report('test_run');
      •  
        • v$hm_run : 查看現在檢查的進度
        • 也可使用adrci查看相關的訊習
          • adrci >> set homepath diag/rdbms/oracle1/orcl
          • adrci >> show report hm_run test_run
    • ADR Command Interpreter (ADRCI) command-line utility
    • Other ADR Contents
  • RMAN New Features
    • 平 行備份 : 11g加強了平行備份的能力,因為以前的版本所指的平行備份是指多個channel可同時備份,但每個channel只能同時備份一個datafile。 所以在11g,真的是支援到平行備份了,因為oracle會把單一大檔打散成多個channel中。但有好處也會帶來相對的問題,如是i/o本身就不強的 情況下,使用平行備份反正有可能讓備份的速度變慢,主要是磁碟頭要不斷的來回走動,所以這是需要考量的。語法:
      backup section size 300M tablespace user_data;
    • 壓縮備份 : 在11g中多提供了另一種壓縮格式 ZLIB ,10g是支援BZIP2 。如使用壓縮功能並沒有定議是要使用那種的話,就會採用ZLIB。如要手動指定的話,語法如:
      configure compression algorithm 'ZLIB';
      configure compression algorithm 'BZIP2';
      ZLIB是吃cpu資源的,所以當系統是卡在cpu上面的話,可考慮採用 BZIP2。
  • 複製database : 在11g以前要複製database時,需要備份現在的database,然後放至於目的地機器上,才能進行複製。而這次將不需要這樣子做,可以直接進行複製
    • 大致的流程如下:
      • create the oracle database directory structures
        • 安裝oracle,建立必要的目錄
      • create the password file for the auxiliary instance
        • 建立password file ,如:orapwd file=pwdremote.ora password=remote_passwd。到時要配合 duplicate 指令用
      • configure networking for the auxiliary instance
        • 因為傳送是使用 Oracle Network Configuration ,所以要確保設定都正確
        • 如:
          • rman target=/  auxiliary=sys/remote_passwd@remote_oracle_sid
          • duplicate target database to auxdb from active database spfile nofilenamecheck;
        • 有網友提出,使用oracle內建的通訊協定來傳送檔案,並無法吃滿頻寬,也許可採用如nfs通訊協定來進衛複製。但使用oracle內建的好處就是不需要再次安裝第三方軟體跟設定了
      • create the parameter file for the auxiliary instance
        • 這是個選項,假如是要使用跟來源端一樣的設定的話,可直接複製來源端的spfile;相對的,也可自定新的db的相關參數
      • start the auxiliary instance
        • auxiliary instance 必需於 nomount
  • 設定特定的備份檔保留時間
    • 11g使用 keep ,取代 logs / nologs 。
    • 主要用於特定的備份檔想要額外設定保留,而不受rman裡的設定configure retension policy to recovery window of 7 days;
    • 如 backup datafile 1 keep forever,這就是datafile 1的備份檔永不過期,不受 delete obsolete
  • backup failover for archived redo logs: 在備份時發生archived log file發生錯誤時,如有指定多個路徑存放的話,oracle會自動尋找可用的檔案備份
  • 加強 archiveed redo log 刪除的策略
    • 一般來說,只有falsh recovery area會自動進行刪除,而其他的archive log 將受 retention policy控管。現在11g提供了一個 all 的選項,並且也能管到standby的保留策略。
  • recovery catalog 加強
    • 增加二點:一是提供虛擬catalog以增加安全性,讓不相關的人只能看到所要的資訊,其二是提供 import catalog
  • Undo backup 優化
    • 假如 backup optimization 是設 on 的話,在備份undo tablespace時,只會備份還未 commit 的資料,已commit過的資料將不會備份
  • Block Media Recovery 加強
    • 11g 在修複 block 錯誤時,會先取得 flashback logs 進行修複(假如 flashback 是有開起),可以省下資料從backup set 或是從 tape 取得資料
  • script 方面 : 在以前如要把變數帶入script的話,較通用的方法就是用script再產生要執行的script。現在11g提供變數的方法可以讓這件事更容易了
    • 假 如備份的script, rman_script.sh 內容為 backup database tag '&1' keep until time 'sysdate + 365' restore point '&2' plus archivelog;
      配合 using 這樣子把參數傳入  rman target =rman/pass @'/rman/script/rman_script.sh'  using  my_tag  my_point
  • flashbadck transaction backout :
    • 11g提供 dbms_flashback.transaction_backout 的方法,可由取消一個已commit過的交易資料
    • 必需起動 supplemental logging
      • alter database add supplemental log data;
      • alter database add supplemental log data (primary key) columns;
    • 使用者必需有權限執行 dbms_flashback 跟 select any transaction
  • flashback data archives
    • 跟falshback query非常相像,但底層的運作不太相同,flashback query是使用undo tablespace來實現,所以會有資料被覆蓋過去的問題,就算使用undo_retention,也只能拉長時間,並且undo tablespace使用空間將會非常大。所以11g,oracle提出一個新的flashback來解決個問題,他主要是把全部的資料記錄在指定的 tablespace中,所以可以回查到任何時間點內的資料。多半用於交易記錄的需求上
    • 授權 flashback archive administer 給於使用者
    • 語法:
      • create flashback archive default archive_one_year tablespace retention_archives quota 5G retention 1 year;
      • create flashback archive archive_two_year tablespace retention_archives quota 1T retention 36 month;
      • create table test_archive(id number) flashback archive archive_two_year;
      • 刪除 flashacbk archive 上面的 table 時,需要先解除 flashback archive ,才能進行刪除
        • alter table test_archive no flashback archive;
        • drop table test_archive;
  • standby database
    • archive log 在傳送到standby database前,會自行壓縮後再行傳送
    • standby database 現在可以開在 read-only 的情況下,而可進行查尋這些操作,oracle會自動接收 redo 的資訊,而不必人力介入
    • snapshot database : 轉換成這種模式時,oracle會把database做一個標記,等日後轉換回來時用。這時的oracle還是會自動的接收 primary 送過來的 redo 資料,但並不會把 redo 的改變執行於 db 中。當從 snapshot database 轉回 standby database 時,這時oracle會把 database 的資料時間點轉換之前標記的時間點,然後自動的把這段時間內的 redo 資料變更於 db 中。
  • Oracle Data Pump
    • exp 在11g中不再支援,但imp還是會支援
    • dump file 支援壓縮 : 語法
      • expd  system/passwd  directory=dump_dir   dumpfile=test.dump   compression={ALL | metadata_only | data_only | none}
      • metadata_only 是預設值
    • 增強加密功能 : 語法
      • expdp system/passwd  directory=dump_dir   dumpfile=test.dump  encryption=all  encryption_password=passwd  encryption_algorithm=AES128  encryption_mode=password
      • encryption_algorithm 支援 AES128 、 AES192 、 AES256
      • encryption_mode 支援 dual 、 passwd 、 transparent
    • remap_data
      • 支援匯入時就修改為新的table名字
      • exp時可使用reuse_dumpfile=y來覆蓋已存在的dump檔

4、Oracle Database Advisors
  • database recovery advisor
    • 11g引入了執行修復db的功能,可讓剛入門的dba可盡快解決問題
    • rman增加的指令
      • list failure detail :  可列出db錯誤的記錄
      • advise failure : 可列出建議的解決方式,並且會把操作的流程寫在一個scritp中,這時你可手動執行產生出來的script
      • repari failure : 執行oracle建議的解決方式,進行修複
      • repair failure preview : 可模凝修複流程,但並不會真的執行
      • change faulure xxx priority low : 設定 xxx 編號的錯誤優先等級為 low,但然了也可設為 high
  • SQL Access Advisor
    • 可選擇 index / materialized view / paration 進行建議
   
5、Oracle Database Change Management
  • replay:可把正式區的運行流程的記錄下來,在測試的機器上進行重新執行,有下列幾種情況可以應用
    • database upgrades : 資料庫升級後,進行效能測試
    • database patch install : 安裝了patch後,進行效能測試
    • RAC 增加、減一個node時,也可利用這功能進行效能測試
    • os 平台改變
    • 硬體改變,如cpu、ram、hd
    • 使用這個功能,大約會影響效能4~5%,每個session大約會使用64k的空間記錄相關的操作
    • 如是 rac 的架構下,記錄檔會寫於每個node之下,所以在replay時,需要放在一個地方讓測試環境都能讀寫的到那些檔案才行
    • 手動執行 : dbms_workload_capture
    • 支援
      • all SQL operations including most with binds
      • all long object (LOB) operations
      • local transactions
      • login and logoff
      • session switching
      • some PL/SQL remote procedure call
    • 不支援
      • direct path load operations
      • oracle call-level interface (OCI)-base object navigation and REF binds
      • streams and non-PL/SQL-based Advanced Querying (AQ)
      • distributed transactions
      • flashback operations
      • shared server operations
    • 分析重點
      • 錯誤訊習
      • 效能分析
        • capture跟replay報表
        • ADDM 報表
        • ASH 報表
        • AWR 報表

Posted by my_work at 樂多Roodo! │15:49 │回應(2)引用(0)DB
樂多分類:網路/3C 共同主題:Oracle 工具:加入樂多書籤編輯本文
Ads by Roodo! 

引用URL

http://cgi.blog.roodo.com/trackback/6319967
回應文章
貓大大:
可以請教您一個問題嗎?
我有個Oracle資料庫 他是放在windows cluster上的(有裝Fail Safe)
之前做exp 都是正常的,不過最近掛了,所以重新imp上去,系統還是cluster,不過沒有裝fail.safe
當我在做exp的時候一直出現Ora-00943 cluster does not exist,
請問該如何處理這個問題? 謝謝
Posted by chiway at 2008年07月9日 09:34

我沒有環境可測試,這是我從matelink上查到的方法,你試看看吧

Subject: ORA-943 When Importing Clusters
Doc ID: Note:1005258.6 Type: PROBLEM
Last Revision Date: 25-OCT-2005 Status: PUBLISHED

Problem Description:
====================
You may get the error message ORA-00943: "cluster does not exist" when trying
to move a table out of a cluster in the following way:
- clustered tables are exported
- clustered tables and cluster itself are dropped
- the tables are precreated standalone, without the cluster definition
- when trying to import, IMP fails with ora-00943 (despite the IGNORE=y
option)


Problem Explanation:
====================
The steps above fail with the following errors at import time:

Export file created by EXPORT:V07.00.15
. importing JAVIER's objects into JAVIER
IMP-00017: following statement failed with ORACLE error 943:
"CREATE TABLE "CLU_TABLE1" ("R" NUMBER, "V" CHAR(1)) CLUSTER
"JAVIER_CLUSTE"
"R" ("R", "V")"
IMP-00003: ORACLE error 943 encountered
ORA-00943: cluster does not exist
IMP-00017: following statement failed with ORACLE error 943:
"CREATE TABLE "CLU_TABLE2" ("S" NUMBER, "W" CHAR(1)) CLUSTER
"JAVIER_CLUSTE"
"R" ("S", "W")"
IMP-00003: ORACLE error 943 encountered
ORA-00943: cluster does not exist
Import terminated successfully with warnings.

Solution Description:
====================
Workaround:
----------
* Precreate the cluster definition with the same original name but with
dummy options.
* Retry the same import operation:
The CREATE TABLE will be skipped due to the IGNORE=y option and IMP will
proceed with the import of table data without further errors.
* Drop the dummy cluster definition.


Solution Explanation:
====================
From the error messages in the Problem entry, it is obvious that IMP is trying
to create the tables with the same clustered nature as it was at export time.
The IGNORE=y option first checks the table definition before proceeding with
the import of table data. However, since the original tables are clustered
while the precreated tables are not, the table definition check fails with the
errors in question, and thus IMP aborts its operation.

Thus,

SQL> create cluster javier_cluster (n number, c char(1));

Cluster created.

SQL> !imp javier/javi tables=clu_table1, clu_table2 file=jseen/clu.dmp ignore=y

Import: Release 7.0.15.4.0 - Production on Mon Aug 29 13:35:57 1994

Copyright (c) Oracle Corporation 1979, 1992. All rights reserved.


Connected to: ORACLE7 Server Release 7.0.15.4.0 - Production
With the procedural and distributed options
PL/SQL Release 2.0.17.1.0 - Production

Export file created by EXPORT:V07.00.15
. importing JAVIER's objects into JAVIER
. . importing table "CLU_TABLE1" 2 rows imported
. . importing table "CLU_TABLE2" 0 rows imported
Import terminated successfully without warnings.
Posted by 睡貓 at 2008年07月9日 11:26