RAC启用归档日志

1.关闭实例

[oracle@RAC1 dbs]$ crsctl status resource -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.CVUQ.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.DBFD.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.LOGD.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.net1.network
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.ons
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.proxy_advm
               ONLINE  OFFLINE      rac1                     STABLE
               ONLINE  OFFLINE      rac2                     STABLE
               ONLINE  OFFLINE      rac3                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac2                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       rac3                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.LISTENER_SCAN4.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       rac1                     169.254.71.218 172.1
                                                             6.10.41,STABLE
ora.asm
      1        ONLINE  ONLINE       rac3                     STABLE
      2        ONLINE  ONLINE       rac2                     STABLE
      3        ONLINE  ONLINE       rac1                     STABLE
ora.cvu
      1        ONLINE  ONLINE       rac1                     STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       rac1                     Open,STABLE
ora.oc4j
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac1.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac2.vip
      1        ONLINE  ONLINE       rac2                     STABLE
ora.rac3.vip
      1        ONLINE  ONLINE       rac3                     STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       rac2                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       rac3                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.scan4.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.test.db
      1        ONLINE  ONLINE       rac3                     Open,STABLE
      2        ONLINE  ONLINE       rac1                     Open,STABLE
      3        ONLINE  ONLINE       rac2                     Open,STABLE     //实例open
--------------------------------------------------------------------------------
[oracle@RAC1 dbs]$ crsctl status resource -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.CVUQ.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.DBFD.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.LOGD.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.net1.network
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.ons
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.proxy_advm
               ONLINE  OFFLINE      rac1                     STABLE
               ONLINE  OFFLINE      rac2                     STABLE
               ONLINE  OFFLINE      rac3                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac2                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       rac3                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.LISTENER_SCAN4.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       rac1                     169.254.71.218 172.1
                                                             6.10.41,STABLE
ora.asm
      1        ONLINE  ONLINE       rac3                     STABLE
      2        ONLINE  ONLINE       rac2                     STABLE
      3        ONLINE  ONLINE       rac1                     STABLE
ora.cvu
      1        ONLINE  ONLINE       rac1                     STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       rac1                     Open,STABLE
ora.oc4j
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac1.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac2.vip
      1        ONLINE  ONLINE       rac2                     STABLE
ora.rac3.vip
      1        ONLINE  ONLINE       rac3                     STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       rac2                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       rac3                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.scan4.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.test.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
      2        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
      3        OFFLINE OFFLINE                               Instance Shutdown,ST     //实例shutdown
                                                             ABLE
--------------------------------------------------------------------------------

2.创建归档目录

[oracle@RAC2 ~]$ asmcmd
ASMCMD>
ASMCMD> ls
CVUQ/
DBFD/
LOGD/
ASMCMD> cd LOGD
ASMCMD> ls
TEST/
ASMCMD>
ASMCMD> cd TEST
ASMCMD> ls 
CONTROLFILE/
ONLINELOG/
ASMCMD> mkdir archive_log   //创建归档日志目录
ASMCMD> ls
CONTROLFILE/
ONLINELOG/
archive_log/
ASMCMD> cd archive_log
ASMCMD> pwd
+LOGD/TEST/archive_log
ASMCMD> exit

3.启用归档

[oracle@RAC1 dbs]$ echo $ORACLE_HOME   //设置oracle_home变量和sid变量 实现静态注册的原理 方便连接到实例
/oracle/ora/12.0.1
[oracle@RAC1 dbs]$ echo $ORACLE_SID
TEST3
[oracle@RAC1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on 星期二 11月 26 14:35:24 2013

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

已连接到空闲例程。

SQL> startup mount      //启动到mount状态
ORACLE 例程已经启动。

Total System Global Area 1169149952 bytes
Fixed Size            2287624 bytes
Variable Size          503318520 bytes
Database Buffers      654311424 bytes
Redo Buffers            9232384 bytes
数据库装载完毕。

SQL> alter system set cluster_database=false scope=spfile;   --将数据库设在为单实例

系统已更改。

SQL> shutdown immediate
ORA-01109: 数据库未打开


已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount

 
ORACLE 例程已经启动。

Total System Global Area 1169149952 bytes
Fixed Size            2287624 bytes
Variable Size          503318520 bytes
Database Buffers      654311424 bytes
Redo Buffers            9232384 bytes
数据库装载完毕。

SQL> alter system set log_archive_dest_1='LOCATION=+LOGD/TEST/archive_log' scope=spfile sid='TEST1'         --修改数据库的归档路径
  2  ;

系统已更改。

SQL> alter system set log_archive_dest_1='LOCATION=+LOGD/TEST/archive_log' scope=spfile sid='TEST2';

系统已更改。

SQL> alter system set log_archive_dest_1='LOCATION=+LOGD/TEST/archive_log' scope=spfile sid='TEST3';

系统已更改。

SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='arch_test1_%t_%s_%r.arc' scope=spfile sid='TEST1';              --修改数据库的归档命名

系统已更改。

SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='arch_test2_%t_%s_%r.arc' scope=spfile sid='TEST2';

系统已更改。

SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='arch_test3_%t_%s_%r.arc' scope=spfile sid='TEST3';

系统已更改。

SQL> alter database archivelog;                        --启用归档

数据库已更改。

SQL> alter database open;                    --open单实例

数据库已更改。

SQL> alter system set cluster_database=true scope=spfile;           --恢复数据库的集群参数

系统已更改。

SQL> shutdown immediate         --关闭实例
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。

4.启动集群数据库

[oracle@RAC1 dbs]$ srvctl start database -d TEST
[oracle@RAC1 dbs]$ crsctl status resource -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.CVUQ.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.DBFD.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.LOGD.dg
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.net1.network
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.ons
               ONLINE  ONLINE       rac1                     STABLE
               ONLINE  ONLINE       rac2                     STABLE
               ONLINE  ONLINE       rac3                     STABLE
ora.proxy_advm
               ONLINE  OFFLINE      rac1                     STABLE
               ONLINE  OFFLINE      rac2                     STABLE
               ONLINE  OFFLINE      rac3                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac2                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       rac3                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.LISTENER_SCAN4.lsnr
      1        ONLINE  ONLINE       rac1                     STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       rac1                     169.254.71.218 172.1
                                                             6.10.41,STABLE
ora.asm
      1        ONLINE  ONLINE       rac3                     STABLE
      2        ONLINE  ONLINE       rac2                     STABLE
      3        ONLINE  ONLINE       rac1                     STABLE
ora.cvu
      1        ONLINE  ONLINE       rac1                     STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       rac1                     Open,STABLE
ora.oc4j
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac1.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.rac2.vip
      1        ONLINE  ONLINE       rac2                     STABLE
ora.rac3.vip
      1        ONLINE  ONLINE       rac3                     STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       rac2                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       rac3                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.scan4.vip
      1        ONLINE  ONLINE       rac1                     STABLE
ora.test.db
      1        ONLINE  ONLINE       rac3                     Open,STABLE   //实例已open
      2        ONLINE  ONLINE       rac1                     Open,STABLE
      3        ONLINE  ONLINE       rac2                     Open,STABLE
--------------------------------------------------------------------------------

5.查看归档信息

[oracle@RAC1 dbs]$ sqlplus sys/[email protected]/TEST as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on 星期二 11月 26 15:01:37 2013

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


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

SQL> show parameter instance_name;

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
instance_name			     string	 TEST2
SQL> archive log list;
数据库日志模式            存档模式
自动存档             启用
存档终点            +LOGD/test/archive_log
最早的联机日志序列     23
下一个存档日志序列   24
当前日志序列           24

打完收工!!!

########################

迷途小运维原创

作者:john

转载请注明出处

你可能感兴趣的:(Oracle)