题记:
生产RAC,闪回和归档必须配置,但是闪回功能基本上用不到所以可以考虑不启用,读者只需要了解其作用以及如何紧急处理因归档或者闪回空间快满或者已经满导致数据库crash的解决方法即可。
数据库的备份、恢复始终是重点,后续继续讨论。
开启归档步骤
1.查看当前数据库归档情况--未开启
SQL> select name,log_mode,flashback_on from gv$database;
NAME LOG_MODE FLASHBACK_ON
--------- ------------ ------------------
RAC NOARCHIVELOG NO
RAC NOARCHIVELOG NO
2.查看集群数据库是否状态-默认为共享
SQL> show parameter cluster;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
3.将归档置于ASM-ARCH,查看ASM是否存在
[grid@node1 u01]$ asmcmd lsdg
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 4096 1048576 2048 1953 0 1953 0 N ARCH/
MOUNTED NORMAL N 512 4096 1048576 3072 2146 1024 561 0 Y CRSVOTE/
MOUNTED EXTERN N 512 4096 1048576 4096 2042 0 2042 0 N DATA/
4.查看当前归档sequence号
nodeSQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence 5
Current log sequence 6
node2SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence 1
Current log sequence 2
5.将整库启动到mount状态
5.1 先关闭整库
[oracle@node1 ~]$ srvctl stop database -d rac
5.2 查看整库状态
[oracle@node1 ~]$ srvctl status database -d rac
Instance rac1 is not running on node node1
Instance rac2 is not running on node node2
5.3 将整库启动到mount状态
[oracle@node1 ~]$ srvctl start database -d rac -o mount
5.4 查看库是否为mount状态
SQL> select inst_id,status from gv$instance;
INST_ID STATUS
---------- ------------
1 MOUNTED
2 MOUNTED
6. 配置归档路径
SQL> alter system set log_archive_dest_1='LOCATION=+ARCH' sid='rac1' scope=spfile;
System altered.
SQL> alter system set log_archive_dest_1='LOCATION=+ARCH' sid='rac2' scope=spfile;
System altered.
--配置归档路径也可以用此命令 alter system set log_archive_dest_1='LOCATION=+ARCH' sid='*' scope=spfile;
7.关闭集群控制文件共享
SQL> alter system set cluster_database=false scope=spfile;
System altered.
cluster_database的说明:
这个参数的取值是TRUE和FALSE。对于所有实例,这个参数的取值应当设置为TRUE。TRUE值将指引实例在启动期间以共享模式挂载控制文件。
如果一个首先启动的实例将该参数设置为FALSE,那么它将能够以独占模式挂载控制文件。但是这样会禁止所有后台实例启动,如果试图去启动别的实例,
则会收到以下错误:
SQL> startup
ORA-01102: cannot mount database in EXCLUSIVE mode
在以下维护操作期间,必须使用cluster_database=FALSE启动实例:
从无存档日志模式转换为存档日志模式及反向转换。
启用闪回数据库功能。
升级期间。
对系统表空间执行介质恢复。
从Oracle RAC 数据库转换为单实例数据库及反向转换。
这个参数的默认值是FALSE,为了在Oracle RAC环境中启动实例,这个参数必须设置为TRUE。
8.关闭数据库
[oracle@node1 ~]$ srvctl stop database -d rac
9.启动数据库至mount状态
[oracle@node1 ~]$ srvctl start database -d rac -o mount
10. 确定当前实例为mount状态
SQL> select status,inst_id from gv$instance;
STATUSINST_ID
------------ ----------
MOUNTED 1
11. 开启归档
SQL> alter database archivelog;
Database altered.
12. 打开数据库
SQL> alter database open;
Database altered.
13. 打开集群控制文件共享
SQL> alter system set cluster_database=true scope=spfile;
System altered.
14. 关闭实例
SQL> shutdown immediate;
15.启动数据库
[oracle@node1 ~]$ srvctl start database -d rac
16.查看数据库归档状态
SQL> select name,log_mode,flashback_on from gv$database;
NAME LOG_MODE FLASHBACK_ON
--------- ------------ ------------------
RAC ARCHIVELOG NO
RAC ARCHIVELOG NO
17.归档测试
17.1 归档当前online日志组
SQL> alter system archive log current;
17.2 查看asm中是否生成
ASMCMD> ls
thread_1_seq_6.257.902564455
thread_1_seq_7.258.902564457
thread_1_seq_8.260.902564583
thread_2_seq_2.256.902564379
thread_2_seq_3.259.902564585
ASMCMD> pwd
+arch/rac/archivelog/2016_01_31
归档删除策略配置
日志的归档对于数据库的恢复提供了最完美的保障,对于纯粹的RAC或者单实例,归档的删除策略可以不用考虑,但是对于DG、OGG,那考虑的问题就要多了,且归档的删除策略关系到整个DG、OGG的完整性,因此归档删除策略以及闪回删除将独立为一篇!
开启闪回功能过程
11g开启闪回比10g容易许多,直接在线操作即可,如下
1. 查看当前闪回状态
QL> show parameter db_recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 0
2. 配置闪回路径
SQL> alter system set db_recovery_file_dest='+arch' scope=spfile;
System altered.
3. 配置闪回空间大小
SQL> alter system set db_recovery_file_dest_size=1g scope=spfile;
System altered.
4. 打开闪回功能
SQL> alter database flashback on;
Database altered.
注意:可以根据需要为特定的表空间打开或关闭闪回:
SQL> alter tablespace users flashback on;
SQL> alter tablespace users flashback off
5. 查看闪回状态
SQL> select name,log_mode,flashback_on from gv$database;
NAME LOG_MODE FLASHBACK_ON
--------- ------------ ------------------
RAC ARCHIVELOG YES
RAC ARCHIVELOG YES
11g以后的闪回关闭很简单,直接在任意节点执行
SQL>alter database flashback off;即可
最后,附带官方对闪回FRA介绍:
Specifying a Fast Recovery Area The Fast Recovery Area is a location in which Oracle Database can store and manage files related to backup and recovery. It is distinct from the database area, which is a location for the current database files (datafiles, control files, and online redo logs). You specify the Fast Recovery Area with the following initialization parameters: DB_RECOVERY_FILE_DEST: Location of the Fast Recovery Area. This can be a directory, file system, or Automatic Storage Management (Oracle ASM) disk group. It cannot be a raw file system. In an Oracle Real Application Clusters (Oracle RAC) environment, this location must be on a cluster file system, Oracle ASM disk group, or a shared directory configured through NFS. DB_RECOVERY_FILE_DEST_SIZE: Specifies the maximum total bytes to be used by the Fast Recovery Area. This initialization parameter must be specified before DB_RECOVERY_FILE_DEST is enabled. 注意:DB_RECOVERY_FILE_DEST_SIZE先于DB_RECOVERY_FILE_DEST配置,且rac节点配置一致! In an Oracle RAC environment, the settings for these two parameters must be the same on all instances. You cannot enable these parameters if you have set values for the LOG_ARCHIVE_DEST and LOG_ARCHIVE_DUPLEX_DEST parameters. You must disable those parameters before setting up the Fast Recovery Area. 注意:oracle rac中,在配置了FRA情况下,要禁掉LOG_ARCHIVE_DEST和LOG_ARCHIVE_DUPLEX_DEST 参数 You can instead set values for the LOG_ARCHIVE_DEST_n parameters. The LOG_ARCHIVE_DEST_1 parameter is implicitly set to point to the Fast Recovery Area if a local archiving location has not been configured and LOG_ARCHIVE_DEST_1 value has not been set. Oracle recommends using a Fast Recovery Area, because it can simplify backup and recovery operations for your database. 注意:Oracle官方推荐使用FRA,因为它可以简化备份、恢复数据库操作。
http://my.oschina.net/1272149624/blog/611949