2007年11月6日

General Space Management Enhancements

1、SYSAUX tablespace:OverView
  • 角色是補助system tablespace,
  • 存在指令、函式庫的地方
  • 當新建database時,會順便產生
  • 跟system tablespace一樣具有一些特別的保護機治
    無法reamanent、read write、extent management local、segment space management auto、drop
  • 不支援 transportable tablespace
  • 如sysaux tablespace遺失、損壞將會讓一些oracle的功能失效

2、SYSAUX tablespace的好處
  • 減少tablespace的管理的數量: 在較舊的版本中,當新開起一些非預設的功能時,有時將會需要獨立的tablespace空間才行
    如XML DB(XDB)、OLAP等等,當數量一多時,將會照成 dba的負擔。所以在10g中,就把這些功能、函式庫都存在這sysaux tablespace裡。
  • 減少對system tablespace的存取:system tablespace對db而言是最重要的tablespace,當損壞時db將無法開起。為了保險起見,oracle把較常用的tools、 drsys、cwmilte、odm 等等的這些功能存放在sysaux tablespace裡,以免到時tablespace空間被用滿、datafile size無法自動延申這類的問題發生。
  • 減化RAC管理: 在RAC中,每個一tablespace都要最少指定一個raw device,為了減少dba進行相關的操作。(跟第一點的意思相同)

3、SYSAUX Occupants
在10g版本之前,每個功能對應的預設tablespace,而現在全放在sysaux tablespace 裡面
Occupant Original Tablespace
Text ,Ultra Search DRSYS
Intermedia ,spatial SYSTEM
Scheduler (new in 10g)
OLAP CWMLITE
XML DB XDB_RESINFO
Workspace Manager SYSTEM
Server Manageability Components (new in 10g)
Recovery catalog TOOLS
EM repository OEM_REPOSITORY
Analytical Workspace Object table SYSTEM
LogMiner,Log standby,Streams SYSTEM
Statspack User-specified

4、CREATE DATABASE
create database datafile '/u01/datafile/system.dbf' size 200M
sysaux datafile '/u01/datafile/sysaux.dbf' size 300m
default temporary tablespace stemp_tbs tempfile '/u01/datafile/stemp_tbs.dbf' size 60M
undo tablespace sundo_tbs datafile '/u01/datafile/sundo_tbs.dbf' size 100M;


5、alter tablespace sysaux
  • 你必需要有sysdba的權限
  • 可增加size、offline
    alter tablespace sysaux ADD datafile '/u01/datafile/sysaux2.dbf' size 200M;
    alter tablespace sysaux OFFLINE;

6、SYSAUX Occupants:Relocation
  • 查看裡面各別佔有的空間
    select occupant_name , space_usage_kbytes from v$sysaux_occupants;
  • 有些是無法搬移到別的tablespace (streams,smc,statsoace,ordim,ordim/pligins,ordim/sqlmm,efs,emmu,job_scheduler)
    select occupant_name , schema_name , move_procedure from v$sysaux_occupants;
  • 搬移的指令為
    EXEC  wksys.move_wk('new tablespace name ');

7、rename的流程
       
  • can rename undo 、temporary tablespaces
  • system、sysaux tablespace cannot be renamed
  • The tablespace to be renamed must have all its files ONLINE;
  • tablespace identifiers are not affected
  • data file header of READ ONLY tablespace are not changed: 因為oracle無法更新data file header裡的資料
  • 如果rename操作成功,spfile會自動更新相關資料
  • 如棌用OMF,預設tablespace name是會相同於file name,但這不是絕對的,只能拿來參考用的
  • 當你重建control file後,這時tablespace的資訊是來自於相對應的datafile裡的記錄
  • 要求的版本最少要為 10.0.0.0.0.

8、default Permanent Tablespace:Overview
  • system is the default permanent tablespace
    除了 sys、system、outln其他的使用者無法在system tablespace上面建立相關的object
  • 如是使用dbca建立database的話,會預設users tablespace為預設的 permanent tablespace
    設定為default permanent tablespace的話,將無法進行刪除
  • 10g以前預設是為system,這點是不好的,因為system tablespace是非常重要的,所以非相關的東西不應該存在上面
    所以10g就建議要設定一個非system  tablespace為default permanent tablespace
  • 方法1:
    create database
    datafile '/u01/datafile/system.dbf' szie 200M
    sysaux datafile '/u01/datafile/sysaux.dbf' size 300M
    default tablespace users datafile /u01/datafile/users.dbf' size 100m segment space management auto
    default temporary tablespace stemp_tbs tempfile '/u01/datafile/stemp_tbs.dbf' size 100M
    undo tablespace sundo_tbs datafile '/u01/datafile/sundo_tbs.dbf' size 100M;
  • 方法2:
    alter database default tablespace newusers;
  • 查現在使用的default permanent tablespace
    select property_value from database_properties where property_name = 'DEFAULT_PERMANENT_TABLESPACE';

9、Copy Files by Using the Database Server


  • Oracle 10g provides a PL/SQL interface for copying binary files and for transferring binary file between Oracle database.
  • 主要是讓dba可不必使用os命令或ftp傳送tablespace、data file
  • Local Copy:
    create directory source_dir as '/u01/oradata/oracl';
    create directory dest_dir as '/u01/copies';
    begin
      DBMS_FILE_TRANSFER.COPY_FILE(
          source_directory_object => 'SOURCE_DIR',
          source_file_name => 'example01.dbf',
          destination_directory_object => 'DEST_DIR',
          destination_file_name => 'example01_copy.dbf');
      END;
    /

  • Transferring File:
    create directory source_dir as '/u01/oradata/oracl';
    create directory dest_dir as '/u01/transfer';
    begin
      DBMS_FILE_TRANSFER.PUT_FILE(
         source_directory_object => 'source_dir',
         source_file_name => 'example01.dbf',
         destination_directory_object => 'dest_dir',
         destination_file_name => 'example01_t.dbf',
         destination_database => 'name.dblink.com');
       END;
    /
    ps:name.dblink.com 這需要先建立dblink,不然在傳送時會發生錯誤
  • 傳送的格式是2位元檔案
  • 檔案傳送是以512 bytes為一個傳送單位,最大單一檔案為 2 TB.
  • 來源地跟傳送地都可使用Automatic Storage Management
  • 在傳送的過程中可由 v$session_longops來查看相關的資訊

10、Redo Logfile Size Advisor
  • Fast_Start_MTTR_TARGET 如有設定的話,Redo logfile size Advisor才會生效
  • 可查看v$instance_recovery , column :OPTIMAL_LOGFILE_SIZE(單位為 Megabytes)

11、Dropping an Empty Data File
  • 可使用alter tablespace users drop datafile '/u01/oradata/oracle/userdrop.dbf'; 進行刪除空白的datafile,並且會自動
    更新 controlfile裡的資訊。當然了,你也可手動進行刪除,可由alter database offline/offline drop後,再自行刪除檔案
  • alter tablespace drop datafile使用限制為 database 必需要open
  • 可使用 alter tablespace drop tempfile 去刪除空的temporary data files.
  • drop datafile只能刪除非"第一個datafile",也不可用於刪除 bigfile tablespaces
  • 當datafile 是唯讀時也無法進執行 drop datafile.

Posted by my_work at 樂多Roodo! │23:20 │回應(1)引用(0)DB
樂多分類:網路/3C 共同主題:Oracle 工具:編輯本文
Ads by Roodo! 

引用URL

http://cgi.blog.roodo.com/trackback/4431779
回應文章

貓大寫的太好了!!
Posted by 初學者 at 2008年06月27日 14:59