分享
 
 
 

配置Windows与Linux平台的DATA GURAD

王朝system·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

从Oracle 11g数据库开始,Oracle支持在特定条件下Windows与Linux两个不同OS平台之间配置DATA GUARD,这样DATA GUARD再也不受原来需要同样OS平台的限制了(具体参考Metalink:413484.1):

配置过程示例:

主库:Windows 2003 +Oracle 11.1.0.6

SID:orcl

数据文件目录:D:\ORACLE\ORADATA\ORCL\

备用库:RHEL 4 U5+Oracle 11.1.0.6

SID:standby

数据文件目录:/home/oracle/opt/oradata/standby/

1、验证主库是归档模式,并将主库置于FORCE LOGGING模式:

SQL> archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence 229

Next log sequence to archive 231

Current log sequence 231

SQL> alter database force logging;

2、对主库做一个全库的RMAN备份,用于STANDBY配置:

RMAN> backup database format 'd:\db_%U.bak';

3、准备STANDBY数据文件路径和其他路径:

[oracle@test51 oradata]$ pwd

/home/oracle/opt/oradata

[oracle@test51 oradata]$ mkdir standby

[oracle@test51 oradata]$ cd standby

[oracle@test51 oradata]$ mkdir archive

[oracle@test51 oradata]$ cd $ORACLE_BASE/admin

[oracle@test51 admin]$ mkdir standby

[oracle@test51 oradata]$ cd standby

[oracle@test51 standby]$mkdir adump

[oracle@test51 standby]$mkdir dpdump

[oracle@test51 standby]$mkdir pfile

[oracle@test51 standby]$ ls

adump dpdump pfile

4、生成standby 初始化参数文件:

SQL> create pfile='d:/init.ora' from spfile;

添加以下几个STANDBY参数:

*.log_archive_config=’DG_CONFIG=(orcl,standby)’

*.fal_client=’standby’

*.fal_server=’primary’

*.db_file_name_convert=’D:\ORACLE\ORADATA\ORCL\’,'/home/oracle/opt/oradata/standby/’

*.log_file_name_convert=’D:\ORACLE\ORADATA\ORCL\’,'/home/oracle/opt/oradata/standby/’

*.standby_file_management=’auto’

*.log_archive_dest_1=’location=/home/oracle/opt/oradata/standby/archive VALID_FOR=(STANDBY_LOGFILE,STANDBY_ROLE)’

5、生成STANDBY控制文件:

SQL> alter database create standby controlfile as 'd:\ control01.ctl';

并将生成的STANDBY控制文件、初始化参数文件、备份集分别COPY至STANDBY端相应的目录,另外注意密码文件也需要COPY并在STANDBY端改名,因为主库和备库需要相同的密码文件,否则STANDBY无法配置成功:

[oracle@test51 standby]$ cp control01.ctl control02.ctl

[oracle@test51 standby]$ cp control01.ctl control03.ctl

[oracle@test51 standby]$ ls

archive control01.ctl control02.ctl control03.ctl db_04j3dk0q_1_1.bak db_05j3dk6n_1_1.bak

6、在STANDBY端MOUNT STANDBY数据库,可以看到从WINDOWS COPY过来的备份控制文件可以直接在LINUX底下MOUNT成功:

idle> startup mount pfile='/home/oracle/opt/admin/standby/pfile/init_standby.ora';

7、RESTORE STANDBY数据库:

由于控制文件里面记录的备份信息还是在WINDOWS上主库的备份信息,我们需要使用RMAN的catalog命令来使RMAN认出在STANDBY端从WINDOWS主库COPY过来的备份集:

RMAN> catalog start with '/home/oracle/opt/oradata/standby';

using target database control file instead of recovery catalog

searching for all files that match the pattern /home/oracle/opt/oradata/standby

List of Files Unknown to the Database

=====================================

File Name: /home/oracle/opt/oradata/standby/db_05j3dk6n_1_1.bak

File Name: /home/oracle/opt/oradata/standby/db_04j3dk0q_1_1.bak

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

List of Cataloged Files

=======================

File Name: /home/oracle/opt/oradata/standby/db_05j3dk6n_1_1.bak

File Name: /home/oracle/opt/oradata/standby/db_04j3dk0q_1_1.bak

RMAN> crosscheck backup;

RMAN> delete expired backup;

等到RMAN能够正切认出STANDBY端的备份集后,我们就可以对数据库进行RESTORE了:

RMAN> list backup;

List of Backup Sets

BS Key Type LV Size Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

3 Full 1.75G DISK 00:03:03 12-DEC-07

BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20071212T104026

Piece Name: /home/oracle/opt/oradata/standby/db_04j3dk0q_1_1.bak

RMAN> restore database;

Starting restore at 12-DEC-07

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 /home/oracle/opt/oradata/standby/SYSTEM01.DBF

channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/opt/oradata/standby/SYSAUX01.DBF

channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/opt/oradata/standby/UNDOTBS01.DBF

channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/opt/oradata/standby/USERS01.DBF

channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/opt/oradata/standby/EXAMPLE01.DBF

channel ORA_DISK_1: reading from backup piece /home/oracle/opt/oradata/standby/db_04j3dk0q_1_1.bak

channel ORA_DISK_1: piece handle=/home/oracle/opt/oradata/standby/db_04j3dk0q_1_1.bak tag=TAG20071212T104026

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:05

Finished restore at 12-DEC-07

8、在主库和备用库端分别更改tnsnames配置,添加主库和备用库的TNS连接字,并确保在主库和STANDBY都能够连接上对方:

primary =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.200.168)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

standby =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.200.169)(PORT = 1522))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = standby)

)

)

9、添加STANDBY LOGFILE,启动STANDBY至恢复管理模式:

idle> alter database add standby logfile '/home/oracle/opt/oradata/standby/redo04.log' size 50M;

idle> alter database add standby logfile '/home/oracle/opt/oradata/standby/redo05.log' size 50M;

idle> alter database add standby logfile '/home/oracle/opt/oradata/standby/redo06.log' size 50M;

idle> recover managed standby database disconnect from session;

Media recovery complete.

10、主库配置到STANDBY的归档,另外注意主库需要设置log_archive_config这个参数,否则归档将不会从主库传至STANDBY端:

Sys@orcl> alter system set log_archive_dest_2='service=standby ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby';

Sys@orcl> alter system set log_archive_dest_state_2=enable;

Sys@orcl> alter system set log_archive_config='DG_CONFIG=(orcl,standby)';

这样异构STANDBY就配置成功了。

11、测试STANDBY切换,注意在测试前要在主库端和备库端都准备好主库和备库的两种参数文件:

首先在主库端将主库切换为备库:

SQL> alter database commit to switchover to physical standby with session shutdown ;

SQL> startup mount pfile='d:\init_standby.ora'

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

再在备库端将备库切换为主库:

idle> alter database commit to switchover to primary;

idle> shutdown

idle> startup pfile='/home/oracle/opt/admin/standby/pfile/init.ora'

ORACLE instance started.

Total System Global Area 836976640 bytes

Fixed Size 1303132 bytes

Variable Size 595594660 bytes

Database Buffers 234881024 bytes

Redo Buffers 5197824 bytes

Database mounted.

Database opened.

至此,切换顺利完成。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有