场景,重新启动数据库,不重新启动linux系统,所以不用考虑监听程序,
#linux输入lsnrctl start
1 数据库关闭
1.1 关闭主库
SHUTDOWN IMMEDIATE;
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE 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 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,就是运行完这个命令后断开这个回话,就是我们所能接受的,能够接着用这个连接运行其它命令了。
#linux输入lsnrctl start
1 数据库关闭
1.1 关闭主库
SHUTDOWN IMMEDIATE;
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE 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 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,就是运行完这个命令后断开这个回话,就是我们所能接受的,能够接着用这个连接运行其它命令了。