[terry笔记]11gR2_DataGuard搭建_primary零停机
11gR2搭建dataguard环境,此篇文章是利用rman搭建dataguard,这样的好处是primary不用停机,当然,前提条件是primary已经开启归档。
相对于可以停机,零停机传送数据文件的方式,不能冷备然后拷贝数据文件,只能利用rman技术备份,并恢复至standby中,当然rman备份恢复我只用了最简单的一种,一条命令备份,两条命令恢复。
可以参考拷贝数据文件方式:http://www.cnblogs.com/kkterry/p/3819322.html
主备切换、模式调整等实验会在以后更新。
环境信息介绍:
primary(正在运行,已经开启归档,可正常交易):
OS:OEL6.
database:11.2.0.4.
hostname:node4
192.168.100.131
ORACLE_SID=good
ORACLE_HOME=/u01/product/11.2.
db_unique_name=good standby(装好database软件):
OS:OEL6.
database:11.2.0.4.
hostname:node5
192.168.100.132
ORACLE_SID=good
ORACLE_HOME=/u01/product/11.2.
db_unique_name=bad 两边oracle用户的环境变量:
export ORACLE_BASE=/u01
export ORACLE_HOME=$ORACLE_BASE/product/11.2.
export ORACLE_SID=good
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
alias s='sqlplus / as sysdba'
1. primary已经处于归档状态(归档目录/u01/arch),然后打开force logging:
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/arch
Oldest online log sequence 24
Next log sequence to archive 26
Current log sequence 26
alter database force logging;
2. 配置listener与tnsnames,然后传至standby
(primary可以是动态监听,但是standby需要静态监听,因为动态监听需要数据库启动至mount状态才能监听得到。standby目前只有软件,没有实例,所以动态监听无法向外提供服务,以至于primary无法连接至standby的库,导致无法测试连通性,并向向standby传递归档)
listner.ora:
# listener.ora Network Configuration File: /u01/product/11.2./network/admin/listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/product/11.2.)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = good)
(ORACLE_HOME = /u01/product/11.2.)
(SID_NAME = good)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = ))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
) ADR_BASE_LISTENER = /u01
tnsnames.ora:
# tnsnames.ora Network Configuration File: /u01/product/11.2./network/admin/tnsnames.ora
# Generated by Oracle configuration tools. GOOD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.131)(PORT = ))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = good)
)
) BAD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.132)(PORT = ))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = good)
)
)
3.两边打开监听
lsnrctl start
此时可以测试两边是否连通
sqlplus sys/xxx@good as sysdba
sqlplus sys/xxx@bad as sysdba
4.配置primary参数,并添加standby logfile,以用来将来主备切换,standby logfile要比redo多一个组
此时的primary参数文件,里面没有相关dg的参数。 good.__db_cache_size=205520896
good.__java_pool_size=4194304
good.__large_pool_size=8388608
good.__oracle_base='/u01'#ORACLE_BASE set from environment
good.__pga_aggregate_target=209715200
good.__sga_target=343932928
good.__shared_io_pool_size=0
good.__shared_pool_size=113246208
good.__streams_pool_size=0
*.audit_file_dest='/u01/admin/good/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/oradata/good/control01.ctl','/u01/fast_recovery_area/good/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='good'
*.db_recovery_file_dest='/u01/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=goodXDB)'
*.memory_target=550502400
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
*.log_archive_dest_1='location=/u01/arch'
运行如下命令:具体参数含义在文章最后的附录表中,也可以查询官方文档,解释的更详细。
(不用设置primary的db_unique_name,默认就有) alter system set log_archive_config= 'DG_CONFIG=(good,bad)'; alter system set log_archive_dest_1= 'LOCATION=/u01/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=good'; alter system set log_archive_dest_2= 'SERVICE=bad LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=bad'; alter system set log_archive_dest_state_1 = enable; alter system set log_archive_dest_state_2 = enable; alter system set fal_server=bad; alter system set fal_client=good; alter system set standby_file_management=AUTO;
添加standby redo:
alter database add standby logfile
group 4 ('/u01/oradata/good/standby04.log')size 50m,
group 5 ('/u01/oradata/good/standby05.log')size 50m,
group 6 ('/u01/oradata/good/standby06.log')size 50m,
group 7 ('/u01/oradata/good/standby07.log')size 50m;
5.创建standby controlfile、pfile
alter database create standby controlfile as '/u01/control01.ctl'; create pfile from spfile;
6.利用rman备份primary,做全备即可
rman target / backup database format '/u01/backup/full_%U';
7.把相关文件从primary传递至standby
监听文件:listener.ora、tnsnames.ora --$ORACLE_HOME/network/admin(在之前已经传过去了) 参数文件:initgood.ora --$ORACLE_HOME/dbs 密码文件:orapwgood --$ORACLE_HOME/dbs sty控制文件:control01.ctl --$ORACLE_BASE/oradata/good 日志目录(或直接创建文件夹):$ORACLE_BASE/admin、$ORACLE_BASE/diag、$ORACLE_BASE/flash_recovery_area --$ORACLE_BASE 备份文件:/u01/backup/* --/u01/backup/
8.修改standby参数文件,重点注意蓝色的参数,绿色是重点要修改的。
good.__db_cache_size=222298112
good.__java_pool_size=4194304
good.__large_pool_size=8388608
good.__oracle_base='/u01'#ORACLE_BASE set from environment
good.__pga_aggregate_target=192937984
good.__sga_target=360710144
good.__shared_io_pool_size=0
good.__shared_pool_size=113246208
good.__streams_pool_size=0
*.audit_file_dest='/u01/admin/good/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/oradata/good/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='good'
*.db_recovery_file_dest='/u01/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.db_unique_name='bad'
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=goodXDB)'
*.fal_client='bad'
*.fal_server='good‘
*.log_archive_config='dg_config=(good,bad)'
*.log_archive_dest_1='location=/u01/arch valid_for=(all_logfiles,all_roles) db_unique_name=bad'
*.log_archive_dest_2='service=good lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=good'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.memory_target=550502400
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
9.standby启动至mount,然后rman恢复
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 2 20:32:36 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance. SQL> startup nomount
ORACLE instance started. Total System Global Area 551165952 bytes
Fixed Size 2255112 bytes
Variable Size 385877752 bytes
Database Buffers 155189248 bytes
Redo Buffers 7843840 bytes SQL> alter database mount;
Database altered. SQL> exit
[oracle@node5 dbs]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jul 2 20:33:57 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: GOOD (DBID=1820366808, not open) RMAN> catalog start with '/u01/backup/'; Starting implicit crosscheck backup at 02-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=14 device type=DISK
Crosschecked 2 objects
Finished implicit crosscheck backup at 02-JUL-14 Starting implicit crosscheck copy at 02-JUL-14
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 02-JUL-14 searching for all files in the recovery area
cataloging files...
no files cataloged searching for all files that match the pattern /u01/backup/ List of Files Unknown to the Database
=====================================
File Name: /u01/backup/full_03pcdktt_1_1
File Name: /u01/backup/full_04pcdkvl_1_1 Do you really want to catalog the above files (enter YES or NO)? yes cataloging files...
cataloging done List of Cataloged Files
=======================
File Name: /u01/backup/full_03pcdktt_1_1
File Name: /u01/backup/full_04pcdkvl_1_1 RMAN> restore database; Starting restore at 02-JUL-14
using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/oradata/good/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/good/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oradata/good/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/good/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/full_03pcdktt_1_1
channel ORA_DISK_1: piece handle=/u01/backup/full_03pcdktt_1_1 tag=TAG20140702T202533
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 02-JUL-14
此时standby的/u01/arch会出现归档。
可以在primary进行alter system switch logfile测试,归档必须同时出现在两端,这点很重要,不然standby无法进行恢复。
10.standby应用日志
alter database recover managed standby database using current logfile disconnect from session;
11.验证
观察primary与standby的/u01/arch
primary:alter system switch logfile;
SELECT STATUS,DESTINATION, ERROR FROM V$ARCHIVE_DEST;
select sequence#,status from v$archived_log;--主备一致
14.standby可以选择是否启动read only with apply
如果启动可以在standby库进行查询,同时从primary日志恢复(此为11g特性,10g如果read only打开standby库,不可以同时恢复)
alter database recover managed standby database cancel; alter database open; alter database recover managed standby database using current logfile disconnect from session; select open_mode from v$database;
到这里可以算是完成了,可以正常登录主库、备库进行数据查询。
15.此时会发现一个现象,v$logfile中的文件可以查询得到,但是文件并不存在,这种情况可以忽略,主备互转的时候会自动创建。
SQL> col member for a30
SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------ ---
3 ONLINE /u01/oradata/good/redo03.log NO
2 ONLINE /u01/oradata/good/redo02.log NO
1 ONLINE /u01/oradata/good/redo01.log NO
4 STANDBY /u01/oradata/good/redo04.log NO
5 STANDBY /u01/oradata/good/redo05.log NO
6 STANDBY /u01/oradata/good/redo06.log NO
7 STANDBY /u01/oradata/good/redo07.log NO 7 rows selected.
参数附录:
角色 |
参数名称 |
介绍 |
Pri |
DB_NAME |
数据库名称,primary端和standby端必须相同 |
DB_UNIQUE_NAME |
指定唯一名称,区别primary端和 standby端 |
|
LOG_ARCHIVE_CONFIG |
指定DG的全局日志配置,包含所有数据库的名称,及归档路径 |
|
CONTROL_FILES |
控制文件路径及名称 |
|
LOG_ARCHIVE_DEST_n |
指定主备库的归档路径 |
|
LOG_ARCHIVE_DEST_STATE_n |
配置是否允许通过redo进行日志传输及路径 |
|
REMOTE_LOGIN_PASSWORDFILE |
配置远程登陆模式,是否独享还是共享 |
|
LOG_ARCHIVE_FORMAT |
配置归档日志文件存储格式规范 |
|
LOG_ARCHIVE_MAX_PROCESS=integer |
配置归档进程数量,默认为4 |
|
FAL_SERVER |
配置服务器角色 |
|
DB_FILE_NAME_CONVERT |
配置数据库数据文件转换,用在主备库数据文件路径不一致 |
|
LOG_FILE_NAME_CONVERT |
配置数据库redo日志文件转换,用在主备库redo日志文件路径不一致 |
|
STANDBY_FILE_MANAGEMENT |
配置备库是否同步主库的表空间添加或数据文件添加。 |
|
st |
DB_UNIQUE_NAME |
指定唯一名称,区别pri 端和 sty端 |
CONTROL_FILES |
控制文件路径及名称 |
|
DB_FILE_NAME_CONVERT |
配置数据库数据文件转换,用在主备库数据文件路径不一致 |
|
LOG_FILE_NAME_CONVERT |
配置数据库数据文件转换,用在主备库数据文件路径不一致 |
|
LOG_ARCHIVE_DEST_n |
指定主备库的归档路径 |
|
FAL_SERVER |
配置服务器角色 |
[terry笔记]11gR2_DataGuard搭建_primary零停机的更多相关文章
- [terry笔记]11gR2_DataGuard搭建_拷贝数据文件
11gR2搭建dataguard环境: 自己做的实验,后续按照rman模式搭建.主备切换.模式调整等实验会陆续发上来. primary: OS:oel 6.4 database:11.2.0.4.0 ...
- [terry笔记]RMAN综合学习之恢复
[terry笔记]RMAN综合学习之备份http://www.cnblogs.com/kkterry/p/3308405.html [terry笔记]RMAN综合学习之恢复 http://www.cn ...
- [terry笔记]RMAN综合学习之备份
rman是最经济实惠的oracle备份工具,在这里做一个rman的整体学习. 文章中大多是rman命令的语法,还是最好做做实验,以便印象深刻,因为大多数数据库的备份就是按时跑脚本,恢复也不是经常能遇到 ...
- [terry笔记]RMAN综合学习之配置
[terry笔记]RMAN综合学习之备份http://www.cnblogs.com/kkterry/p/3308405.html [terry笔记]RMAN综合学习之恢复 http://www.cn ...
- [terry笔记]Oracle会话追踪(二):TKPROF
接上一笔记[terry笔记]Oracle会话追踪(一):SQL_TRACE&EVENT 10046 http://www.cnblogs.com/kkterry/p/3279282.html ...
- [terry笔记]Oracle会话追踪(一):SQL_TRACE&EVENT 10046
SQL_TRACE/10046 事件是 Oracle 提供的用于进行 SQL 跟踪的手段,在日常的数据库问题诊断和解决中是非常常用的方法.但其生成的trace文件需要tkprof工具生成一个可供人 ...
- 详解k8s零停机滚动发布微服务 - kubernetes
1.前言 在当下微服务架构盛行的时代,用户希望应用程序时时刻刻都是可用,为了满足不断变化的新业务,需要不断升级更新应用程序,有时可能需要频繁的发布版本.实现"零停机"." ...
- DevOps之零停机部署
“零停机部署(ZDD)可在不中断现有服务的情况下部署新版系统.” 通过ZDD方式部署应用程序时,可在确保用户不会遭遇应用程序停机的前提下将新版应用引入生产环境.从用户和公司的角度来看,这应该是最佳部署 ...
- Hadoop学习笔记(10) ——搭建源码学习环境
Hadoop学习笔记(10) ——搭建源码学习环境 上一章中,我们对整个hadoop的目录及源码目录有了一个初步的了解,接下来计划深入学习一下这头神象作品了.但是看代码用什么,难不成gedit?,单步 ...
随机推荐
- 【XSY2692】杨柳 - 网络流
题目来源:2018冬令营模拟测试赛(十) 题解: 继续鬼畜网络流…… 首先这题有个显然的做法:bfs预处理出每个起点到每个终点的最短步数,然后直接建边加超级源汇跑费用流即可: 但是这样边数是$n^2$ ...
- freeswitch 一些坑
1.You must install libopus-dev to build mod_opus. Stop. 确实已经安装libopus-dev后 将文件 usr/local/src/mod/cod ...
- man帮助命令
linux系统提供可比较丰富的帮助手册,man是manual(说明书)的缩写,在日常的linux系统管理中经常会用到. 语法: man(选项)(参数) 选项: -a:在所有的man帮助手册中搜索: - ...
- Python学习笔记(6)元组
2019-03-02 元组(tuple): (1)元组是不可变的,无法进行任意修改.插入.删除一个元素. (2)创建元组大部分时候用小括号,如果创建的元组中只有一个元素,需要在它的后面加上一个逗号. ...
- hbase的几种访问方式
Hbase的访问方式 1.Native Java API:最常规和高效的访问方式: 2.HBase Shell:HBase的命令行工具,最简单的接口,适合HBase管理使用: 3.Thrift Gat ...
- SQL SERVER-identity | @@identity | scope_identity
主键自增 IDENTITY(1,1),MS SQL Server 使用 IDENTITY 关键字来执行 auto-increment 任务. 在上面的实例中,IDENTITY 的开始值是 1,每条新记 ...
- .C#-NET开源方向基本
我的理解,nancyFx是一个.net的微型框架,可以在Linux环境下运行,ServiceStack也是全平台框架,更大一些 owin的概念:Open Web Server Interface Fo ...
- [Javascript] Delegate JavaScript (ES6) generator iteration control
We can execute generators from generators, and delegate the iteration control with the yield* keywor ...
- oracle 10g/11g 命令对照,日志文件夹对照
oracle 10g/11g 命令对照,日志文件夹对照 oracle 11g 中不再建议使用的命令 Deprecated Command Replacement Commands crs_st ...
- 黑马day14 过滤器概述&生命周期&运行过程
过滤器:当訪问一个web资源的时候,过滤器就在你訪问这个web资源的前进行拦截...在放行过后...filter过滤器也能够做一些其它的事情. 编写过滤器的步骤: 1.写一个过滤器类实现filter接 ...