在ASM单机环境下,开启归档的最简单的方法。
环境:oracle11g 11.2.0.4
登陆sqlplus
[oracle@udevasm ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Thu Jun 8 18:20:41 2017Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to an idle instance.要把Oracle数据库给启动到Open状态
SQL> startup
ORACLE instance started.Total System Global Area 1068937216 bytesFixed Size 2260088 bytesVariable Size 331350920 bytesDatabase Buffers 729808896 bytesRedo Buffers 5517312 bytesDatabase mounted.Database opened.查看ASM空间使用率
SQL> select group_number,name,total_mb,free_mb from v$asm_diskgroup;GROUP_NUMBER NAME TOTAL_MB FREE_MB------------ ------------------------------ ---------- ---------- 1 DGDATA01 22520 260 2 DGDATA02 20472 14132 3 DGRECOVERY 21500 21420 4 DGSYSTEM 20472 20392 5 GRID1 10232 10144查看归档状态
SQL> archive log list;Database log mode No Archive ModeAutomatic archival DisabledArchive destination /oracle/app/oracle/product/11.2.0/dbs/archOldest online log sequence 9Current log sequence 14SQL> show user
USER is "SYS"关库,或使用命令:shutdown immediate来关闭
SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.启库到mount
SQL> startup mount;ORACLE instance started.Total System Global Area 1068937216 bytesFixed Size 2260088 bytesVariable Size 331350920 bytesDatabase Buffers 729808896 bytesRedo Buffers 5517312 bytesDatabase mounted.查看当前节点的状态
SQL> select status from gv$instance;STATUS------------MOUNTED为节点开启归档,开启归档
SQL> alter database archivelog;Database altered.查看归档状态,发现归档日志路径不对,并不是默认的路径在ASM中的路径
SQL> archive log list;
Database log mode Archive ModeAutomatic archival EnabledArchive destination /oracle/app/oracle/product/11.2.0/dbs/archOldest online log sequence 9Next log sequence to archive 14Current log sequence 14修改归档路径
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+DGRECOVERY/' SCOPE=SPFILE SID='udevasm';
查看当前修改后路径
SQL> archive log list;
Database log mode Archive ModeAutomatic archival EnabledArchive destination +DGRECOVERY/arcOldest online log sequence 9Next log sequence to archive 14Current log sequence 14节点启库
SQL> alter database open;Database altered.
SQL> select status from v$instance;
STATUS------------OPEN来看一下,归档路径的信息,默认是直接指向了ASM中的路径
SQL> show parameter log_archive_dest;NAME TYPE VALUE------------------------------------ ----------- ------------------------------log_archive_dest stringlog_archive_dest_1 string LOCATION=+DGRECOVERY/ARClog_archive_dest_10 stringlog_archive_dest_11 stringlog_archive_dest_12 stringlog_archive_dest_13 stringlog_archive_dest_14 stringlog_archive_dest_15 stringlog_archive_dest_16 stringlog_archive_dest_17 stringlog_archive_dest_18 string
到ASM下看一下归档文件
ASMCMD> lsdgState Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files NameMOUNTED EXTERN N 512 4096 4194304 22520 260 0 260 0 N DGDATA01/MOUNTED EXTERN N 512 4096 4194304 20472 14132 0 14132 0 N DGDATA02/MOUNTED EXTERN N 512 4096 4194304 21500 21420 0 21420 0 N DGRECOVERY/MOUNTED EXTERN N 512 4096 4194304 20472 20392 0 20392 0 N DGSYSTEM/MOUNTED EXTERN N 512 4096 4194304 10232 10144 0 10144 0 N GRID1/SMCMD> cd 2017_06_08/
ASMCMD> lthread_1_seq_14.256.946154499thread_1_seq_15.257.946154499thread_1_seq_16.258.946154499thread_1_seq_17.259.946154499thread_1_seq_18.260.946154501thread_1_seq_19.261.946154523thread_1_seq_20.262.946154571