共计 3457 个字符,预计需要花费 9 分钟才能阅读完成。
这篇文章主要介绍 oracle dg 如何安装,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
主备库均为归档模式,并且 force logging
== 开启归档并设为强制日志模式 ==
select log_mode,force_logging from v$database;
alter database archivelog;
alter database force logging;
=== 修改主库参数 ===
alter system set log_archive_config= dg_config=(db01,dg01) scope=both;
alter system set standby_file_management=auto scope=both;
alter system set log_archive_dest_1= location=/oracle/app/oracle/oradata/arch/ valid_for=(all_logfiles,all_roles) db_unique_name=db01 scope=both;
alter system set log_archive_dest_state_1= enable
alter system set log_archive_dest_2= service=dg01 lgwr async valid_for=(online_logfile,primary_role) db_unique_name=dg01 scope=both;
alter system set log_archive_dest_state_2= enable
alter system set fal_server=dg01 scope=both;
alter system set fal_client=db01 scope=both;
alter system set db_file_name_convert= /oracle/app/oracle/oradata/dg01/ , /oracle/app/oracle/oradata/db01/ scope=spfile;
alter system set log_file_name_convert= /oracle/app/oracle/oradata/dg01/ , /oracle/app/oracle/oradata/db01/ scope=spfile;
=== 创建参数文件,修改后用于备库 ===
create pfile= /tmp/tt/initdg01.ora from spfile;
===tnsnames.ora 和监听(两端均为静态监听)===
=== 复制主库准备好的参数文件和密码文件到备库 ===
环境准备好后:
=== 备库利用修改好的参数文件,启动数据库到 nomount 状态 ===
=== 主库操作 ===
rman target / auxiliary sys/oracle@dg01
duplicate target database for standby from active database;
或者
duplicate target database for standby nonamefilecheck from active database;(无需目录转换)
=== 建立 standy log(redolog+1)===
alter database add standby logfile thread 1 group 11 /oracle/app/oracle/oradata/dg01/standby_group_11.log size 52428800;
alter database add standby logfile thread 1 group 12 /oracle/app/oracle/oradata/dg01/standby_group_12.log size 52428800;
alter database add standby logfile thread 1 group 13 /oracle/app/oracle/oradata/dg01/standby_group_13.log size 52428800;
===dg 验证 ===
验证物理备库是否工作:
检查是否存在报错:
select error,destination from v$archive_dest;
(1)在备库上检查已经存在的归档日志
select sequence# , first_time , next_time from v$archived_log order by sequence#;
(2) 在主库上强制进行日志切换,手动归档
alter system switch logfile;
(3) 在备库上检查归档日志 (是否出现新的归档日志)
select sequence# , first_time , next_time from v$archived_log order by sequence#;
(4) 检查归档日志是否被“应用”
select sequence# , applied from v$archived_log order by sequence#;
=== 当备库正在应用日志,把备库启动到只读模式
停掉日志应用
alter database recover managed standby database cancel;
以只读方式打开备库
alter database open;
当数据库处于只读模式,把备库切换到 Redo Apply
1. 让所有活动的会话退出备库
2. 日志应用
alter database recover managed standby database disconnect from session;
或者 (启动 real-time apply)
alter database recover managed standby database using current logfile disconnect from session;
==== 主备切换 ===
1、主库切换到备库
查看主库状态:
select database_role,switchover_status from v$database;
to standby
alter database commit to switchover to physical standby;
备注:
A:switchover_status 出现 session active/not allow
session active 表示还有活动的 session
alter database commit to switchover to physical standby with session shut down;
B:not allow,ora-01153:an incompatible media recovery is active
alter database recover managed standby database finish;
或者
alter database recover managed standby database finish force;
重启主库
shutdown immediate
startup mount
alter database recover managed standby database disconnect from session;
select database_role,switchover_status from v$database;
to primary
2、备库切换到主库
select database_role,switchover_status from v$database;
to primary
alter database commit to switchover to primary;
shutdown immediate;
startup
alter system switch logfile;
重复验证 dg。
=================
注意:
一般 switchover 切换都是计划中的切换,特点是切换后,不会丢失任何数据,而且这个过程是
可逆的,整个 data guard 环境不会被破坏,原来的 data guard 环境中的所有 standby
都可以继续工作。
在进行 data guard 的物理 standby 切换前:
1)确认主从库之间的网络连接畅通;
2)确认没有活动的会话连接在数据库中;
3)primary 数据库处于打开状态,standby 数据库处于 mount 状态。
以上是“oracle dg 如何安装”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注丸趣 TV 行业资讯频道!