oracle 11g rac 开启修改归档模式
oracle 11g rac开启修改归档模式
目的:
把归档模式打开并且将日志放在共享存储(ASM)上。
环境信息:
主机名:db1,db2
实例名:rac11,rac12
1.配置归档目录
在db上执行
[root@db1 ~] # su - grid
[grid@db11 ~]$ sqlplus / as sysasm
SQL> select name from v$asm_diskgroup;
NAME
------------------------------
ARCH
CRS
DATA
需要将归档日志存放在ASM上。因此需要在ASM建归档路径
[root@db1 ~]# su - grid
[grid@db1 ~]$ asmcmd
ASMCMD> ls
ARCH/
CRS/
DATA/
ASMCMD> cd ARCH/
ASMCMD> mkdir ARCH1
ASMCMD> mkdir ARCH2
ASMCMD> cd ARCH2
ASMCMD> pwd
+ARCH/ARCH2
ASMCMD>
当然也可以采用此方法:
SQL>
alter
diskgroup ARCH
add
directory
'+ARCH/ARCH1'
;
SQL>
alter
diskgroup ARCH
add
directory
'+ARCH/ARCH2'
;
修改归档参数
任意一个实例,oracle用户下:
SQL> alter system set log_archive_dest_1='LOCATION=+ARCH/ARCH1' scope=spfile sid='racdb11';
SQL> alter system set log_archive_dest_1='LOCATION=+ARCH/ARCH2' scope=spfile sid='racdb12';
这是分别将两个实例的归档目录放到同一个ASM不同的目录里面。
如果是存于相同的目录下可以使用下面的命令:
SQL> alter system set log_archive_dest_1='LOCATION=+ARCH/ARCH2' scope=spfile sid='*';
关闭2个实例,关闭数据库,全部节点都要关闭
节点DB1上执行
SQL> SHUTDOWN IMMEDIATE
节点DB!2执行
SQL> SHUTDOWN IMMEDIATE
或是采用此方法,grid用户下执行:
[grid@db1 ~]$ srvctl stop database -d racdb
racdb 为实例全局名
[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.CRS.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.DATA.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.LISTENER.lsnr
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.asm
ONLINE ONLINE db1 Started
ONLINE ONLINE db2 Started
ora.gsd
OFFLINE OFFLINE db1
OFFLINE OFFLINE db2
ora.net1.network
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.ons
ONLINE ONLINE db1
ONLINE ONLINE db2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE db1
ora.cvu
1 ONLINE ONLINE db1
ora.db1.vip
1 ONLINE ONLINE db1
ora.db2.vip
1 ONLINE ONLINE db2
ora.oc4j
1 ONLINE ONLINE db1
ora.racdb.db
1 OFFLINE OFFLINE Instance Shutdown
2 OFFLINE OFFLINE Instance Shutdown
开启归档模式
节点db1 上执行
SQL>STARTUP MOUNT
SQL>ALTER DATABASE ARCHIVELOG;
Database altered.
或是使用以下命令,grid 用户下执行:
[grid@db1 ~]$ srvctl start instance -d racdb -i racdb11 -o mount
[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.CRS.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.DATA.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.LISTENER.lsnr
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.asm
ONLINE ONLINE db1 Started
ONLINE ONLINE db2 Started
ora.gsd
OFFLINE OFFLINE db1
OFFLINE OFFLINE db2
ora.net1.network
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.ons
ONLINE ONLINE db1
ONLINE ONLINE db2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE db1
ora.cvu
1 ONLINE ONLINE db1
ora.db1.vip
1 ONLINE ONLINE db1
ora.db2.vip
1 ONLINE ONLINE db2
ora.oc4j
1 ONLINE ONLINE db1
ora.racdb.db
1 ONLINE INTERMEDIATE db1 Mounted (Closed)
2 OFFLINE OFFLINE Instance Shutdown
ora.scan1.vip
1 ONLINE ONLINE db1
修改数据库的归档模式并启动数据库,ORACLE用户下执行:
SQL> alter database archivelog;数据库已更改。SQL> alter database open;
数据库已更改。检查状态 :
SQL> archive log list;
数据库日志模式 存档模式
自动存档 启用
存档终点 +ARCH/arch1
最早的联机日志序列 7
下一个存档日志序列 8
当前日志序列 8
启动2节点数据库
[grid@db1 ~]$ srvctl start instance -d racdb -i racdb12
检查集群状态
[grid@db1 ~]$ crsctl stat res -t--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.CRS.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.DATA.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.LISTENER.lsnr
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.asm
ONLINE ONLINE db1 Started
ONLINE ONLINE db2 Started
ora.gsd
OFFLINE OFFLINE db1
OFFLINE OFFLINE db2
ora.net1.network
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.ons
ONLINE ONLINE db1
ONLINE ONLINE db2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE db1
ora.cvu
1 ONLINE ONLINE db1
ora.db1.vip
1 ONLINE ONLINE db1
ora.db2.vip
1 ONLINE ONLINE db2
ora.oc4j
1 ONLINE ONLINE db1
ora.racdb.db
1 ONLINE ONLINE db1 Open
2 ONLINE ONLINE db2 Open
ora.scan1.vip
1 ONLINE ONLINE db1
检查db2 数据库归档状态:
[root@db2 ~]# su - oracle
[oracle@db2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期三 10月 5 15:34:27 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
连接到:
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
SQL> archive log list;
数据库日志模式 存档模式
自动存档 启用
存档终点 +ARCH/arch2
最早的联机日志序列 4
下一个存档日志序列 5
当前日志序列
已经成功能开启归档。
验证归档文件成功生成在目标位置:
执行alter system switch logfile并且多切换几次确定每次切换都有相对应的归档日志生成
SQL> alter system switch logfile;
系统已更改。
SQL> alter system switch logfile;
系统已更改。
SQL> alter system switch logfile;
系统已更改。
SQL> alter system switch logfile;
系统已更改。
检查 ASM目录已经生成相关的的归档文件
ASMCMD> pwd
+ARCH/ARCH2
ASMCMD> ls
2_5_924397271.dbf
2_6_924397271.dbf
2_7_924397271.dbf
2_8_924397271.dbf
ASMCMD> ls ../ARCH1
1_8_924397271.dbf
2_4_924397271.dbf
ASMCMD>
目录 返回
首页