oracle dataguard 重启步骤
oracle dataguard 重启步骤
场景,重启数据库,不重启linux系统,所以不用考虑监听程序,
#linux输入lsnrctl start
1 数据库关闭
1.1 关闭主库
SHUTDOWN IMMEDIATE;
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
instance shut down.
SQL>
1.2 关闭备库
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SHUTDOWN IMMEDIATE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
2 数据库启动,
开启的时候先开备库启动备库监听,再开主库
2.1 启动备库
#STARTUP MOUNT;
#ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
# ALTER DATABASE OPEN;
# 这里不用设置归档,归档设置一次是永久生效的,直接startup启动就行
STARTUP ;
SQL> STARTUP ;
ORACLE instance started.
Total System Global Area 5344731136 bytes
Fixed Size 2213136 bytes
Variable Size 3489663728 bytes
Database Buffers 1811939328 bytes
Redo Buffers 40914944 bytes
Database mounted.
Database opened.
SQL>
2.2 启动主库
STARTUP ;
SQL> STARTUP ;
ORACLE instance started.
Total System Global Area 1.1358E+10 bytes
Fixed Size 2216744 bytes
Variable Size 8589937880 bytes
Database Buffers 2751463424 bytes
Redo Buffers 13946880 bytes
Database mounted.
Database opened.
SQL>
/*取代下面的过程,数据库本来就是归档的,所以关闭之后再重启,数据库也是归档的
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;*/
2.3 启动备库应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
这个命令是死命令,会一直卡在这,但是后台其实归档日志已经在同步了,除非人为的关闭 否则 一直是这样的。
ALTER DATABASE OPEN; --备库不是必须处于OPEN状态,启动归档被应用即可,这个命令可以不用执行。
2.4 check,查看归档是否及时应用
先检查备库的归档日志同步情况
SQL> SELECT NAME,applied FROM v$archived_log;
......
NAME
--------------------------------------------------------------------------------
APPLIED
---------
/data/oracle/oradgdata/standby_archive/1_20866_821708334.dbf
YES
/data/oracle/oradgdata/standby_archive/1_20867_821708334.dbf
YES
/data/oracle/oradgdata/standby_archive/1_20868_821708334.dbf
YES
NAME
--------------------------------------------------------------------------------
APPLIED
---------
/data/oracle/oradgdata/standby_archive/1_20869_821708334.dbf
YES
2800 rows selected.
SQL>
如果发现全部都是YES,证明归档日志已经在同步。
在主库执行check:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracle/app/oracle/flash_recovery_area/archivelog
Oldest online log sequence 20869
Next log sequence to archive 20871
Current log sequence 20871
SQL>
在备库执行check
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data/oracle/oradgdata/standby_archive
Oldest online log sequence 20869
Next log sequence to archive 0
Current log sequence 20871
SQL>
看到主库备库当前的Current log sequence都是20871,备库上面最新的归档日志applied都是YES,就表明主库备库数据同步一致了。
dataguard重启算是彻底完成了。到这里强行关闭执行2.3的那个sql命令窗口。
下次再执行到2.3这一步骤,就可以在后面加上disconnect from session,就是执行完这个命令后断开这个回话,就是我们所能接受的,可以接着用这个连接执行其他命令了。