当前位置:  数据库>oracle

同一环境下新建Standby RAC库

    来源: 互联网  发布时间:2017-06-27

    本文导语: 需求:在同一个环境下新建Standby RAC库,即和Primary RAC在相同的磁盘组。说明:生产环境一般不建议这样配置DG,因为存储层面是相同磁盘组,灾备的实际意义不大。我这里是用作读写分离。 基本信息:db_name: jyzhaoPrimary RAC db_uniqu...

需求:在同一个环境下新建Standby RAC库,即和Primary RAC在相同的磁盘组。
说明:生产环境一般不建议这样配置DG,因为存储层面是相同磁盘组,灾备的实际意义不大。我这里是用作读写分离。

基本信息:
db_name: jyzhao
Primary RAC db_unique_name:jyzhao
Standby RAC db_unique_name:jyzhaodg
Standby RAC instance_name: jyzhaodg1, jyzhaodg2
版本:GI 11.2.0.4 + DB 11.2.0.4

第一章 准备工作

  • 1.1 ASM存储
  • 1.2 配置tnsnames.ora
  • 1.3 密码文件

第二章 源数据库备份

第三章 参数文件

  • 3.1 修改主库参数文件
  • 3.2 修改Standby RAC 参数
  • 3.3 在ASM中创建standby的spfile
  • 3.4 Standby RAC启动到nomount

第五章 rman恢复数据库
第六章 备库开启日志应用
第七章 创建standby log
第八章 检查资源状态

第一章 准备工作 1.1 ASM存储

确认RAC Standby存储是在和RAC Primary相同的ASM磁盘组内(PS:灾备效果不明显),创建RAC Standby存储目录(根据db_unique_name)

mkdir +DATA/JYZHAODG
mkdir +FRA/JYZHAODG
1.2 配置tnsnames.ora

cd $Oracle_HOME/network/admin/
cat tnsnames.ora
添加主库备库的连接信息(所有节点):

JYZHAO =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oradb-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jyzhao)
    )
  )

jyzhaodg =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oradb-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jyzhaodg)
    )
  )
1.3 密码文件

节点1:

export ORACLE_SID=jyzhaodg1
密码文件;
cd $ORACLE_HOME/dbs
orapwd file=orapwjyzhaodg1 password=oracle entries=5
或者直接copy之前的密码文件,然后mv重命名:
cp orapwjyzhao1 orapwjyzhaodg1

节点2:

export ORACLE_SID=jyzhaodg2
密码文件;
cd $ORACLE_HOME/dbs
orapwd file=orapwjyzhaodg2 password=oracle entries=5
或者直接copy之前的密码文件,然后mv重命名:
cp orapwjyzhao2 orapwjyzhaodg2

最后测试相互连接可用

sqlplus sys/oracle@jyzhao as sysdba
sqlplus sys/oracle@jyzhaodg as sysdba
第二章 源数据库备份

vi backup.sh
备份脚本如下:

rman target /  select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/jyzhaodg/onlinelog/group_2.262.931878637
+FRA/jyzhao/onlinelog/group_2.258.931878639
+DATA/jyzhaodg/onlinelog/group_1.261.931878635
+FRA/jyzhao/onlinelog/group_1.257.931878637
+DATA/jyzhaodg/onlinelog/group_3.265.931879021
+FRA/jyzhao/onlinelog/group_3.259.931879023
+DATA/jyzhaodg/onlinelog/group_4.266.931879027
+FRA/jyzhao/onlinelog/group_4.260.931879029

8 rows selected.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DATA/jyzhaodg/tempfile/temp.263.931878661

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DATA/jyzhaodg/controlfile/current.288.937645851
+FRA/jyzhaodg/controlfile/current.275.937645851

发现日志文件有不符合预期的路径,进行修正:

SQL> show parameter convert

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string      +DATA/jyzhao, +DATA/jyzhaodg
log_file_name_convert                string      +DATA/jyzhao, +DATA/jyzhaodg

SQL> alter system set log_file_name_convert='+DATA/jyzhao','+DATA/jyzhaodg','+FRA/jyzhao','+FRA/jyzhaodg' scope=spfile;

SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2252824 bytes
Variable Size             222302184 bytes
Database Buffers           83886080 bytes
Redo Buffers                4718592 bytes
Database mounted.
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/jyzhaodg/onlinelog/group_2.262.931878637
+FRA/jyzhaodg/onlinelog/group_2.258.931878639
+DATA/jyzhaodg/onlinelog/group_1.261.931878635
+FRA/jyzhaodg/onlinelog/group_1.257.931878637
+DATA/jyzhaodg/onlinelog/group_3.265.931879021
+FRA/jyzhaodg/onlinelog/group_3.259.931879023
+DATA/jyzhaodg/onlinelog/group_4.266.931879027
+FRA/jyzhaodg/onlinelog/group_4.260.931879029

8 rows selected.
第五章 rman恢复数据库

Standby RAC节点1:

确定ORACLE_SID变量:

echo $ORACLE_SID
export ORACLE_SID=jyzhaodg1

a. 如果是使用从备份集恢复的方式
vi restore.sh

rman target /  switch database to copy;

using target database control file instead of recovery catalog
datafile 1 switched to datafile copy "+DATA/jyzhaodg/datafile/0eru6m4s.dbf"
datafile 2 switched to datafile copy "+DATA/jyzhaodg/datafile/0fru6m4s.dbf"
datafile 3 switched to datafile copy "+DATA/jyzhaodg/datafile/0hru6meo.dbf"
datafile 4 switched to datafile copy "+DATA/jyzhaodg/datafile/0iru6mg5.dbf"
datafile 5 switched to datafile copy "+DATA/jyzhaodg/datafile/0jru6mg6.dbf"
datafile 6 switched to datafile copy "+DATA/jyzhaodg/datafile/0gru6men.dbf"
第六章 备库开启日志应用

确认Primary RAC的日志传输链路打开:

echo $ORACLE_SID
export ORACLE_SID=jyzhao1

SQL> alter system set log_archive_dest_state_3=enable;

Standby RAC节点1在mount状态下开启日志应用:

echo $ORACLE_SID
export ORACLE_SID=jyzhaodg1

SQL> alter database recover managed standby database disconnect from session;
第七章 创建standby log

停止备库应用:

SQL> alter database recover managed standby database cancel;                   

查看日志信息:

SQL> select * from v$Log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME   NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------ ------------ ------------
         1          1         69   52428800        512          2 YES CURRENT                2450934 03-MAR-17      2.8147E+14
         2          1          0   52428800        512          2 YES UNUSED                 2440706 03-MAR-17         2450934 03-MAR-17
         3          2          0   52428800        512          2 YES UNUSED                 2440817 03-MAR-17         2450939 03-MAR-17
         4          2         36   52428800        512          2 YES CURRENT                2450939 03-MAR-17      2.8147E+14


SQL> col member for a70
SQL> select group#, type, member from v$logfile;

    GROUP# TYPE    MEMBER
---------- ------- ----------------------------------------------------------------------
         2 ONLINE  +DATA/jyzhaodg/onlinelog/group_2.298.937648563
         2 ONLINE  +FRA/jyzhaodg/onlinelog/group_2.278.937648565
         1 ONLINE  +DATA/jyzhaodg/onlinelog/group_1.297.937648559
         1 ONLINE  +FRA/jyzhaodg/onlinelog/group_1.279.937648561
         3 ONLINE  +DATA/jyzhaodg/onlinelog/group_3.299.937648567
         3 ONLINE  +FRA/jyzhaodg/onlinelog/group_3.389.937648569
         4 ONLINE  +DATA/jyzhaodg/onlinelog/group_4.300.937648573
         4 ONLINE  +FRA/jyzhaodg/onlinelog/group_4.390.937648573

8 rows selected.

根据检查结果,合理为数据库添加standby logfile:

alter database add standby logfile thread 1 group 11 ('+DATA','+FRA') size 52428800;
alter database add standby logfile thread 1 group 12 ('+DATA','+FRA') size 52428800;
alter database add standby logfile thread 1 group 13 ('+DATA','+FRA') size 52428800;

alter database add standby logfile thread 2 group 21 ('+DATA','+FRA') size 52428800;
alter database add standby logfile thread 2 group 22 ('+DATA','+FRA') size 52428800;
alter database add standby logfile thread 2 group 23 ('+DATA','+FRA') size 52428800;

添加完再次查看:

SQL> select group#, type, member from v$logfile;

    GROUP# TYPE    MEMBER
---------- ------- ----------------------------------------------------------------------
         2 ONLINE  +DATA/jyzhaodg/onlinelog/group_2.298.937648563
         2 ONLINE  +FRA/jyzhaodg/onlinelog/group_2.278.937648565
         1 ONLINE  +DATA/jyzhaodg/onlinelog/group_1.297.937648559
         1 ONLINE  +FRA/jyzhaodg/onlinelog/group_1.279.937648561
         3 ONLINE  +DATA/jyzhaodg/onlinelog/group_3.299.937648567
         3 ONLINE  +FRA/jyzhaodg/onlinelog/group_3.389.937648569
         4 ONLINE  +DATA/jyzhaodg/onlinelog/group_4.300.937648573
         4 ONLINE  +FRA/jyzhaodg/onlinelog/group_4.390.937648573
        11 STANDBY +DATA/jyzhaodg/onlinelog/group_11.301.937648773
        11 STANDBY +FRA/jyzhaodg/onlinelog/group_11.391.937648775
        12 STANDBY +DATA/jyzhaodg/onlinelog/group_12.302.937648777

    GROUP# TYPE    MEMBER
---------- ------- ----------------------------------------------------------------------
        12 STANDBY +FRA/jyzhaodg/onlinelog/group_12.392.937648779
        13 STANDBY +DATA/jyzhaodg/onlinelog/group_13.303.937648779
        13 STANDBY +FRA/jyzhaodg/onlinelog/group_13.393.937648781
        21 STANDBY +DATA/jyzhaodg/onlinelog/group_21.304.937648783
        21 STANDBY +FRA/jyzhaodg/onlinelog/group_21.394.937648783
        22 STANDBY +DATA/jyzhaodg/onlinelog/group_22.305.937648785
        22 STANDBY +FRA/jyzhaodg/onlinelog/group_22.395.937648787
        23 STANDBY +DATA/jyzhaodg/onlinelog/group_23.306.937648787
        23 STANDBY +FRA/jyzhaodg/onlinelog/group_23.396.937648789

20 rows selected.

继续开启备库应用,确定恢复完成日志没报错信息后取消日志应用,打开数据库,开启ADG:

alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;     
alter database open;
alter database recover managed standby database using current logfile disconnect from session;

查看DG同步状态:

SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE; 

OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    FOR DATAGUAR GUARD_S
-------------------- ---------------- -------------------- --- -------- -------
READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED          NO  DISABLED NONE

SQL> set lines 1000
SQL> select * from v$dataguard_stats;

NAME                             VALUE                                                            UNIT                           TIME_COMPUTED                  DATUM_TIME
-------------------------------- ---------------------------------------------------------------- ------------------------------ ------------------------------ ------------------------------
transport lag                    +00 00:09:37                                                     day(2) to second(0) interval   03/03/2017 10:03:20            03/03/2017 10:03:13
apply lag                        +00 00:09:38                                                     day(2) to second(0) interval   03/03/2017 10:03:20            03/03/2017 10:03:13
apply finish time                                                                                 day(2) to second(3) interval   03/03/2017 10:03:20
estimated startup time           40                                                               second                         03/03/2017 10:03:20

--可以在Primary RAC上归档当前日志模拟业务切换归档:
SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE; 

OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    FOR DATAGUAR GUARD_S
-------------------- ---------------- -------------------- --- -------- -------
READ WRITE           PRIMARY          TO STANDBY           NO  DISABLED NONE

SQL> alter system archive log current;

System altered.


--再次在Standby RAC上查看DG同步状态:
SQL> r
  1* select * from v$dataguard_stats

NAME                             VALUE                                                            UNIT                           TIME_COMPUTED                  DATUM_TIME
-------------------------------- ---------------------------------------------------------------- ------------------------------ ------------------------------ ------------------------------
transport lag                    +00 00:00:00                                                     day(2) to second(0) interval   03/03/2017 10:04:45            03/03/2017 10:04:44
apply lag                        +00 00:00:00                                                     day(2) to second(0) interval   03/03/2017 10:04:45            03/03/2017 10:04:44
apply finish time                                                                                 day(2) to second(3) interval   03/03/2017 10:04:45
estimated startup time           40                                                               second                         03/03/2017 10:04:45

至此,已完成RAC Standby库在同环境下的创建。

第八章 检查资源状态

我们可以将RAC Standby也加入到crs资源中:

[oracle@oradb23 ~]$ srvctl add database -d jyzhaodg -o $ORACLE_HOME -i jyzhaodg1 -n jyzhao
[oracle@oradb23 ~]$ srvctl add instance -d jyzhaodg -i jyzhaodg1 -n oradb23
[oracle@oradb23 ~]$ srvctl add instance -d jyzhaodg -i jyzhaodg2 -n oradb24
--启动数据库
[oracle@oradb23 ~]$ srvctl start database -d salehrdg
--查看资源状态:
[grid@oradb23 ~]$ crsctl stat res -t

总结:同环境下搭建Standby RAC,最重要的注意事项就是一定要细心,操作前确保自己操作的是正确的ORACLE_SID,备库的路径也要反复确认无误再操作。


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 如何在RAC环境下修改Oracle字符集
  • 多jdk环境下安装多个tomcat冲突解决配置方法
  • 程序中获取的环境变量能够根据Linux系统中相应环境变量而变化吗?
  • Linux下如何查看,设置环境变量并立即生效
  • 用JSP。XML开发网站。请问那种环境设置最好。该如何设置环境
  • Mysql服务器登陆,启动,停止等基本操作命令介绍(Linux/Centos环境)
  • 怎么查看自己的shell的环境变量,和root的环境变量,solaris系统
  • Android环境的PHP开发环境 ANMPP
  • 退出curses环境到字符环境的问题?
  • 请问:环境变量的值 一般前面加$就可以了,但有时又用{}将环境变量括起来,它们有什么区别啊?
  • mysql iis7站长之家
  • 用的是linux,kde,gnome为中文环境,如果把它改为英文环境。
  • 下载了个Tomcat 5.0.27,solaris 9系统,但是环境Java_home的环境变量不知道怎么设定
  • 急,《UNIX环境高级编程》中6.9 环境变量T Z是什么?
  • 如何在linux环境下配置java环境变量?
  • 求教: Linux环境下有没有类似VC++那样的、比较容易使用的集成开发环境?
  • 因进修,需要学习《Unix 环境高级编程》一书,完全没接触过Unix/Linux,请推荐一个学习环境。
  • 哪有将c程序从HPUNIX环境移植到LINUX环境的资料
  • Linux下怎么搭建QT的环境,QT编程有没IDE?要用QT编程是不是得先编译QT环境?
  • JSP开发环境和运行环境的配置和使用方法,以SUN JDK为例
  • 有哪些中文linux,有哪些外挂的中文环境,这些中文环境之间兼容吗?
  • 想看linux内核源代码,另外手头上有一本《unix环境高级编程》,需要先把《unix环境高级编程》看完之后再看内核吗?


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3