11g rac ASM下最簡單歸檔開啟/關閉方法

張衝andy發表於2016-12-06

本次先來介紹一下在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;


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2129839/,如需轉載,請註明出處,否則將追究法律責任。

相關文章