oracle-11g-配置dataguard
1、环境信息:
系统:
oracle-linux 5.7
数据库版本:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
主库:192.168.12.31 SID:yoon db_unique_name:yoon
备库:192.168.12.231 SID:yoon db_unique_name:yoondg
2、查看DG是否已经安装:
SQL> select * from v$option where parameter = 'Oracle Data Guard';
PARAMETER VALUE
-------------------- --------------------
Oracle Data Guard TRUE
TRUE表示已经安装可以配置,否则需要安装相应软件
3、查看主库是否开启归档:
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Current log sequence 6
4、设置主库为归档模式:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2505338880 bytes
Fixed Size 2230952 bytes
Variable Size 553649496 bytes
Database Buffers 1946157056 bytes
Redo Buffers 3301376 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Next log sequence to archive 6
Current log sequence 6
5、设置主库为强制记录日志:
SQL> alter database force logging;
Database altered.
6、创建standy log files:
SQL> select group#,member from v$logfile;
GROUP# MEMBER
------- -----------------------------------
3 /opt/oracle/oradata/yoon/redo03.log
2 /opt/oracle/oradata/yoon/redo02.log
1 /opt/oracle/oradata/yoon/redo01.log
添加:
SQL> alter database add standby logfile group 7 '/opt/oracle/oradata/yoon/standby07.log' size 50m;
Database altered.
SQL> alter database add standby logfile group 8 '/opt/oracle/oradata/yoon/standby08.log' size 50m;
Database altered.
SQL> alter database add standby logfile group 9 '/opt/oracle/oradata/yoon/standby09.log' size 50m;
Database altered.
SQL> alter database add standby logfile group 10 '/opt/oracle/oradata/yoon/standby10.log' size 50m;
Database altered.
7、创建standby控制文件:
SQL> shutdown immediate
SQL> startup mount
SQL> alter database create standby controlfile as '/opt/oracle/oradata/yoon/standby_control01.ctl';
Database altered.
SQL>alter database open;
8、设置db_unique_name:
默认db_name和db_unique_name是一样的,主库是yoon
在配置DG中主库和备库的SID可以一样,But,db_unique_name不能相同,备库设置为:yoondg
SQL> show parameter db_unique_name;
NAME TYPE VALUE
------------------------------------ ---------- ------------------------------
db_unique_name string yoon
--注意虽然默认db_unique_name和db_name是一致的,但是需要显式设置,否则在spfile中没有此参数
SQL> alter system set db_unique_name=yoon scope=spfile;
System altered.
9、配置主库listener.ora:
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = yoon)
(ORACLE_HOME = /opt/oracle/product/11.2.0/db_1/)
(SID_NAME = yoon)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
配置tnsnames.ora
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
YOON =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoon)
)
)
YOONDG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoondg)
)
)
10、将主库listener.ora和tnsnames.ora拷贝到备库修改
[root@1231 admin]# scp listener.ora tnsnames.ora oracle@192.168.12.231:/opt/oracle/product/11.2.0/db_1/network/admin/
配置listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = yoon)
(ORACLE_HOME = /opt/oracle/product/11.2.0/db_1/)
(SID_NAME = yoon)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
配置tnsnames.ora
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
YOONDG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoondg)
)
)
YOON =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoon)
)
)
11、配置完以后在主和备的oralce用户下测试下是否能ping通
主:
[oracle@1231 ~]$ tnsping yoon
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoon)))
OK (0 msec)
[oracle@1231 ~]$ tnsping yoondg
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoondg)))
OK (10 msec)
备:
[oracle@12231 ~]$ tnsping yoon
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoon)))
OK (0 msec)
[oracle@12231 ~]$ tnsping yoondg
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoondg)))
OK (0 msec)
12、重做日志传输配置
a.配置归档日志位置:
SQL> alter system set log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoon' scope=spfile;
System altered.
b.配置重做日志到备份库:
SQL> alter system set log_archive_dest_2='service=yoondg lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoondg' scope=spfile;
System altered.
13、配置FAL_SERVER
主:
SQL> alter system set fal_server='yoondg';
System altered.
14、Data Guard 配置里的另外一个库的名字
SQL> alter system set log_archive_config='dg_config=(yoon,yoondg)';
System altered.
SQL> alter system set log_archive_dest_state_1=enable scope=spfile;
System altered.
SQL> alter system set log_archive_dest_state_2=enable scope=spfile;
System altered.
SQL> create pfile from spfile;
File created.
SQL> create spfile from pfile;
File created.
15、查看主库inityoon.ora信息
yoon.__db_cache_size=1946157056
yoon.__java_pool_size=16777216
yoon.__large_pool_size=16777216
yoon.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
yoon.__pga_aggregate_target=838860800
yoon.__sga_target=2516582400
yoon.__shared_io_pool_size=0
yoon.__shared_pool_size=520093696
yoon.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/yoon/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/oracle/oradata/yoon/control01.ctl','/opt/oracle/fast_recovery_area/yoon/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yoon'
*.db_recovery_file_dest='/opt/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='YOON'
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=yoonXDB)'
*.fal_server='yoondg'
*.log_archive_config='dg_config=(yoon,yoondg)'
*.log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoon'
*.log_archive_dest_2='service=yoondg lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoondg'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.open_cursors=300
*.pga_aggregate_target=837812224
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.sga_target=2514485248
*.undo_tablespace='UNDOTBS1'
16、将主库的数据文件、控制文件、参数文件、密码文件拷贝到备库对应的目录
[root@1231 oracle]# scp -r admin/ fast_recovery_area/ oradata/ oracle@192.168.12.231:/opt/oracle/
17、修改备库参数文件
yoon.__db_cache_size=1946157056
yoon.__java_pool_size=16777216
yoon.__large_pool_size=16777216
yoon.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
yoon.__pga_aggregate_target=838860800
yoon.__sga_target=2516582400
yoon.__shared_io_pool_size=0
yoon.__shared_pool_size=520093696
yoon.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/yoon/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/oracle/oradata/yoon/control01.ctl','/opt/oracle/fast_recovery_area/yoon/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yoon'
*.db_recovery_file_dest='/opt/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='YOONDG'
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=yoonXDB)'
*.fal_server='yoon'
*.log_archive_config='dg_config=(yoondg,yoon)'
*.log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoondg'
*.log_archive_dest_2='service=yoon lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoon'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.open_cursors=300
*.pga_aggregate_target=837812224
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.sga_target=2514485248
*.undo_tablespace='UNDOTBS1'
18、在备库通过pfile创建spfile
19、删除备库的控制文件control01.ctl和control02.ctl
将standby_control01.ctl替换成control01.ctl和control02.ctl
20、启动备库
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2505338880 bytes
Fixed Size 2230952 bytes
Variable Size 553649496 bytes
Database Buffers 1946157056 bytes
Redo Buffers 3301376 bytes
SQL>
SQL> alter database mount standby database;
Database altered.
启用redo应用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
停止standby
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL>shutdown immediate;
21、备用服务器的管理模式与只读模式
a.启动到管理模式
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;
b.启动到只读模式
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
SQL> alter database open read only;
c.在管理恢复模式下到只读模式
SQL> recover managed standby database cancel;
SQL> alter database open read only;
d.从只读方式到管理恢复方式
SQL> recover managed standby database disconnect from session;
22、DG启动:
监听:先起备库再起主库
数据库:先起备库再起主库
关闭:与启动相反.
oracle-11g-配置dataguard的更多相关文章
- Oracle 11g 物理Dataguard日常操作维护(二)
Oracle 11g 物理Dataguard日常操作维护(二) 2017年8月25日 14:34 3.3 3.3.1 查看备库进程状态 SYS(125_7)@fpyj123> select pr ...
- oracle 11g 配置口令复杂度
oracle 11g 配置口令复杂度 使用ORACLE自带的utlpwdmg.sql脚本来实现 找到本地的utlpwdmg.sql脚本 find / -name utlpwdmg.sql 查看 /ho ...
- ORACLE 11G 配置DG 报ORA-10458、ORA-01152、ORA-01110
操作系统: Oracle Linux Server release 5.7 数据库版本: Oracle Database 11g Enterprise Edition Release 11.2.0.3 ...
- oracle 11G 配置侦听文件
lsnrctl status 130 2017-08-23 03:15:16 oracle cat /etc/hosts 131 2017-08-23 03:15:26 oracle ca ...
- 【Oracle】Oracle安装配置、创建数据库实例及用户和连接
https://blog.csdn.net/wudiyong22/article/details/78904361 参考资料:https://www.cnblogs.com/hoobey/p/6010 ...
- Oracle 11g dataguard check RTA(real time apply)
Oracle 11g dataguard check RTA(real time apply) 2017年8月24日 16:38 环境:oracle 11.2.0.1 OEL 5.8 注:以下操作都在 ...
- Oracle 11g DataGuard搭建(一) - 单节点到单节点
(一)DataGuard概要 DataGuard中文称为”数据卫士“,提供了数据库高可用性.数据保护和灾难恢复的功能.DataGuard通过建立primary数据库和standby数据库来确立参照关系 ...
- Oracle 11g Dataguard参数详解
https://www.jb51.net/article/52269.htm注:本文译自<Oracle Data Guard 11g Handbook> Page 78 – Page 88 ...
- Linux平台oracle 11g单实例 安装部署配置 快速参考
1.重建主机的Oracle用户 组 统一规范 uid gid 以保证共享存储挂接或其他需求的权限规范 userdel -r oracle groupadd -g 7 oinstall groupadd ...
- Oracle 11g DG配置简明版
环境: 主库A机:在线生产环境,RHEL 6.4 + Oracle 11.2.0.3 备库B机:新增备机,RHEL 6.4 需求: 对生产环境最小影响前提下配置DG备库. 目录: 一.B机安装相同版本 ...
随机推荐
- http://www.cnblogs.com/
<?php $filename = $_GET['filename']; header("Content-type: application/octet-stream"); ...
- Java基础--访问权限控制符
今天我们来探讨一下访问权限控制符. 使用场景一:攻城狮A编写了ClassA,但是他不想所有的攻城狮都可以使用该类,应该怎么办? 使用场景二:攻城狮A编写了ClassA,里面有func1方法和func2 ...
- 剑指Offer23 二叉树中和为sum的路径
/************************************************************************* > File Name: 23_FindPa ...
- 浅析js中的this
this的用法 this在日常javascript编码中很常见, 但是一直以来没有好好总结过. 今天在这里好好总结一下. 本文只讨论浏览器环境. this指向全局 var name = "w ...
- MongoDB - The mongo Shell, Data Types in the mongo Shell
MongoDB BSON provides support for additional data types than JSON. Drivers provide native support fo ...
- .Net简单上传与下载
上传: 首先上传我们需要一个控件-FileUpLoad: 再加上一个上传按钮: 在上传按钮的Click事件中添加如下代码: FileUpload1.SaveAs(Server.MapPath(&quo ...
- POJ1064
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int N ...
- jQuery插件的编写和使用 <思维导图>
以下是jQuery插件的编写和使用的思维导图,全屏观看,请点击:jQuery插件的编写和使用
- GIT Learning
一.Why Git 1.1 Git是分布式的,本地的版本管理 chect out代码后会在自己的机器上克隆一个自己的版本库,即使你在没有网络的环境,你仍然能够提交文件,查看历史版本记录,创建项目分支, ...
- PropertyGrid排序
解决PropertyGrid对自定义属性排序的问题. 参考了:http://www.cnblogs.com/greatverve/archive/2012/02/08/propergrid-order ...