- SQL> select open_mode,log_mode,flashback_on,database_role from v$database;
- OPEN_MODE LOG_MODE FLASHBACK_ON DATABASE_ROLE
- -------------------- ------------ ------------------ ----------------
- READ ONLY WITH APPLY ARCHIVELOG YES PHYSICAL STANDBY
- SQL> show parameter db_recovery_file_dest
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- db_recovery_file_dest string /u01/app/oracle/fast_recovery_
- area
- db_recovery_file_dest_size big integer 4032M
3.开始切换
- #这里查看一下restore_point里面是否有记录
- SQL> select scn,name from v$restore_point;
- no rows selected
- SQL> recover managed standby database cancel;
- Media recovery complete.
- SQL> ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;
- Database altered.
- SQL> select open_mode,log_mode,flashback_on,database_role from v$database;
- OPEN_MODE LOG_MODE FLASHBACK_ON DATABASE_ROLE
- -------------------- ------------ ------------------ ----------------
- MOUNTED ARCHIVELOG YES SNAPSHOT STANDBY
- #这里使用convert to snapshot standby后,查询v$restore_point多了一条记录。
- #其实convert to snapshot standby就是利用的restore point这个功能。
- 所以在前面我们提到要配置FRA
- SQL> col name for a30
- SQL> set lines 100
- SQL> select scn,name, GUARANTEE_FLASHBACK_DATABASE from v$restore_point;
- SCN NAME GUA
- ---------- ------------------------------ ---
- 1122733 SNAPSHOT_STANDBY_REQUIRED_09/1 YES
- 0/2012 21:25:15
4.创建表测试
- SQL> shutdown immediate;
- ORA-01109: database not open
- Database dismounted.
- ORACLE instance shut down.
- SQL> startup
- ORACLE instance started.
- Total System Global Area 313159680 bytes
- Fixed Size 2226072 bytes
- Variable Size 255854696 bytes
- Database Buffers 50331648 bytes
- Redo Buffers 4747264 bytes
- Database mounted.
- Database opened.
- #查看database role是否是SNAPSHOT STANDBY
- SQL> select open_mode,log_mode,flashback_on,database_role from v$database;
- OPEN_MODE LOG_MODE FLASHBACK_ON DATABASE_ROLE
- -------------------- ------------ ------------------ ----------------
- READ WRITE ARCHIVELOG YES SNAPSHOT STANDBY
- SQL> show user;
- USER is "SYS"
- SQL> connect scott/oracle
- Connected.
- SQL> show user;
- USER is "SCOTT"
- SQL> select * from tab;
- TNAME TABTYPE CLUSTERID
- ------------------------------ ------- ----------
- BONUS TABLE
- DEPT TABLE
- EMP TABLE
- SALGRADE TABLE
- TEST1 TABLE
- #在scott用户下面创建一张test2表
- SQL> create table test2 as select * from emp;
- Table created.
- SQL> select count(*) from test2;
- COUNT(*)
- ----------
- 14
5.转换成physical standby并查看表是否存在
- SQL> conn / as sysdba
- Connected.
- SQL> shutdown abort;
- ORACLE instance shut down.
- SQL> startup mount;
- ORACLE instance started.
- Total System Global Area 313159680 bytes
- Fixed Size 2226072 bytes
- Variable Size 255854696 bytes
- Database Buffers 50331648 bytes
- Redo Buffers 4747264 bytes
- Database mounted.
- #这里切换成physical standby
- SQL> alter database convert to physical standby;
- Database altered.
- SQL> shutdown abort;
- ORACLE instance shut down.
- SQL> startup
- ORACLE instance started.
- Total System Global Area 313159680 bytes
- Fixed Size 2226072 bytes
- Variable Size 255854696 bytes
- Database Buffers 50331648 bytes
- Redo Buffers 4747264 bytes
- Database mounted.
- Database opened.
- SQL> select open_mode,log_mode,flashback_on,database_role from v$database;
- OPEN_MODE LOG_MODE FLASHBACK_ON DATABASE_ROLE
- -------------------- ------------ ------------------ ----------------
- READ ONLY ARCHIVELOG YES PHYSICAL STANDBY
- #这里提示表已经不存在了。说明已经成功。
- SQL> select count(*) from scott.test2;
- select count(*) from scott.test2
- *
- ERROR at line 1:
- ORA-00942: table or view does not exist
6.查询restore point是否还存在
- SQL> select scn,name from v$restore_point;
- no rows selected
这里restore point已经自动删除了。