主库做一些DML操作,提交,并切换日志处罚ARCH归档日志
-
17:36:32 SYS @ slow >create table t2 as select * from scott.emp;
-
-
Table created.
-
-
Elapsed: 00:00:00.10
-
17:38:43 SYS @ slow >commit;
-
-
Commit complete.
-
-
Elapsed: 00:00:00.00
-
17:38:47 SYS @ slow >alter system switch logfile;
-
-
System altered.
-
-
Elapsed: 00:00:00.01
-
17:38:58 SYS @ slow >
查看备库的告警日志,是否接收到日志,此时已处罚RFS(remote file server)故主备连接没有问题
-
RFS[1]: Assigned to RFS process 4339
-
RFS[1]: Selected log 4 for thread 1 sequence 16 dbid 1147482511 branch 963616975
-
Fri Jan 12 17:33:36 2018
-
RFS[2]: Assigned to RFS process 4335
-
RFS[2]: Opened log for thread 1 sequence 10 dbid 1147482511 branch 963616975
-
Archived Log entry 1 added for thread 1 sequence 10 rlc 963616975 ID 0x4465718f dest 2:
-
RFS[1]: Opened log for thread 1 sequence 12 dbid 1147482511 branch 963616975
-
RFS[2]: Opened log for thread 1 sequence 13 dbid 1147482511 branch 963616975
-
Fri Jan 12 17:33:36 2018
-
Archived Log entry 2 added for thread 1 sequence 16 ID 0x4465718f dest 1:
-
Fri Jan 12 17:33:36 2018
-
RFS[3]: Assigned to RFS process 4343
-
RFS[3]: Opened log for thread 1 sequence 11 dbid 1147482511 branch 963616975
-
Archived Log entry 3 added for thread 1 sequence 13 rlc 963616975 ID 0x4465718f dest 2:
-
RFS[2]: Opened log for thread 1 sequence 14 dbid 1147482511 branch 963616975
-
Archived Log entry 4 added for thread 1 sequence 14 rlc 963616975 ID 0x4465718f dest 2:
-
RFS[2]: Opened log for thread 1 sequence 15 dbid 1147482511 branch 963616975
-
Archived Log entry 5 added for thread 1 sequence 15 rlc 963616975 ID 0x4465718f dest 2:
-
Archived Log entry 6 added for thread 1 sequence 11 rlc 963616975 ID 0x4465718f dest 2:
我上一次搭建DG的时候主库是startup pfile=xxxx 所以隔天我来做主备互换的时候是startup,主备无法连接,折
腾一下午终于找出原因了,通过以上的一些验证证明没有问题之后我们继续下面的操作
-
17:42:10 SYS @ gotime >r
-
1* alter database convert to snapshot standby
-
-
Database altered.
-
-
Elapsed: 00:00:02.37
-
Created guaranteed restore point SNAPSHOT_STANDBY_REQUIRED_01/12/2018 17:42:11
-
Killing 4 processes with pids 4406,4385,4389,4393 (all RFS) in order to disallow current and futions. Requested by OS process 3844
-
Begin: Standby Redo Logfile archival
-
End: Standby Redo Logfile archival
-
RESETLOGS after incomplete recovery UNTIL CHANGE 336029
-
Resetting resetlogs activation ID 1147498895 (0x4465718f)
-
Online log /u01/app/oracle/oradata/gotime/redo01a.log: Thread 1 Group 1 was previously cleared
-
Online log /u01/app/oracle/oradata/gotime/redo01b.log: Thread 1 Group 1 was previously cleared
-
Online log /u01/app/oracle/oradata/gotime/redo02a.log: Thread 1 Group 2 was previously cleared
-
Online log /u01/app/oracle/oradata/gotime/redo02b.log: Thread 1 Group 2 was previously cleared
-
Online log /u01/app/oracle/oradata/gotime/redo03a.log: Thread 1 Group 3 was previously cleared
-
Online log /u01/app/oracle/oradata/gotime/redo03b.log: Thread 1 Group 3 was previously cleared
-
Standby became primary SCN: 336027
-
Fri Jan 12 17:42:13 2018
-
Setting recovery target incarnation to 2
-
CONVERT TO SNAPSHOT STANDBY: Complete - Database mounted as snapshot standby
-
Completed: alter database convert to snapshot standby
-
Fri Jan 12 17:43:05 2018
-
ARC1: Becoming the 'no SRL' ARCH
此时备库的 状态是mounted,我们下面可以将他转换成open read write 状态了
-
17:56:17 SYS @ gotime >select status from v$instance;
-
-
STATUS
-
------------
-
MOUNTED
-
-
1 row selected.
-
-
Elapsed: 00:00:00.00
现在可以以read write的方式打开备库了!!!因为转换成功了
-
17:56:25 SYS @ gotime >alter database open read write;
-
-
Database altered.
-
-
Elapsed: 00:00:01.01
-
17:58:12 SYS @ gotime >
查看转换后的database_role是snapshot standby !!!
-
18:00:55 SYS @ gotime >select name,database_role,protection_mode,open_mode fromv$database;
-
-
NAME DATABASE_ROLE PROTECTION_MODE OPEN_MODE
-
--------- ---------------- -------------------- --------------------
-
SLOW SNAPSHOT STANDBY MAXIMUM PERFORMANCE READ WRITE
-
-
1 row selected.
-
-
Elapsed: 00:00:00.01
-
18:02:03 SYS @ gotime >
做一些DML操作,提交,好等备库回到snapshot DB之前做对比
-
18:00:30 SYS @ gotime >r
-
1* create table t2018 as select * from scott.emp
-
-
Table created.
-
-
Elapsed: 00:00:00.04
-
18:00:30 SYS @ gotime >select * from t2018;
-
-
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
-
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
-
7369 SMITH CLERK 7902 17-DEC-80 800 20
-
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
-
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
-
7566 JONES MANAGER 7839 02-APR-81 2975 20
-
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
-
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
-
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
-
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
-
7839 KING PRESIDENT 17-NOV-81 5000 10
-
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
-
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
-
-
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
-
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
-
7900 JAMES CLERK 7698 03-DEC-81 950 30
-
7902 FORD ANALYST 7566 03-DEC-81 3000 20
-
7934 MILLER CLERK 7782 23-JAN-82 1300 10
-
-
14 rows selected.
-
-
Elapsed: 00:00:00.00
-
18:00:42 SYS @ gotime >commit;
-
-
Commit complete.
-
-
Elapsed: 00:00:00.00
-
18:00:55 SYS @ gotime >
这时候刚才创建的standby redo log被使用了
-
18:02:03 SYS @ gotime >select group#,thread#,sequence#,archived,status from v$standby_log;
-
-
GROUP# THREAD# SEQUENCE# ARC STATUS
-
---------- ---------- ---------- --- ----------
-
4 1 22 YES ACTIVE
-
5 1 0 NO UNASSIGNED
-
6 0 0 YES UNASSIGNED
-
7 0 0 YES UNASSIGNED
-
-
4 rows selected.
-
-
Elapsed: 00:00:00.00
-
18:03:39 SYS @ gotime >
主库做一些DML操作,提交,好等备库回到snapshot DB之前做对比
-
17:38:58 SYS @ slow >create table t2017 as select * from scott.dept;
-
-
Table created.
-
-
Elapsed: 00:00:00.06
-
18:08:04 SYS @ slow >select * from t2017;
-
-
DEPTNO DNAME LOC
-
---------- -------------- -------------
-
10 ACCOUNTING NEW YORK
-
20 RESEARCH DALLAS
-
30 SALES CHICAGO
-
40 OPERATIONS BOSTON
-
-
4 rows selected.
-
-
Elapsed: 00:00:00.01
-
18:08:13 SYS @ slow >commit;
-
-
Commit complete.
-
-
Elapsed: 00:00:00.00
-
18:08:19 SYS @ slow >alter system switch logfile;
-
-
System altered.
-
-
Elapsed: 00:00:00.01
-
18:10:28 SYS @ slow >
关闭备库,重新启动到mounted然后转换回physical standby DB
-
18:11:34 SYS @ gotime >shutdown immediate;
-
Database closed.
-
Database dismounted.
-
ORACLE instance shut down.
-
18:12:42 SYS @ gotime >startup mount;
-
ORACLE instance started.
-
-
Total System Global Area 521936896 bytes
-
Fixed Size 2254824 bytes
-
Variable Size 377489432 bytes
-
Database Buffers 138412032 bytes
-
Redo Buffers 3780608 bytes
-
Database mounted.
-
18:12:57 SYS @ gotime >alter database convert to physical standby;
-
-
Database altered.
-
-
Elapsed: 00:00:02.23
-
18:13:18 SYS @ gotime >
转换回physical standby DB告警日志的情况
-
alter database convert to physical standby
-
ALTER DATABASE CONVERT TO PHYSICAL STANDBY (gotime)
-
Killing 3 processes with pids 4994,4998,5002 (all RFS) in order to disallow current and future RFS connections. Requested by OS process 4988
-
Flashback Restore Start
-
Flashback Restore Complete
-
Drop guaranteed restore point
-
Stopping background process RVWR
-
Deleted Oracle managed file/dsk1/gotime_recover/GOTIME/flashback/o1_mf_f5k0qmlb_.flb
-
Deleted Oracle managed file/dsk1/gotime_recover/GOTIME/flashback/o1_mf_f5k0qoco_.flb
-
Guaranteed restore point dropped
-
Clearing standby activation ID 1149107987 (0x447dff13)
-
The primary database controlfile was created using the
-
'MAXLOGFILES 10' clause.
-
There is space for up to 7 standby redo logfiles
-
Use the following SQL commands on the standby database to create
-
standby redo logfiles that match the primary database:
-
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 104857600;
-
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 104857600;
-
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 104857600;
-
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 104857600;
-
Shutting down archive processes
-
Archiving is disabled
-
Fri Jan 12 18:13:17 2018
-
ARCH shutting down
-
ARC3: Archival stopped
-
Fri Jan 12 18:13:17 2018
-
ARCH shutting down
-
ARC2: Archival stopped
-
Fri Jan 12 18:13:17 2018
-
ARCH shutting down
-
ARC1: Archival stopped
-
Fri Jan 12 18:13:17 2018
-
ARCH shutting down
-
ARC0: Archival stopped
-
Completed: alter database convert to physical standby
-
18:13:18 SYS @ gotime >select name,database_role,protection_mode,open_mode fromv$database; select name,database_role,protection_mode,open_mode from v$database
-
*
-
ERROR at line 1:
-
ORA-01507: database not mounted
-
-
-
Elapsed: 00:00:00.01
-
18:15:42 SYS @ gotime >select name,database_role,protection_mode,open_mode fromv$database;
-
select name,database_role,protection_mode,open_mode from v$database
-
*
-
ERROR at line 1:
-
ORA-01507: database not mounted
-
-
-
Elapsed: 00:00:00.00
-
18:15:51 SYS @ gotime >recover managed standby database disconnect;
-
ORA-01507: database not mounted
-
-
-
18:16:37 SYS @ gotime >select status from v$instance;
-
-
STATUS
-
------------
-
STARTED
-
-
1 row selected.
-
-
Elapsed: 00:00:00.01
-
18:17:00 SYS @ gotime >alter database mount;
-
alter database mount
-
*
-
ERROR at line 1:
-
ORA-00750: database has been previously mounted and dismounted
-
-
-
Elapsed: 00:00:00.00
-
18:17:13 SYS @ gotime >startup mount;
-
ORA-01081: cannot start already-running ORACLE - shut it down first
-
18:17:26 SYS @ gotime >shutdown immediate;
-
ORA-01507: database not mounted
-
-
-
ORACLE instance shut down.
-
18:18:58 SYS @ gotime >startup mount;
-
ORACLE instance started.
-
-
Total System Global Area 521936896 bytes
-
Fixed Size 2254824 bytes
-
Variable Size 377489432 bytes
-
Database Buffers 138412032 bytes
-
Redo Buffers 3780608 bytes
-
Database mounted.
-
18:19:10 SYS @ gotime >select name,database_role,protection_mode,open_mode fromv$database;
-
-
NAME DATABASE_ROLE PROTECTION_MODE OPEN_MODE
-
--------- ---------------- -------------------- --------------------
-
SLOW PHYSICAL STANDBY MAXIMUM PERFORMANCE MOUNTED
-
-
1 row selected.
-
-
Elapsed: 00:00:00.02
-
18:19:17 SYS @ gotime >
重新恢复到physical DB之后,对积压的主库传过来的日志进行media recover 应用
-
18:19:17 SYS @ gotime >recover managed standby database disconnect;
-
Media recovery complete.
-
MRP0 started with pid=27, OS id=5221
-
MRP0: Background Managed Standby Recovery process started (gotime)
-
Serial Media Recovery started
-
Managed Standby Recovery not using Real Time Apply
-
Waiting for all non-current ORLs to be archived...
-
All non-current ORLs have been archived.
-
Clearing online redo logfile 1 /u01/app/oracle/oradata/gotime/redo01a.log
-
Clearing online log 1 of thread 1 sequence number 25
-
Completed: ALTER DATABASE RECOVER managed standby database disconnect
-
Clearing online redo logfile 1 complete
-
Clearing online redo logfile 2 /u01/app/oracle/oradata/gotime/redo02a.log
-
Clearing online log 2 of thread 1 sequence number 2
-
Clearing online redo logfile 2 complete
-
Clearing online redo logfile 3 /u01/app/oracle/oradata/gotime/redo03a.log
-
Clearing online log 3 of thread 1 sequence number 24
-
Fri Jan 12 18:21:56 2018
-
Clearing online redo logfile 3 complete
-
Media Recovery Log /dsk1/arch_gotime/1_21_963616975.arc
-
Media Recovery Log /dsk1/arch_gotime/1_22_963616975.arc
-
Media Recovery Log /dsk1/arch_gotime/1_23_963616975.arc
-
Media Recovery Log /dsk1/arch_gotime/1_24_963616975.arc
-
Media Recovery Waiting for thread 1 sequence 25 (in transit)
以只读的方式打开数据库,此时备库snapshot DB期间主库所做的操作都应用到备库了
-
18:21:51 SYS @ gotime >alter database open;
-
alter database open
-
*
-
ERROR at line 1:
-
ORA-10456: cannot open standby database; media recovery session may be in progress
-
-
-
Elapsed: 00:00:00.00
-
18:24:11 SYS @ gotime >recover managed standby database cancel;
-
Media recovery complete.
-
18:24:34 SYS @ gotime >alter database open ;
-
-
Database altered.
-
-
Elapsed: 00:00:00.28
-
18:24:41 SYS @ gotime >select name,database_role,protection_mode,open_mode fromv$database;
-
-
NAME DATABASE_ROLE PROTECTION_MODE OPEN_MODE
-
--------- ---------------- -------------------- --------------------
-
SLOW PHYSICAL STANDBY MAXIMUM PERFORMANCE READ ONLY
-
-
1 row selected.
-
-
Elapsed: 00:00:00.01
-
18:25:15 SYS @ gotime >
在备库上对比查询,t2017(主库DML)存在,t2018(备库DML)消失,snapshot DB转换成功!!!
-
18:25:15 SYS @ gotime >select * from t2017;
-
-
DEPTNO DNAME LOC
-
---------- -------------- -------------
-
10 ACCOUNTING NEW YORK
-
20 RESEARCH DALLAS
-
30 SALES CHICAGO
-
40 OPERATIONS BOSTON
-
-
4 rows selected.
-
-
Elapsed: 00:00:00.01
-
18:26:51 SYS @ gotime >select * from t2018;
-
select * from t2018
-
*
-
ERROR at line 1:
-
ORA-00942: table or view does not exist
-
-
-
Elapsed: 00:00:00.00
-
18:27:01 SYS @ gotime >
2017悄然逝去已成历史,我们无法改变,2018还像一张白纸,等我们认真填写,我那时候站在2019回望2018又会不会呆着遗憾呢,期待2018。。。
我做的所有改变只为我心中不变,应对变化的只有改变
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31405474/viewspace-2150108/
,如需转载,请注明出处,否则将追究法律责任。