oracle ADG for windows install steps
admin
2023-02-06 17:40:04
0

环境介绍:
windows 2012 R2*2台
主库:安装oracle软件、监听、实例
备库:安装oracle软件、监听
数据库版本:11.2.0.4
主库:orcl
备库:prod

1、主库
create pfile='C:\Users\Administrator\Desktop\file\pfile.ora' from spfile;
alter database force logging;

alter system set log_archive_config='DG_CONFIG=(orcl,prod)' scope=spfile;
alter system set log_archive_dest_1='location=C:\app\archive valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl' scope=both sid='';
alter system set log_archive_dest_2='service=prod LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=prod' scope=both sid='
';
alter system set log_archive_dest_state_1='enable' scope=both sid='';
alter system set log_archive_dest_state_2='enable' scope=both sid='
';
alter system set fal_client='orcl' scope=both sid='';
alter system set fal_server='prod' scope=both sid='
';
alter system set standby_file_management='AUTO' scope=both sid='';
alter system set db_file_name_convert='C:\app\datafiles\orcl\','C:\app\datafiles\prod\' scope=spfile sid='
';
alter system set log_file_name_convert='C:\app\datafiles\orcl\','C:\app\datafiles\prod\' scope=spfile sid='*';

SQL> create pfile='C:\Users\Administrator\Desktop\file\pfilebak.ora' from spfile;

2、备库创建目录
归档目录 C:\app\archive
数据文件目录 C:\app\datafiles\prod\
adump目录 C:\app\Administrator\admin\prod\adump

3、主库备份
rman target /
run{
allocate channel a1 device type disk;
allocate channel a2 device type disk;
allocate channel a3 device type disk;
crosscheck archivelog all;
sql 'alter system archive log current';
sql 'alter system archive log current';
backup full database format='C:\Users\Administrator\Desktop\file\full%U%T' include current controlfile for standby;
backup current controlfile for standby format 'C:\Users\Administrator\Desktop\file\control01.ctl';
backup archivelog all format 'C:\Users\Administrator\Desktop\file\arch
%d%T%U.arc';
release channel a1;
release channel a2;
release channel a3;
}

4、拷贝文件
密码文件在$ORACLE_HOME/database
将密码文件(需要改sid)、pfile、redo、temp、拷贝到备库相应目录。

5、修改host文件
192.168.3.2 WIN-JP7MSEND1SD
192.168.3.3 WIN-KL9BBQ52F5R

6、主备库tnsnames一致

7、修改备库pfile文件
更改pfile文件
db_name='orcl'应与主库一致
.db_unique_name='prod'
.audit_file_dest='C:\app\Administrator\admin\prod\adump' 注意路径
log_archive_dest_1='C:\app\archive'
.db_recovery_file_dest
oracle_base
删除log_archive_dest_2、log_archive_dest_state_1
修改
fal_client='prod'
.fal_server='orcl'
.log_archive_config='DG_CONFIG=(orcl,prod)'
.log_archive_dest_1='location=C:\app\archive valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=prod'

*检查文件中的路径是否正确***

8、备库添加服务
oradim -new -sid prod -startmode auto
set ORACLE_SID=prod

9、恢复备库
sql>startup nomount pfile='C:\Users\Administrator\Desktop\file\pfilebak.ora';
sql>create spfile from pfile='C:\Users\Administrator\Desktop\file\pfilebak.ora';
若有需求更改数据文件目录可通过
rman target / nocatalog
RMAN> restore standby controlfile from 'C:\Users\Administrator\Desktop\file\control01.ctl';
SQL>alter database mount;
catalog start with 'C:\Users\Administrator\Desktop\file\';

run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
set newname for datafile 1 to 'C:\app\datafiles\prod\system01.dbf';
set newname for datafile 2 to 'C:\app\datafiles\prod\sysaux01.dbf';
set newname for datafile 3 to 'C:\app\datafiles\prod\undotbs01.dbf';
set newname for datafile 4 to 'C:\app\datafiles\prod\users01.dbf';
set newname for datafile 5 to 'C:\app\datafiles\prod\example01.dbf';
restore database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
recover database;

10、主备库添加standby日志(比online log至少多一个)
主库
alter database add standby logfile thread 1 group 4('C:\app\datafiles\orcl\standby04.log') size 50M;
alter database add standby logfile thread 1 group 5 ('C:\app\datafiles\orcl\standby05.log') size 50M;
alter database add standby logfile thread 1 group 6 ('C:\app\datafiles\orcl\standby06.log') size 50M;
alter database add standby logfile thread 1 group 7 ('C:\app\datafiles\orcl\standby07.log') size 50M;
alter database add standby logfile thread 1 group 8 ('C:\app\datafiles\orcl\standby08.log') size 50M;
备库
alter database add standby logfile thread 1 group 4('C:\app\datafiles\prod\standby04.log') size 50M;
alter database add standby logfile thread 1 group 5 ('C:\app\datafiles\prod\standby05.log') size 50M;
alter database add standby logfile thread 1 group 6 ('C:\app\datafiles\prod\standby06.log') size 50M;
alter database add standby logfile thread 1 group 7 ('C:\app\datafiles\prod\standby07.log') size 50M;
alter database add standby logfile thread 1 group 8 ('C:\app\datafiles\prod\standby08.log') size 50M;

11、主库重启DB 因为log_archive_config重启生效

启动同步
SQL>alter database recover managed standby database disconnect from session;
SQL> recover managed standby database cancel;
SQL>alter database open read only;
SQL>alter database recover managed standby database using current logfile disconnect from session;

验证
主库 v$archived_log
SQL> select thread#,max(sequence#) from v$archived_log where applied='NO' group by thread#;

备库 v$archived_log
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;

备库 v$managed_standby;
select process,status,thread#,sequence# from v$managed_standby;
SQL> select process,status,thread#,sequence# from v$managed_standby;

PROCESS STATUS THREAD# SEQUENCE#


ARCH CONNECTED 0 0
ARCH CONNECTED 0 0
ARCH CLOSING 1 10
ARCH CLOSING 1 11
RFS IDLE 0 0
RFS IDLE 0 0
RFS IDLE 0 0
RFS IDLE 1 12
MRP0 APPLYING_LOG 1 12

相关内容

热门资讯

工信部部长:搞“脱钩断链”对谁... 7月23日,2026年亚太经合组织(APEC)数字和人工智能部长会议新闻发布会在成都召开。会议主席、...
AMD展示最强AI加速器MI4... IT之家 7 月 24 日消息,今天(7 月 24 日)在美国旧金山召开的年度盛会 Advancin...
河北:知行研学度盛夏 多彩实践... 冀时新闻报道暑假期间,我省各地推出形式多样的青少年研学活动,让孩子们在实践中增长见识、锤炼品格,度过...
世界互联网大会数智健康工作组以... 7月22日,2026年世界互联网大会数字丝路发展论坛在陕西西安开幕。这是世界互联网大会连续第三年举办...
开立医疗获得实用新型专利授权:... 证券之星消息,根据天眼查APP数据显示开立医疗(300633)新获得一项实用新型专利授权,专利名为“...
成都深入实施“人工智能+”行动 成都深入实施“人工智能+”行动 到2027年实现人工智能核心产业规模突破2600亿元 华西都市报讯(...
原创 中... 说真的,看到欧洲科学家一本正经拿粪水浇菜做研究,最后还得出了个“安全无害、肥力充足”的结论,我第一反...
小米智能手环11 Active... IT之家 7 月 23 日消息,科技媒体 WinFuture 昨日(7 月 22 日)发布博文,分享...
胡塞武装袭击红海油轮,特朗普威... 据路透社报道,当地时间7月23日,也门胡塞武装表示已在红海袭击两艘沙特油轮,并称这两艘油轮违反该组织...
刚签就要黄了?特朗普:核能协议... 据彭博社报道,当地时间7月23日,美国总统特朗普表示,美国与沙特阿拉伯的民用核能合作协议能否落地,将...