Oracle DBA的工作列表上寫了些什嗎?

來源:互聯網
上載者:User
資料庫管理員(DBA)的主要工作


啟動和關閉資料庫

一)     啟動資料庫
$ svrmgrl
SVRMGR> connect internal     (執行個體啟動)
SVRMGR> startup

二)     關閉資料庫
$ svrmgrl
SVRMGR> connect internal    
SVRMGR> shutdown [immediate/abort]
immediate:正在訪問資料庫的會話被完全終止、資源有序釋放後才關閉       資料庫。
abort: 會話立即中止,資料庫立即關閉。


備份與恢複

一)     邏輯備份與恢複(即卸庫與裝庫)
1.     卸庫:export
不帶參數:
$ cd $ORACLE_HOME/bin
$ exp

Username: cwadmin
Password:
Connected to: Oracle8 Enterprise Edition Release 8.0.4.0.0 - Production
PL/SQL Release 8.0.4.0.0 - Production
Enter array fetch buffer size: 4096 >
Export file: expdat.dmp > pzexdat.dmp

(1)     E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 1
    Export grants (yes/no): yes > y
    Export table data (yes/no): yes > y
    Compress extents (yes/no): yes >y
    export 工作開始自動進行最終出現:
    Export terminated successfully without warnings.
   

    帶參數,選擇性參數如下(可用exp help=y 得到):

    Keyword Description (Default)     Keyword     Description (Default)
---------------------------------------------------------------------------------------------------
USERID   username/password       FULL       export entire file (N)
BUFFER   size of data buffer       OWNER     list of owner usernames
FILE   output file (EXPDAT.DMP)   TABLES     list of table names
COMPRESS import into one extent (Y)   RECORDLENGTH length of IO record
GRANTS   export grants (Y)         INCTYPE     incremental export type
INDEXES export indexes (Y)       RECORD     track incr. export (Y)
ROWS   export data rows (Y)       PARFILE     parameter filename
CONSTRAINTS export constraints (Y)   CONSISTENT   cross-table consistency
LOG     log file of screen output   STATISTICS   analyze objects (ESTIMATE)
DIRECT   direct path (N)
FEEDBACK display progress every x rows (0)
POINT_IN_TIME_RECOVER   Tablespace Point-in-time Recovery (N)
RECOVERY_TABLESPACES   List of tablespace names to recover
VOLSIZE number of bytes to write to each tape volume

例:$exp userid=cwadmin/cwadmin tables=’(sys_cwxx,sys_menu)’ file=pzexport.dmp

2.     裝庫:

不帶參數
$ cd $ORACLE_HOME/bin
$ imp

Username: cwadmin
Password:
Connected to: Oracle8 Enterprise Edition Release 8.0.4.0.0 - Production
PL/SQL Release 8.0.4.0.0 - Production
Import file: expdat.dmp > pzexdat.dmp
Enter insert buffer size (minimum is 4096) 30720> 10240

Export file created by EXPORT:V08.00.04 via conventional path
List contents of import file only (yes/no): no >

Ignore create error due to object existence (yes/no): no > y
Import grants (yes/no):yes > y
Import table data (yes/no):yes >y
Import entire export file (yes/no):no >y
    import 工作開始自動進行最終出現:
    Import terminated successfully with warnings.

帶參數,選擇性參數如下(可用imp help=y 得到):

Keyword Description (Default)     Keyword     Description (Default)
---------------------------------------------------------------------------------------------------
USERID   username/password       FULL     import entire file (N)
BUFFER   size of data buffer       FROMUSER   list of owner usernames
FILE   input file (EXPDAT.DMP)   TOUSER     list of usernames
SHOW   just list file contents (N)   TABLES     list of table names
IGNORE   ignore create errors (N)   RECORDLENGTH   length of IO record
GRANTS   import grants (Y)       INCTYPE     incremental import type
INDEXES import indexes (Y)       COMMIT     commit array insert (N)
ROWS   import data rows (Y)     PARFILE     parameter filename
LOG     log file of screen output
DESTROY overwrite tablespace data file (N)
INDEXFILE write table/index info to specified file
CHARSET character set of export file (NLS_LANG)
POINT_IN_TIME_RECOVER Tablespace Point-in-time Recovery (N)
SKIP_UNUSABLE_INDEXES skip maintenance of unusable indexes (N)
ANALYZE execute ANALYZE statements in dump file (Y)
FEEDBACK display progress every x rows(0)
VOLSIZE number of bytes in file on each volume of a file on tape  

例:$imp userid=cwadmin/cwadmin tables=’(sys_dwxx, sys_menu)’ file=pzexdat.dmp

二)     物理備份與恢複
1.     冷備份與熱備份
冷備份
在資料庫關閉狀態與進行。將所有的資料檔案、重演記錄檔及控制檔案拷貝到磁碟。閒置時間再將備份移到磁帶上。
    (1)可通過:SVRMGR> select * from v$logfile;
              select * from v$dbfile;
              select * from v$control.file;
    這些語句來瞭解資料檔案、重演記錄檔及控制檔案的相應位置及名稱。
(2)利用$cp 命令來拷貝:
  例:$cp /u01/u02/pz_ts.ora /dbfile_b/

熱備份
資料庫必須工作在“ARCHIVELOG”方式下
可利用SVRMGR> archive log list 語句來查歸檔日誌狀態

  若在“NOARCHIVELOG”方式下,進行轉換
  SVRMGR> connect internal      
  SVRMGR> shutdown immediate     ---關閉資料庫---
  SVRMGR> startup mount   ---為暫停日誌方式轉換準備資料庫---
  SVRMGR> alter database archivelog; ---轉換---
  SVRMGR> alter database open;     ---開啟資料庫---
 
  拷貝
  1> 將一個資料表空間置為備份方式
    SVRMGR> alter tablespace pzts begin backup;
  2> 拷貝
    SVRMGR>$cp /u01/u02/pz_ts.ora /dbfile_b/
  3> 取消該表備份方式
      SVRMGR>alter tablespace pzts end backup;
  利用以上3步,將所有資料表空間下的資料檔案進行備份
  4> 拷貝控制檔案
  5> 拷貝歸檔重演日誌

2.     恢複
        磁碟出現故障,資料庫自行關閉。
(1)     將駐留在磁碟上的備份拷貝到其他磁碟或磁帶上
(2)     執行  
        SVRMGR> connect internal
        SVRMGR> startup mount
        SVRMGR> alter database open;
  會出現錯誤資訊,提示需要恢複
(3)     執行
            SVRMGR> recover database
        根據提示,自動回復
(4)     執行
            SVRMGR>alter database open
        恢複完成,資料庫開啟。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.