rhel6.4-11.2.0.3-RAC如何搭建单节点DG

这篇文章主要为大家展示了“rhel6.4-11.2.0.3-RAC如何搭建单节点DG”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“rhel6.4-11.2.0.3-RAC如何搭建单节点DG”这篇文章吧。

RAC搭建单节点备库ADG(active data guard)
掌握DG的核心思想,不管是单节点-单节点、RAC-单节点还是RAC-RAC,都差不多,本质是一样的,come on
1、/etc/hosts RAC和备机保持一致即可
2、修改数据库为强制日志模式
SQL> select force_logging from v$database
SQL> alter database force logging
3、修改数据库处于归档模式
SQL> select open_mode,log_mode from v$database;
4、在主库上修改参数文件
——————————————————————————-
Primary Database: Primary Role Initialization Parameters
——————————————————————————-
DB_NAME=chicago
DB_UNIQUE_NAME=chicago
LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
CONTROL_FILES='/arch2/chicago/control1.ctl', '/arch3/chicago/control2.ctl'
LOG_ARCHIVE_DEST_1=
 'LOCATION=/arch2/chicago/
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=chicago'
LOG_ARCHIVE_DEST_2=
 'SERVICE=boston ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=boston'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
——————————————————————————-
Primary Database: Standby Role Initialization Parameters
——————————————————————————-
FAL_SERVER=boston
DB_FILE_NAME_CONVERT='boston','chicago'
LOG_FILE_NAME_CONVERT=
 '/arch2/boston/','/arch2/chicago/','/arch3/boston/','/arch3/chicago/'
STANDBY_FILE_MANAGEMENT=AUTO
——————————————————————————-

SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(ora11g,beiku)';
SQL> show parameter LOG_ARCHIVE_DEST_1
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=+data/ora11g/archivelog/ #归档位置可人为指定 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ora11g';
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=beiku ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=beiku';
SQL> alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=spfile;
SQL> alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=spfile;
SQL> alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile;
SQL> show parameter LOG_ARCHIVE_FORMAT                           #  静态参数,重启生效
SQL> alter system set LOG_ARCHIVE_MAX_PROCESSES=30 scope=spfile;
———————————————————–
SQL> alter system set fal_server=beiku scope=spfile;
SQL> alter system set fal_client=ora11g scope=spfile;            #  fal_client设置本身,fal_server是对方,检查归档是否断档
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO SCOPE=SPFILE;    
SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='+data/ora11g/','/oracle/app/beiku/' scope =spfile;    #静态参数,重启生效
SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='+data/ora11g/','/oracle/app/beiku/' scope =spfile;  #静态参数,重启生效
5、配置监听lisener.ora、配置网络服务名tnsnames.ora
通常使用netca来进行配置,特殊情况手工配置
主备机相互验证tnsping service_names
6、将主机$ORACLE_HOME/dbs/下的密码文件orapwORACLE_SID传至备机,可以用ssh/ftp
7、在主机/home/oracle下创建控制文件并且传至备机/home/oracle
SQL> alter database create standby controlfile as '/home/oracle/control01.ctl';
8、在主机/tmp下创建初始化参数文件,并且传至备机$ORACLE_HOME/dbs/下
SQL> create pfile='/tmp/initORACLE_SID.ora' from spfile;
9、修改备机初始化参数文件
——————————————————————————-
Modifying Initialization Parameters for a Physical Standby Database
——————————————————————————-
DB_NAME=chicago
DB_UNIQUE_NAME=boston
LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
CONTROL_FILES='/arch2/boston/control1.ctl', '/arch3/boston/control2.ctl'
DB_FILE_NAME_CONVERT='chicago','boston'
LOG_FILE_NAME_CONVERT=
 '/arch2/chicago/','/arch2/boston/','/arch3/chicago/','/arch3/boston/'
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
LOG_ARCHIVE_DEST_1=
 'LOCATION=/arch2/boston/
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=boston'
LOG_ARCHIVE_DEST_2=
 'SERVICE=chicago ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=chicago'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=chicago
——————————————————————————-
*.audit_file_dest='/oracle/app/admin/beiku/adump'
*.audit_trail='db'
*.cluster_database=false
*.compatible='11.2.0.0.0'
*.control_files='/oracle/app/beiku/control01.ctl', '/oracle/app/beiku/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ora11g'
*.diagnostic_dest='/oracle/app'
*.log_archive_max_processes=30
*.memory_target=1264582656
*.open_cursors=300
*.processes=150
*.remote_listener='node-scan:1521'
*.remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
DB_UNIQUE_NAME=beiku
LOG_ARCHIVE_CONFIG='DG_CONFIG=(ora11g,beiku)'
DB_FILE_NAME_CONVERT='+data/ora11g/','/oracle/app/beiku/'
LOG_FILE_NAME_CONVERT='+data/ora11g/','/oracle/app/beiku/'
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
LOG_ARCHIVE_DEST_1='LOCATION=/arch2/beiku/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=beiku'
LOG_ARCHIVE_DEST_2='SERVICE=ora11g ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ora11g'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=ora11g
——————————————————————————-
10、在主机做数据库的备份集并且把备份集传至备机/home/oracle
[oracle@node2 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 – Production on Fri Jul 10 15:21:21 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORA11G (DBID=4275958693)

RMAN> backup database format  '/home/oracle/racfull_%s_%p';
11、在备机用RMAN做复制STANDBY数据库操作
注:要用用户名和密码(sys/oracle)连接主库和备库
[oracle@jason ~]$ rman target sys/oracle@ora11g auxiliary sys/oracle

Recovery Manager: Release 11.2.0.3.0 – Production on Fri Jul 10 14:13:15 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORA11G (DBID=4275958693)
connected to auxiliary database: ORA11G (not mounted) #备库启到nomount阶段,实例已经起来

RMAN> duplicate target database for standby;

Starting Duplicate Db at 10-JUL-15
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK

contents of Memory Script:
{
   restore clone standby controlfile;
}
executing Memory Script

Starting restore at 10-JUL-15
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/racfull_8_1
channel ORA_AUX_DISK_1: piece handle=/home/oracle/racfull_8_1 tag=TAG20150710T122559
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oracle/app/beiku/control01.ctl
output file name=/oracle/app/beiku/control02.ctl
Finished restore at 10-JUL-15

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
   set newname for tempfile  1 to
 "/oracle/app/beiku/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/oracle/app/beiku/system01.dbf";
   set newname for datafile  2 to
 "/oracle/app/beiku/sysaux01.dbf";
   set newname for datafile  3 to
 "/oracle/app/beiku/undotbs01.dbf";
   set newname for datafile  4 to
 "/oracle/app/beiku/users01.dbf";
   set newname for datafile  5 to
 "/oracle/app/beiku/undotbs02.dbf";
   set newname for datafile  6 to
 "/oracle/app/beiku/jason01.dbf";
   restore
   clone database
   ;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /oracle/app/beiku/temp01.dbf in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 10-JUL-15
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /oracle/app/beiku/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oracle/app/beiku/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oracle/app/beiku/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oracle/app/beiku/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /oracle/app/beiku/undotbs02.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /oracle/app/beiku/jason01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/racfull_7_1
channel ORA_AUX_DISK_1: piece handle=/home/oracle/racfull_7_1 tag=TAG20150710T122559
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 10-JUL-15

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=884700883 file name=/oracle/app/beiku/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=11 STAMP=884700883 file name=/oracle/app/beiku/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=884700883 file name=/oracle/app/beiku/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=884700883 file name=/oracle/app/beiku/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=884700883 file name=/oracle/app/beiku/undotbs02.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=15 STAMP=884700883 file name=/oracle/app/beiku/jason01.dbf
Finished Duplicate Db at 10-JUL-15

RMAN>
结束后会自动将备库启到mount状态
SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
—————- ————
beiku            MOUNTED
打开备库,此时备库正处在最大性能模式
SQL> alter database open read only;     #11gDG已经可以在open的状态下应用归档

Database altered.

SQL> select protection_mode,database_role,open_mode from v$database;

PROTECTION_MODE      DATABASE_ROLE    OPEN_MODE
——————– —————- ——————–
MAXIMUM PERFORMANCE  PHYSICAL STANDBY READ ONLY

SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL> select sequence#,thread#,applied from v$archived_log;  #在主库双节点分别切换日志alter system switch logfile,在备库显示如下,DG已运行正常

 SEQUENCE#    THREAD# APPLIED
———- ———- ———
       121          1 YES
       119          1 YES
       120          1 YES
       118          1 YES
       122          1 YES
       151          2 YES
       149          2 YES
       150          2 YES
       152          2 YES
       153          2 YES
       154          2 YES

 SEQUENCE#    THREAD# APPLIED
———- ———- ———
       155          2 YES
       156          2 YES
       157          2 YES
       123          1 YES
       158          2 YES
       159          2 YES
       160          2 YES
       161          2 YES
       162          2 YES
       163          2 YES
       164          2 YES

 SEQUENCE#    THREAD# APPLIED
———- ———- ———
       124          1 YES
       125          1 YES
       126          1 YES
       165          2 YES
       127          1 YES
       128          1 YES
12、配置DG为最大可用模式
在备库要创建STANDBY REDO LOGFILE
SQL> select group#,member from v$logfile;

    GROUP# MEMBER
———- ————————————————–
         2 /oracle/app/beiku/redo02.log
         1 /oracle/app/beiku/redo01.log
         3 /oracle/app/beiku/redo03.log
         4 /oracle/app/beiku/redo04.log
SQL> alter database add standby logfile group 5 ('/oracle/app/beiku/standby_redo05.log')  size 50m;
SQL> alter database add standby logfile group 6 ('/oracle/app/beiku/standby_redo06.log')  size 50m;
SQL> alter database add standby logfile group 7 ('/oracle/app/beiku/standby_redo07.log')  size 50m;
SQL> alter database add standby logfile group 8 ('/oracle/app/beiku/standby_redo08.log')  size 50m;
SQL> alter database add standby logfile group 9 ('/oracle/app/beiku/standby_redo09.log')  size 50m;
SQL> alter database set standbydatabase to maximize availability;
SQL> alter database recover managedstandby database using current logfile disconnect from session;  #启动实时恢复
SQL>alter database recover managed standby database cancel;

以上是“rhel6.4-11.2.0.3-RAC如何搭建单节点DG”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/201831.html

(0)
上一篇 2021年11月25日
下一篇 2021年11月25日

相关推荐

发表回复

登录后才能评论