Oracle 冷備份以及恢複——異機備份恢複

來源:互聯網
上載者:User

一、標記資料

使用scott使用者登入,並設定標記資料

SQL>select table_name from user_tables;

TABLE_NAME

------------------------------

DEPT

EMP

BONUS

SALGRADE

EMP_BAK

建立了emp表的一個備份表emp_bak。

二、備份資料庫

1 乾淨的關閉資料庫

SQL> shutdownimmediate

Databaseclosed.

Databasedismounted.

Oracle instance shut down.

2 將備份的資料打包

[oracle@study oracle]$ tar -zcvf admin.tar.gz admin/ &

[oracle@study oracle]$ tar -zcvf oradata.tar.gz oradata/ &

[oracle@study db_1]$ tar -zcvf dbs.tar.gz dbs/ &

3 記錄安裝目錄

[oracle@studyoracle]$ pwd

/u01/app/oracle

4 將備份的tar包儲存。

三、恢複

1 安裝資料庫軟體

2 建立同名資料庫

3 資料庫恢複

資料庫恢複之前,啟動資料庫,使用scott使用者登入。

SQL>startup

ORACLEinstance started.

TotalSystem Global Area  285212672 bytes

FixedSize                  1267068 bytes

VariableSize              92277380 bytes

DatabaseBuffers          188743680 bytes

RedoBuffers                2924544 bytes

Databasemounted.

Databaseopened.

SQL>

SQL>conn scott/scott

ERROR:

ORA-28000:the account is locked

Warning:You are no longer connected to ORACLE.

         Scott使用者無法正常登入,因為剛剛安裝的資料庫並沒有對scott使用者進行解鎖。現在乾淨的關閉資料庫。

SQL>shutdown immediate

Databaseclosed.

Databasedismounted.

ORACLE instance shut down.

         資料庫恢複

         將備份的打包資料解壓到相關目錄,主要涉及oradata,admin,dbs三個檔案夾。

[oracle@study oracle]$ mv oradata/ oradata_bak/

[oracle@study oracle]$ cp /home/oracle/oradata.tar.gz ./

[oracle@study oracle]$ tar -zxvf oradata.tar.gz &

 

[oracle@study oracle]$ mv admin/ admin_bak/

[oracle@study oracle]$ cp /home/oracle/admin.tar.gz ./

[oracle@study oracle]$ tar -zxvf admin.tar.gz &

         回複後,啟動資料庫。資料庫可以正常啟動,並且scott使用者可以正常登入,且可以正常查看標記資料。

SQL> conn / as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size                 1267068 bytes

Variable Size             92277380 bytes

Database Buffers         188743680 bytes

Redo Buffers               2924544 bytes

Database mounted.

Database opened.

SQL> conn scott/scott

Connected.

SQL> select table_name from user_tables;

 

TABLE_NAME

------------------------------

DEPT

EMP

BONUS

SALGRADE

EMP_BAK

四、總結

冷備份是最簡單的備份方式,但是也是恢複最快的方式。在工作中,冷備份也是會遇到的,這裡簡單的測試一下。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.