三. 一些其他操作
1. 首先檢視當前的保護模式 ---primary資料庫操作
SQL> select protection_mode,protection_level from v$database;
PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
2. 設定新的資料保護模式並重啟資料庫 --primary資料庫操作
當保護模式更改順序:
maximize protection ---> maximize availability ----> maximize performance
當在把dataguard的保護級別按這上面的順序減低的時候, 不需要primary庫在mount狀態,否則primary 必須在mount 狀態。
如:
SQL> alter database set standby database to maximize availability;
alter database set standby database to maximize availability
*
ERROR at line 1:
ORA-01126: database must be mounted in this instance and not open in any
instance
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 79694068 bytes
Database Buffers 83886080 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter database set standby database to maximize availability;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
報錯了,這是因為最大可用性需要先修改日誌傳送方式為lgwr同步方式,否則,資料庫是無法open.
Maximum protection/AVAILABILITY模式必須滿足以下條件
Redo Archival Process: LGWR
Network Tranmission mode: SYNC
Disk Write Option: AFFIRM
Standby Redo Logs: Yes
standby database type: Physical Only
SQL> alter system set log_archive_dest_2='service=orcl_st lgwr sync AFFIRM';
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 79694068 bytes
Database Buffers 83886080 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter database set standby database to maximize availability;
Database altered.
SQL> alter database open;
Database altered.
SQL> select protection_mode,protection_level from v$database;
PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY
alter database set standby database to maximize performance;
提示:maximize後可跟{PROTECTION | AVAILABILITY | PERFORMANCE},分別對應最大保護,最高可用性及最高效能。
在最大保護模式下,直接關閉備庫是不行的,如果在備庫上關閉資料庫,會有如下提示:
SQL> shutdown immediate
ORA-01154: database busy. Open, close, mount, and dismount not allowed now
SQL>
在最大保護模式下,備庫是不允許關閉的,此時首先關閉主庫,然後備庫就可以順利關閉了。
注意: 主庫的保護模式修改之後,備庫的模式也會改變,和主庫保持一致。
3. 檢視日誌歸檔情況
主庫進行日誌切換:
SQL>Alter system switch logfile;
select max(sequence#) from v$archived_log;
select max(sequence#) from v$log_history;
select group#,sequence#,archived,status from v$log;
select name,sequence#,applied from v$archived_log;
select sequence#,applied from v$archived_log;
若不同步,
1) 看log日誌, archive是否有丟失
2)可以在備庫坐如下操作:
alter database recover managed standby database cancel;
alter database recover managed standby database disconnect from session;