在Oracle中,RAC环境下“ALTER SYSTEM SWITCH LOGFILE;”与“ALTER SYSTEM ARCHIVE LOG CURRENT;”有什么区别?
♣ 答案部分
“ALTER SYSTEM SWITCH LOGFILE;”仅对当前发布节点上的对应Redo Thread进行日志切换并归档。“ALTER SYSTEM ARCHIVE LOG CURRENT;”对集群内所有节点实例上的Redo Thread进行切换并归档(在节点实例可用情况下,分别归档到各节点主机的归档目的地,当节点不可用时候,该线程日志归档到命令发布节点的归档目的地)。
当然,命令“ALTER SYSTEM ARCHIVE LOG CURRENT;”对单实例的数据库也是起作用的,使用这个命令还可以对RAC环境中的指定实例进行日志切换:
1alter system archive log instance 'lhrracdb2' current;
需要注意的是,命令“ALTER SYSTEM ARCHIVE LOG CURRENT;”对于非归档模式的数据库只能归档非当前Redo日志组,而对于归档模式的数据库则没有该限制,否则会报错:
1SYS@lhrrac11> ALTER SYSTEM ARCHIVE LOG CURRENT; 2ALTER SYSTEM ARCHIVE LOG CURRENT 3* 4ERROR at line 1: 5ORA-00258: manual archiving in NOARCHIVELOG mode must identify log 6 7SYS@lhrrac11> ALTER SYSTEM ARCHIVE LOG thread 1 sequence 14; 8 9System altered. 10 11SYS@lhrrac11> ALTER SYSTEM ARCHIVE LOG thread 1 sequence 15; 12ALTER SYSTEM ARCHIVE LOG thread 1 sequence 15 13* 14ERROR at line 1: 15ORA-00259: log 1 of open instance lhrrac11 (thread 1) is the current log, cannot archive 16 17SYS@lhrrac11> ALTER SYSTEM ARCHIVE LOG thread 2 sequence 13 ; 18 19System altered. 20 21SYS@lhrrac11> exit 22Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 23With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 24Data Mining and Real Application Testing options 25[oracle@raclhr-11gR2-N1 ~]$ oerr ora 258 2600258, 00000, "manual archiving in NOARCHIVELOG mode must identify log" 27// *Cause: The database is in NOARCHIVELOG mode and a command to manually 28// archive a log did not specify the log explicitly by sequence 29// number, group number or filename. 30// *Action: Specify log by filename, by group number or by thread and 31// sequence number.
最后提一下与日志相关的发出检查点操作的命令,在RAC数据库中也有所不同,以前的“alter system checkpoint;”与“alter system checkpoint global;”命令是等价的,将在所有数据库实例中触发检查点操作。如果想要在当前实例触发检查点,那么需要对命令稍作修改:
1alter system checkpoint local;