oracle11g 读写,oracle11g pysical standby开启临时读写
1、確定和檢查相關信息
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE??? OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED
數據庫處于mount狀態下,是物理standby
檢查當前模式是否在閃回的條件下
SQL> show parameter db_recovery_file_dest;
NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest??????????????? string
db_recovery_file_dest_size?????????? big integer 0
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
通過檢查,standby閃回沒有開啟,在進行切換時需要開啟閃回
2、對standby數據庫進行操作
--取消日志在standby端的應用
SQL> alter database recover managed standby database cancel;
Database altered.
--設置閃回區域和閃回大小
SQL> alter system set db_recovery_file_dest_size = 40g;
System altered.
SQL> alter system set db_recovery_file_dest = '/u01/db_recover';
System altered.
另外,創建閃回目錄
mkdir /u01/db_recover
chown -R oracle:oinstall /u01/db_recover
--切換到snap database狀態
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 8551575552 bytes
Fixed Size????????????????? 2270360 bytes
Variable Size??????????? 2147486568 bytes
Database Buffers???????? 6392119296 bytes
Redo Buffers??????????????? 9699328 bytes
Database mounted.
SQL> alter database convert to snapshot standby;
Database altered.
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE??? OPEN_MODE
---------------- --------------------
SNAPSHOT STANDBY MOUNTED
--打開數據庫
SQL> alter database open;
Database altered.
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE??? OPEN_MODE
---------------- --------------------
SNAPSHOT STANDBY READ WRITE
可以看到數據庫已經處理可讀寫的狀態了
4、對snap database進行讀寫測試
--切換日志
SQL> alter system switch logfile;
System altered.
--建表測試
SQL> create table mytest as select * from dba_tables;
Table created.
SQL> create table mytest1 as select * from dba_tables;
Table created.
SQL> select count(*) from dba_tables;
COUNT(*)
----------
4622
SQL> drop table mytest purge;
Table dropped.
5、測試完成后,還原到physical standby
--關閉數據庫并切換到mount狀態
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 8551575552 bytes
Fixed Size????????????????? 2270360 bytes
Variable Size??????????? 2147486568 bytes
Database Buffers???????? 6392119296 bytes
Redo Buffers??????????????? 9699328 bytes
Database mounted.
--切換到physical standby狀態
SQL> alter database convert to physical standby;
Database altered.
--關閉閃回
SQL> alter database flashback off;
Database altered.
--重新開啟數據庫physical standby模式
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 8551575552 bytes
Fixed Size????????????????? 2270360 bytes
Variable Size??????????? 2147486568 bytes
Database Buffers???????? 6392119296 bytes
Redo Buffers??????????????? 9699328 bytes
SQL> alter database mount standby database;
Database altered.
SQL> alter database open read only;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION NODELAY;
Database altered.
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE??? OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY
--檢查剛才的表
SQL> select count(*) from mytest1;
select count(*) from mytest1
*
ERROR at line 1:
ORA-00942: table or view does not exist
剛才創建的mytest1表已經不存在了
6、說明
需要注意的點:
--10g中創建的還原點必須在閃回后進行刪除,否則閃回恢復區可能會被撐滿,導致DB Hang住。11g中不用擔心這個問題,在重新轉換為physical standby時會自動進行還原點刪除。
--在進行轉換時,需要設置閃回區
--物理standby是最高保護模式(maximum protection),是不能轉換為snapshot standby的.
--物理standby使用了standby redo log,在create restore point后,要alter system switch logfile,以保證還原點的scn在物理standby庫上是歸檔的,不然可能無法成功閃回到還原點.
--物理standby在切換為快照standby后,如果間隔很長時間,primary數據庫產生的大量的重做日志,這樣可以在轉換為物理standby后,通過對primary數據庫的增量備份并recover到物理standby,來加快物理standby的還原速度。
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的oracle11g 读写,oracle11g pysical standby开启临时读写的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle 空间数据字段,Oracle
- 下一篇: 帝国cms php sql,帝国CMS下