本节将简要的介绍下,rac环境下将归档日志存放到集群文件系统场景下的备份和恢复操作,集群文件系统采用oracle的ocfs2;
一:环境介绍
节点1 IP:192.168.1.41/24
操作系统:centos4.8 64位 (kvm虚拟机)
主机名: rac1.yang.com
节点2 IP:192.168.1.42/24
操作系统: centos4.8 64位 (kvm虚拟机)
|
主机名: rac2.yang.com
共享存储IP:192.168.1.100/24
操作系统: rhel6.0 64位
主机名: rhel6.yang.com
二:安装和配置ocfs2集群文件系统
[root@rac1 ~]# wget http://oss.oracle.com/projects/ocfs2/dist/files/RedHat/RHEL4/x86_64/1.2.9-1/2.6.9-89.EL/ocfs2-2.6.9-89.EL-debuginfo-1.2.9-1.el4.x86_64.rpm [root@rac1 ~]# rpm -ivh *.rpm (在节点2上也需要安装这些rpm包) |
利用ocfs2console工具创建配置文件,并复制到节点2上
[root@rac1 ~]# ocfs2console
[root@rac2 ~]# cat /etc/ocfs2/cluster.conf node: cluster: 初始化o2cb,两个节点都需要如下操作 [root@rac1 ~]# /etc/init.d/o2cb configure This will configure the on-boot properties of the O2CB driver. Load O2CB driver on boot (y/n) [n]: y [root@rac1 ~]# /etc/init.d/o2cb status |
三:对共享存储进行分区
[root@rac1 ~]# fdisk -l /dev/sda
Disk /dev/sda: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 10240 10485744 83 Linux
四:利用o2fsconsole工具格式化共享存储,并在各个节点进行挂载
[root@rac1 ~]# ocfs2console
[root@rac1 ~]# mkdir /u01/app/oracle/rac_archivelog [root@rac2 ~]# tail -1 /etc/fstab (开机自动挂载配置) |
五:修改归档路径到集群文件系统上
[oracle@rac1 ~]$ crs_stat -t -v [oracle@rac1 ~]$ sqlplus /nolog SQL> conn /as sysdba SQL> conn /as sysdba SQL> conn sys/123456@racdb2 as sysdba [root@rac2 ~]# ls /u01/app/oracle/rac_archivelog/ |
六:测试数据库的恢复
RMAN> list backup of database summary; List of Backups
[oracle@rac1 ~]$ sqlplus test/hr@racdb2 Connected to: SQL> create table t2 as select * from t1; SQL> insert into t2 select * from t2; SQL> / SQL> / SQL> commit; SQL> conn /as sysdba SQL> select file_name from dba_data_files where tablespace_name='USERS'; FILE_NAME [oracle@rac1 ~]$ srvctl stop database -d racdb -o immediate [oracle@rac1 ~]$ srvctl start database -d racdb [oracle@rac1 ~]$ tail -f /u01/app/oracle/admin/racdb/bdump/alert_racdb1.log [oracle@rac1 ~]$ srvctl start database -d racdb -o mount RMAN> restore datafile 4; [oracle@rac1 ~]$ sqlplus sys/123456@racdb2 as sysdba Connected to: SQL> select name,open_mode from v$database; NAME OPEN_MODE SQL> alter database open; SQL> select * from test.t2; A 8 rows selected. |