原创作品,出自 “深蓝的blog” 博客,深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/47172639
本次先来介绍一下在rac环境下,开启归档的最简单的方法。
环境:oracle11g RAC 11.2.0.4
登陆sqlplus
Last login: Wed Jul 29 09:25:43 2015 from 10.112.16.22
[root@hyldb1 ~]# su - oracle
[oracle@hyldb1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 29 09:29:44 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
查看ASM空间使用率
SQL> select group_number,name,total_mb,free_mb from v$asm_diskgroup;
GROUP_NUMBER NAME TOTAL_MB FREE_MB
------------ ------------------------------ ---------- ----------
1 OCR_ARCH 2048000 2042322
2 OCR_DATA 26112000 23640108
3 OCR_VOTE 61440 60514
查看归档状态
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 29061
Current log sequence 29065
SQL> show user
USER is "SYS"
节点1、2,分别关库,或使用命令:srvctl stop instance -d hyl来关闭所有实例。
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
节点1,启库到mount
SQL> startup mount;
ORACLE instance started.
Total System Global Area 3.9284E+10 bytes
Fixed Size 2261608 bytes
Variable Size 7516196248 bytes
Database Buffers 3.1675E+10 bytes
Redo Buffers 89997312 bytes
Database mounted.
查看节点1的状态
SQL> select status from gv$instance;
STATUS
------------
MOUNTED
为节点1开启归档
开启归档
SQL> alter database archivelog;
Database altered.
查看归档状态,可以看到默认归档路径为USE_DB_RECOVERY_FILE_DEST
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 29061
Next log sequence to archive 29065
Current log sequence 29065
节点1启库
SQL> alter database open;
Database altered.
SQL> select status,instance_name from gv$instance;
STATUS INSTANCE_NAME
------------ ----------------
OPEN hyl1
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 29061
Next log sequence to archive 29065
Current log sequence 29065
来看一下,归档路径的信息,默认是直接指向了ASM中的路径
SQL> show parameter recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +OCR_ARCH
db_recovery_file_dest_size big integer 4407M
db_unrecoverable_scn_tracking boolean TRUE
recovery_parallelism integer 0
节点2启库:
SQL> startup;
ORACLE instance started.
Total System Global Area 3.9284E+10 bytes
Fixed Size 2261608 bytes
Variable Size 6710889880 bytes
Database Buffers 3.2481E+10 bytes
Redo Buffers 89997312 bytes
Database mounted.
Database opened.
查看集群实例启动状态
SQL> select status,instance_name from gv$instance;
STATUS INSTANCE_NAME
------------ ----------------
OPEN hyl2
OPEN hyl1
查看节点2的归档状态
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 48485
Next log sequence to archive 48489
Current log sequence 48489
查看db_recovery_file_dest信息
SQL> show parameter recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +OCR_ARCH
db_recovery_file_dest_size big integer 4407M
db_unrecoverable_scn_tracking boolean TRUE
recovery_parallelism integer 0
到ASM下看一下归档文件
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 2048000 2042300 0 2042300 0 N OCR_ARCH/
MOUNTED EXTERN N 512 4096 1048576 26112000 23640108 0 23640108 0 N OCR_DATA/
MOUNTED NORMAL N 512 4096 1048576 61440 60514 20480 20017 0 Y OCR_VOTE/
ASMCMD> cd +OCR_ARCH/hyl/ARCHIVELOG/2015_07_29
ASMCMD> ls -s
Block_Size Blocks Bytes Space Name
512 43974 22514688 23068672 thread_2_seq_48488.268.886327155
节点1上切一下归档
SQL> alter system switch logfile;
System altered.
在看一下归档文件的信息
ASMCMD> ls -ls
Type Redund Striped Time Sys Block_Size Blocks Bytes Space Name
ARCHIVELOG UNPROT COARSE JUL 29 10:00:00 Y 512 378883 193988096 196083712 thread_1_seq_29065.269.886328273
ARCHIVELOG UNPROT COARSE JUL 29 09:00:00 Y 512 43974 22514688 23068672 thread_2_seq_48488.268.886327155
可以看到线程1,即节点1的归档文件已经成功生成了。
这种设置归档路径使用的db_recovery_file_dest,但是要注意db_recovery_file_dest的大小设置,默认设置往往比较小,对于生成环境显然是不够的,需要调整。
如果默认设置过小,使用这种方式,开启归档后常常遇到如下错误:
ORA-00257: archiver error. Connect internal only, until freed
如指令:
SQL> alter system set db_recovery_file_dest_size=200G;
————————————————————————————————
关闭RAC归档 由开>到关
-- 关闭数据库
[oracle@hyldb1 ~]$ srvctl stop database -d jcdydb
-- 一个节点操作:
[oracle@hyldb1 ~]$ sqlplus / as sysdba
SQL> startup mount
SQL> alter system set cluster_database=false scope=spfile sid='*';
SQL> alter database noarchivelog;
SQL> alter database open;
SQL> alter system set cluster_database=true scope=spfile sid='*';
-- 另外一个打开数据库
[oracle@hyldb2 ~]$ srvctl stop database -d jcdydb
-- 删除归档文件
[oracle@hyldb1 ~]$ rman target /
RMAN> delete archivelog all;
本文转自 张冲andy 博客园博客,原文链接: http://www.cnblogs.com/andy6/p/6063744.html,如需转载请自行联系原作者