博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RAC环境下的备份与恢复(二)
阅读量:6535 次
发布时间:2019-06-24

本文共 9104 字,大约阅读时间需要 30 分钟。

 本节将简要的介绍下,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 -1.el4.x86_64.rpm

[root@rac1 ~]# wget
[root@rac1 ~]# wget
[root@rac1 ~]# wget
[root@rac1 ~]# wget
[root@rac1 ~]# wget
[root@rac1 ~]# wget

[root@rac1 ~]# rpm -ivh *.rpm  (在节点2上也需要安装这些rpm包)

準備中...                ########################################### [100%]
   1:ocfs2-tools            ########################################### [ 13%]
   2:ocfs2-2.6.9-89.EL      ########################################### [ 25%]
   3:ocfs2-2.6.9-89.EL-debug########################################### [ 38%]
   4:ocfs2-2.6.9-89.ELlarges########################################### [ 50%]
   5:ocfs2-2.6.9-89.ELsmp   ########################################### [ 63%]
   6:ocfs2console           ########################################### [ 75%]
   7:ocfs2-tools-debuginfo  ########################################### [ 88%]
   8:ocfs2-tools-devel      ########################################### [100%]

利用ocfs2console工具创建配置文件,并复制到节点2上

[root@rac1 ~]# ocfs2console

 

[root@rac2 ~]# cat /etc/ocfs2/cluster.conf

node:
        ip_port = 7777
        ip_address = 192.168.1.41
        number = 0
        name = rac1
        cluster = ocfs2

node:

        ip_port = 7777
        ip_address = 192.168.1.42
        number = 1
        name = rac2
        cluster = ocfs2

cluster:

        node_count = 2
        name = ocfs2

初始化o2cb,两个节点都需要如下操作

[root@rac1 ~]# /etc/init.d/o2cb unload
Stopping O2CB cluster ocfs2: OK
Unmounting ocfs2_dlmfs filesystem: OK
Unloading module "ocfs2_dlmfs": OK
Unmounting configfs filesystem: OK
Unloading module "configfs": OK

[root@rac1 ~]# /etc/init.d/o2cb configure

Configuring the O2CB driver.

This will configure the on-boot properties of the O2CB driver.

The following questions will determine whether the driver is loaded on
boot.  The current values will be shown in brackets ('[]').  Hitting
<ENTER> without typing an answer will keep that current value.  Ctrl-C
will abort.

Load O2CB driver on boot (y/n) [n]: y

Cluster to start on boot (Enter "none" to clear) [ocfs2]:
Specify heartbeat dead threshold (>=7) [31]: 61 
Specify network idle timeout in ms (>=5000) [30000]:
Specify network keepalive delay in ms (>=1000) [2000]:
Specify network reconnect delay in ms (>=2000) [2000]:
Writing O2CB configuration: OK
Loading module "configfs": OK
Mounting configfs filesystem at /config: OK
Loading module "ocfs2_nodemanager": OK
Loading module "ocfs2_dlm": OK
Loading module "ocfs2_dlmfs": OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK
Starting O2CB cluster ocfs2: OK

[root@rac1 ~]# /etc/init.d/o2cb status

Module "configfs": Loaded
Filesystem "configfs": Mounted
Module "ocfs2_nodemanager": Loaded
Module "ocfs2_dlm": Loaded
Module "ocfs2_dlmfs": Loaded
Filesystem "ocfs2_dlmfs": Mounted
Checking O2CB cluster ocfs2: Online
  Heartbeat dead threshold: 61
  Network idle timeout: 30000
  Network keepalive delay: 2000
  Network reconnect delay: 2000
Checking O2CB heartbeat: Not active

三:对共享存储进行分区

[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@rac1 ~]# mount -t ocfs2 -o datavolume,nointr /dev/sda1 /u01/app/oracle/rac_archivelog/
[root@rac1 ~]# mount |grep sda
/dev/sda1 on /u01/app/oracle/rac_archivelog type ocfs2 (rw,_netdev,datavolume,nointr,heartbeat=local)

[root@rac2 ~]# tail -1 /etc/fstab  (开机自动挂载配置)

/dev/sda1               /u01/app/oracle/rac_archivelog ocfs2 datavolume,nointr 0 0
[root@rac2 ~]# mount -a
[root@rac1 ~]# chown -R oracle.oinstall /u01/app/oracle/rac_archivelog/

五:修改归档路径到集群文件系统上

[oracle@rac1 ~]$ crs_stat -t -v

Name           Type           R/RA   F/FT   Target    State     Host       
----------------------------------------------------------------------
ora....SM1.asm application    0/5    0/0    ONLINE    ONLINE    rac1       
ora....C1.lsnr application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.gsd   application    0/5    0/0    ONLINE    ONLINE    rac1       
ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1       
ora.rac1.vip   application    0/0    0/0    ONLINE    ONLINE    rac1       
ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    rac2       
ora....C2.lsnr application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.gsd   application    0/5    0/0    ONLINE    ONLINE    rac2       
ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2       
ora.rac2.vip   application    0/0    0/0    ONLINE    ONLINE    rac2       
ora.racdb.db   application    0/0    0/1    ONLINE    ONLINE    rac1       
ora....b1.inst application    0/5    0/0    ONLINE    ONLINE    rac1       
ora....b2.inst application    0/5    0/0    ONLINE    ONLINE    rac2    

[oracle@rac1 ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Dec 15 13:29:44 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

SQL> conn /as sysdba

Connected.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +FRA
Oldest online log sequence     42
Next log sequence to archive   43
Current log sequence           43
SQL> conn as sysdba
Connected.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +FRA
Oldest online log sequence     18
Next log sequence to archive   19
Current log sequence           19

SQL> conn /as sysdba

Connected.
SQL> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/rac_archivelog';
System altered.

SQL> conn as sysdba

Connected.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/rac_archivelog
Oldest online log sequence     18
Next log sequence to archive   19
Current log sequence           19
SQL> alter system archive log current;
System altered.

[root@rac2 ~]# ls /u01/app/oracle/rac_archivelog/

1_43_769205632.dbf  2_19_769205632.dbf  lost+found

六:测试数据库的恢复

RMAN> list backup of database summary;

List of Backups

===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
7       B  0  A DISK        2011-12-12 20:34:22 1       1       NO         RACDB_BAK_20121212
8       B  0  A DISK        2011-12-12 20:34:22 1       1       NO         RACDB_BAK_20121212

 

[oracle@rac1 ~]$ sqlplus

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Dec 15 13:38:43 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> create table t2 as select * from t1;

Table created.

SQL> insert into t2 select * from t2;

1 row created.

SQL> /

2 rows created.

SQL> /

4 rows created.

SQL> commit;

Commit complete.

SQL> conn /as sysdba

Connected.
SQL> alter system archive log current;
System altered.

SQL> select file_name from dba_data_files where tablespace_name='USERS';

FILE_NAME

----------------------------------------
+DATA/racdb/datafile/users.259.769728851

[oracle@rac1 ~]$ srvctl stop database -d racdb -o immediate

[oracle@rac1 ~]$ export ORACLE_SID=+ASM1
[oracle@rac1 ~]$ asmcmd rm -rf +DATA/racdb/datafile/users.259.769728851

[oracle@rac1 ~]$ srvctl start  database -d racdb

PRKP-1001 : Error starting instance racdb1 on node rac1
CRS-0215: Could not start resource 'ora.racdb.racdb1.inst'.
PRKP-1001 : Error starting instance racdb2 on node rac2
CRS-0215: Could not start resource 'ora.racdb.racdb2.inst'.

[oracle@rac1 ~]$ tail -f /u01/app/oracle/admin/racdb/bdump/alert_racdb1.log

ALTER DATABASE OPEN
This instance was first to open
Thu Dec 15 13:52:03 CST 2011
Errors in file /u01/app/oracle/admin/racdb/bdump/racdb1_dbw0_23072.trc:
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '+DATA/racdb/datafile/users.259.769728851'
ORA-17503: ksfdopn:2 Failed to open file +DATA/racdb/datafile/users.259.769728851
ORA-15012: ASM file '+DATA/racdb/datafile/users.259.769728851' does not exist
ORA-1157 signalled during: ALTER DATABASE OPEN...
Thu Dec 15 13:52:05 CST 2011
Shutting down instance (abort)
License high water mark = 1
Instance terminated by USER, pid = 23262

[oracle@rac1 ~]$ srvctl start  database -d racdb -o mount

[oracle@rac1 ~]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Dec 15 13:54:43 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: RACDB (DBID=766822397, not open)

RMAN> restore datafile 4;

RMAN> recover datafile 4;
RMAN> alter database open;
database opened
RMAN> exit

[oracle@rac1 ~]$ sqlplus as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Dec 15 13:57:18 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select name,open_mode from v$database;

NAME                        OPEN_MODE

--------------------------- ------------------------------
RACDB                       MOUNTED

SQL> alter database open;

Database altered.

SQL> select * from test.t2;

         A

----------
         1
         1
         1
         1
         1
         1
         1
         1

8 rows selected.

转载地址:http://sswdo.baihongyu.com/

你可能感兴趣的文章
Linux中Inode概念
查看>>
KVM命令集管理虚拟机
查看>>
常用的商业级和免费开源Web漏洞扫描工具
查看>>
快过年了,我给小明制定了一份价值60万的Java学习计划
查看>>
新一代视频AI服务,阿里云智能视觉重磅发布
查看>>
2019年面对全新的DDoS功击企业需做好哪些防护措施?
查看>>
原有vue项目接入typescript
查看>>
企业该分多少钱给员工?看柏明顿阿米巴奖金分配方案
查看>>
百度PaddlePaddle再获新技能 智能推荐、对话系统、控制领域都能搞定!
查看>>
大学生如何看待校园考勤
查看>>
如何保护云中的工作负载
查看>>
基础面试题String、变量、类与对象、集合类、SSH
查看>>
酷不酷,就来看我家的车库!李彦宏说“我们的无人车刚换了大车库”
查看>>
森拓气液增压缸什么时候更换液压油_具体步骤
查看>>
学习总结
查看>>
shell计算工具源码
查看>>
像素密度和分辨率
查看>>
amoeba连接mysql--ERROR 2006 (HY000): MySQL server has gone away
查看>>
Vmware vSphere(Esxi)常见问题汇总(转载)
查看>>
BGP路径选择次序
查看>>