Oracle遷移資料檔案

來源:互聯網
上載者:User

標籤:arch   檔案的   pen   error   ica   data   sel   情境   system   

情境如下:

 

[[email protected] ~]# df -h 

Filesystem            容量  已用 可用 已用% 掛載點

/dev/sda2              28G   26G  585M  98% /

/dev/sda1             190M   12M  169M   7% /boot

none                  2.0G     0  2.0G   0% /dev/shm

/dev/sdb3              99G   93M   94G   1% /u02

 

  1. 根目錄滿了,

  2. /u02相對來說還有更大的空間,

  3. 現在要把根目錄佔用空間大的datafile,遷移到空間大的/u02上去

     

 

步驟如下:

1.  把資料檔案遷移到/u02對應的目錄

[[email protected] hsbop]$ mv /u01/app/oracle/oradata/orcl/acptdat.dbf  /u02/oradata/hsbop/acptdat.dbf

[[email protected] hsbop]$ mv /u01/app/oracle/oradata/orcl/acptidx.dbf /u02/oradata/hsbop/acptidx.dbf

[[email protected] hsbop]$ mv /u01/app/oracle/oradata/orcl/archdat.dbf /u02/oradata/hsbop/archdat.dbf

[[email protected] hsbop]$ mv /u01/app/oracle/oradata/orcl/archidx.dbf /u02/oradata/hsbop/archidx.dbf

 

2. 資料庫啟動到mount狀態

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  536870912 bytes

Fixed Size     1220408 bytes

Variable Size   171966664 bytes

Database Buffers   356515840 bytes

Redo Buffers     7168000 bytes

Database mounted.

 

3. 進行資料檔案的rename

SQL> alter database rename file ‘/u01/app/oracle/oradata/orcl/acptdat.dbf‘ to ‘/u02/oradata/hsbop/acptdat.dbf‘;

 

Database altered.

 

SQL> alter database rename file ‘/u01/app/oracle/oradata/orcl/acptidx.dbf‘ to ‘/u02/oradata/hsbop/acptidx.dbf‘;

 

Database altered.

 

SQL> alter database rename file ‘/u01/app/oracle/oradata/orcl/archdat.dbf‘ to ‘/u02/oradata/hsbop/archdat.dbf‘;

 

Database altered.

 

SQL> alter database rename file ‘/u01/app/oracle/oradata/orcl/archidx.dbf‘ to ‘/u02/oradata/hsbop/archidx.dbf‘;

 

Database altered.

 

4. 開啟資料庫

SQL> alter database open;

 

Database altered.

 

 

 

###### 如果mv的時候 xshell斷開了,又重新mv了一下,會導致資料檔案不完整,

###### 測試環境可以玩一下,通過把資料檔案構造到和控制檔案記錄的一致來騙過oracle,這個時候其實資料已經丟失了一部分

 

 

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01122: database file 19 failed verification check

ORA-01110: data file 19: ‘/u02/oradata/hsbop/ykhdat.dbf‘

ORA-01200: actual file size of 21087 is smaller than correct size of 64000

blocks

 

 

SQL> select 64000-21087 cnt from dual;

 

       CNT

----------

     42913

 

SQL> !dd if=/dev/zero of=/u02/oradata/hsbop/ykhdat.dbf bs=8192 count=42913 seek=21088

42913+0 records in

42913+0 records out

 

SQL> alter database open;

 

Database altered.

Oracle遷移資料檔案

聯繫我們

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