1. 程式人生 > >oracle rac啟用歸檔模式

oracle rac啟用歸檔模式

環境:

2個節點的RAC

資料庫版本:12.1.0.2.0

目的:

啟動歸檔日誌,同時將歸檔日誌存放到共享目錄(我這裡的是ASM磁碟組)

操作:

1、建立共享ASM磁碟組

C:\Users\Administrator>set ORACLE_HOME=E:\app\oraclehome\grid

C:\Users\Administrator>set ORACLE_SID=+ASM1

C:\Users\Administrator>asmcmd
ASMCMD> ls
DATA/
FRA/
OCR/
ASMCMD> cd fra
ASMCMD> pwd
+fra

ASMCMD> mkdir jiaxundb1
ASMCMD> mkdir jiaxundb2
ASMCMD> ls
jiaxundb1/
jiaxundb2/

2、檢視目前資料庫歸檔模式

C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on 星期三 8月 17 15:15:45 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     89
Current log sequence           90
SQL>

3、設定歸檔格式以及歸檔目的地

SQL> alter system set log_archive_format='%t_%s_%r.arch' scope=spfile sid='*';

System altered.

SQL> alter system set log_archive_dest_1='location=+fra/arch/jiaxundb1' scope=spfile sid='jiaxundb1';

System altered.

SQL> alter system set log_archive_dest_1='location=+fra/arch/jiaxundb2' scope=spfile sid='jiaxundb2';

System altered.

4、關閉所有例項

C:\Users\Administrator>srvctl stop database -d jiaxundb

5、將例項1啟動到Mount階段,並設定資料庫為歸檔模式

C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on 星期三 8月 17 15:27:20 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 1677721600 bytes
Fixed Size                  3046368 bytes
Variable Size            1056965664 bytes
Database Buffers          603979776 bytes
Redo Buffers               13729792 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +FRA/arch/jiaxundb1
Oldest online log sequence     89
Next log sequence to archive   90
Current log sequence           90
SQL>

6、啟動例項2,檢視資料庫歸檔模式是否正確

C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on 星期三 8月 17 15:35:30 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +FRA/arch/jiaxundb2
Oldest online log sequence     76
Next log sequence to archive   77
Current log sequence           77
SQL>

7、切換日誌組,驗證日誌是否被成功歸檔

SQL> alter system archive log current;

System altered.

ASMCMD> ls jiaxundb1
1_90_914678682.arch
1_91_914678682.arch
ASMCMD> ls jiaxundb2
2_77_914678682.arch
2_78_914678682.arch

OK,例項1和例項2已成功歸檔。