Oracle 10g 物理DataGuard擴充套件表空間

lpwebnet發表於2014-02-08

我的<>,歡迎觀看:

Oracle 10g 物理DataGuard擴充套件表空間

關於物理DG的擴充套件表空間,首先要看備庫端的引數standby_file_management,該引數可以設定為手動管理(MANUAL)和自動管理(AUTO).通常該引數配置為AUTO,在自動管理模式下,當表空間大小在主庫端變更時(不論是alter tablespace add datafile還是alter database datafile *** resize),備庫能夠自動偵測並調整大小,不需要手動干預。以下是物理dataguard擴充套件表空間的例子:

oracle 10.2.0.1,linux上的物理DG,首先standby處於日誌接受模式:

SQL> select instance_name ,status from v$instance;

INSTANCE_NAME                    STATUS
 -------------------------------- ------------------------
 orcl                             MOUNTED

SQL>



在主庫端檢視歸檔日誌序號:

SQL>  select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
 --------------
           5593

SQL>



在備庫端檢視日誌應用序號:

select sequence#,applied from v$archived_log;

      5583 YES
       5584 YES

SEQUENCE# APPLIE
 ---------- ------
       5585 YES
       5586 YES
       5587 YES
       5588 YES
       5589 YES
       5590 YES
       5591 YES
       5592 YES
       5593 YES

2528 rows selected.

SQL>



日誌應用正常。



在主庫端檢視錶空間使用率如下:

SQL> select t.tablespace_name,t.total "總大小(M)",t.total-f.free "已使用(M)",f.free "剩餘容量(M)",
 (t.total-f.free)/t.total*100 "使用率%" from
 (select tablespace_name,sum(bytes)/1024/1024 total
   2    3    4  from dba_data_files group by tablespace_name) t,
   5  (select tablespace_name,sum(bytes)/1024/1024  free
   6  from dba_free_space group by tablespace_name) f
   7  where t.tablespace_name=f.tablespace_name(+)
   8  ;

TABLESPACE_NAME      總大尣?M) 已使産?M) 剩餘容量(M) 使用玣?
-------------------- ------------ ------------ --------------- ----------
APPS_DATA                    7524     794.6875       6729.3125 10.5620348
 HALFENTERSEND                1024      59.1875        964.8125  5.7800293
 UNDOTBS1                    10240      78.5625      10161.4375 .767211914
 SYSAUX                        570      528.375          41.625 92.6973684
 BSKILL                       1024     183.0625        840.9375 17.8771973
 HALFENTER                    3118    2044.5625       1073.4375 65.5728833
 USERS                       872.5         64.5             808 7.39255014
DEVELOPE                    11754       2056.5          9697.5 17.4961715
 STATE_DATA                   3072    2157.8125        914.1875 70.2412923
 SYSTEM                        960     582.9375        377.0625 60.7226563
 SKILLS_DATA                 13568   12982.4375        585.5625 95.6842386

TABLESPACE_NAME      總大尣?M) 已使産?M) 剩餘容量(M) 使用玣?
-------------------- ------------ ------------ --------------- ----------
MAILCHECK_WORK                256      48.0625        207.9375 18.7744141
 IMPORTUSER                   1024     799.1875        224.8125 78.0456543
 PUBCODE_DATA                  512      253.875         258.125 49.5849609
EMAIL_WORK                  11744    9579.0625       2164.9375 81.5655867
 EMPLY                        1024     863.1875        160.8125 84.2956543
 EMPLYSEND                    1024      11.1875       1012.8125  1.0925293

17 rows selected.

SQL>



這裡SKILLS_DATA表空間13568M,使用率達到了95.6842386%。



在備庫端查詢:

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open read only;

Database altered.

SQL>



SQL> select t.tablespace_name,t.total "總大小(M)",t.total-f.free "已使用(M)",f.free "剩餘容量(M)",
   2  (t.total-f.free)/t.total*100 "使用率%" from
   3  (select tablespace_name,sum(bytes)/1024/1024 total
   4  from dba_data_files group by tablespace_name) t,
   5  (select tablespace_name,sum(bytes)/1024/1024  free
   6  from dba_free_space group by tablespace_name) f
   7  where t.tablespace_name=f.tablespace_name(+)
   8  ;

TABLESPACE_NAME      總大尣?M) 已使産?M) 剩餘容量(M) 使用玣?
-------------------- ------------ ------------ --------------- ----------
APPS_DATA                    7524     794.6875       6729.3125 10.5620348
 HALFENTERSEND                1024      59.1875        964.8125  5.7800293
 UNDOTBS1                    10240      78.5625      10161.4375 .767211914
 SYSAUX                        570      528.375          41.625 92.6973684
 BSKILL                       1024     183.0625        840.9375 17.8771973
HALFENTER                    3118    2044.5625       1073.4375 65.5728833
 USERS                       872.5         64.5             808 7.39255014
 DEVELOPE                    11754       2056.5          9697.5 17.4961715
 STATE_DATA                   3072    2157.8125        914.1875 70.2412923
 SYSTEM                        960     582.9375        377.0625 60.7226563
 SKILLS_DATA                 13568   12982.4375        585.5625 95.6842386

TABLESPACE_NAME      總大尣?M) 已使産?M) 剩餘容量(M) 使用玣?
-------------------- ------------ ------------ --------------- ----------
MAILCHECK_WORK                256      48.0625        207.9375 18.7744141
IMPORTUSER                   1024     799.1875        224.8125 78.0456543
 PUBCODE_DATA                  512      253.875         258.125 49.5849609
 EMAIL_WORK                  11744    9579.0625       2164.9375 81.5655867
 EMPLY                        1024     863.1875        160.8125 84.2956543
 EMPLYSEND                    1024      11.1875       1012.8125  1.0925293

17 rows selected.

SQL>



也是完全一致的。



我的環境裡,SKILLS_DATA表空間有兩個資料檔案,但是在主庫端和備庫端的目錄不同:

primary:

SQL>  select file_name from dba_data_files where tablespace_name='SKILLS_DATA';

FILE_NAME
 --------------------------------------------------------------------------------
 /u01/oracle/oradata/research/skills_data.dbf
 /u01/oracle/oradata/research/skills_data01.dbf



standby:

SQL>  select file_name from dba_data_files where tablespace_name='SKILLS_DATA';

FILE_NAME
 --------------------------------------------------------------------------------
 /opt/oracle/oradata/research/skills_data.dbf
 /opt/oracle/oradata/research/skills_data01.dbf



將備庫切換回日誌接收模式:

SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL>



在primary:


 SQL> alter tablespace SKILLS_DATA add datafile '/u01/oracle/oradata/research/skills_data02' size 8G;



primary:

SQL> select file_name from dba_data_files where tablespace_name='SKILLS_DATA';

FILE_NAME
 --------------------------------------------------------------------------------
 /u01/oracle/oradata/research/skills_data.dbf
 /u01/oracle/oradata/research/skills_data01.dbf
 /u01/oracle/oradata/research/skills_data02

SQL> select t.tablespace_name,t.total "總大小(M)",t.total-f.free "已使用(M)",f.free "剩餘容量(M)",
   2  (t.total-f.free)/t.total*100 "使用率%" from
   3  (select tablespace_name,sum(bytes)/1024/1024 total
   4  from dba_data_files group by tablespace_name) t,
   5  (select tablespace_name,sum(bytes)/1024/1024  free
   6  from dba_free_space group by tablespace_name) f
   7  where t.tablespace_name=f.tablespace_name(+)
   8  ;

TABLESPACE_NAME      總大尣?M) 已使産?M) 剩餘容量(M) 使用玣?
-------------------- ------------ ------------ --------------- ----------
APPS_DATA                    7524     794.6875       6729.3125 10.5620348
 HALFENTERSEND                1024      59.1875        964.8125  5.7800293
 UNDOTBS1                    10240      79.5625      10160.4375 .776977539
 SYSAUX                        570      528.375          41.625 92.6973684
 BSKILL                       1024     183.0625        840.9375 17.8771973
 HALFENTER                    3118    2044.5625       1073.4375 65.5728833
 USERS                       872.5         64.5             808 7.39255014
 DEVELOPE                    11754       2056.5          9697.5 17.4961715
 STATE_DATA                   3072    2157.8125        914.1875 70.2412923
 SYSTEM                        960     582.9375        377.0625 60.7226563
 SKILLS_DATA                 21760      12982.5          8777.5 59.6622243

TABLESPACE_NAME      總大尣?M) 已使産?M) 剩餘容量(M) 使用玣?
-------------------- ------------ ------------ --------------- ----------
MAILCHECK_WORK                256      48.0625        207.9375 18.7744141
 IMPORTUSER                   1024     799.1875        224.8125 78.0456543
 PUBCODE_DATA                  512      253.875         258.125 49.5849609
 EMAIL_WORK                  11744    9579.0625       2164.9375 81.5655867
 EMPLY                        1024     863.1875        160.8125 84.2956543
 EMPLYSEND                    1024      11.1875       1012.8125  1.0925293

17 rows selected.

SQL>



standby:

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter datbase open read only;
 alter datbase open read only
       *
 ERROR at line 1:
 ORA-00940: invalid ALTER command


 SQL> alter database open read only;

Database altered.

SQL>



standby:

SQL> select file_name from dba_data_files where tablespace_name='SKILLS_DATA';

FILE_NAME
 --------------------------------------------------------------------------------
 /opt/oracle/oradata/research/skills_data.dbf
 /opt/oracle/oradata/research/skills_data01.dbf

SQL>



standby 切回日誌接收模式:




primary:

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL>



primary 查詢:


SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
 --------------
           5598

SQL>



standby端切換到open read only狀態,然後再次查詢:

standby查詢:

     5588 YES
       5589 YES

SEQUENCE# APPLIE
 ---------- ------
       5590 YES
       5591 YES
       5592 YES
       5593 YES
       5594 YES
       5595 YES
       5596 YES
       5597 YES
       5598 YES

2528 rows selected.

SQL>



然後在standby端查詢:

SQL> select file_name from dba_data_files where tablespace_name='SKILLS_DATA';

FILE_NAME
 --------------------------------------------------------------------------------
 /opt/oracle/oradata/research/skills_data.dbf
 /opt/oracle/oradata/research/skills_data01.dbf
 /u01/oracle/oradata/research/skills_data02

SQL>



我們可以看到,standby已經同步看到了新加的資料檔案。

以上是standby_file_management為AUTO的方式,另外,如果資料檔案在裸裝置下面,一定要先在主庫端和備庫端都建立好裸裝置,尤其是備庫端,不然備庫端無法找到相應的裸裝置就會出問題。如果不是AUTO而是MANUAL,則需要手動的在主庫和備庫端同時修改。

我的<>,歡迎觀看:

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17172228/viewspace-1077956/,如需轉載,請註明出處,否則將追究法律責任。

相關文章