用户有一套oracle数据库环境存在单节点运行隐患,虽然有全库备份,但是听用户说恢复数据极慢,且数据量有5t了。了解到该系统承载的业务比较重要,为消除隐患,给用户提了部署adg环境的建议,用户也采纳了,申请了一台相同配置的服务器,目前已经部署完成,运行正常。
网上部署adg环境的文档很多,但是windows环境的却极少,且windows环境与linux环境部署dg还是有部分差异的,好记性不如烂笔头,下面是根据生产环境的操作记录下来的。
源端操作系统:windows server 2008 r2
源端数据库:oracle 11.2.0.4.0
目标端操作系统:windows server 2008 r2
目标端数据库:oracle 11.2.0.4.0
select df.total / 1048576 "datafile size mb",
log.total / 1048576 "redo log size mb",
control.total / 1048576 "control file size mb",
(df.total log.total control.total) / 1048576 "total size mb"
from dual,
(select sum(a.bytes) total from dba_data_files a) df,
(select sum(b.bytes) total from v$log b) log,
(select sum((cffsz 1) * cfbsz) total from x$kcccf c) control;
archive log list;
alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_dest_1='location=e:\arch' scope=spfile sid='*';
shutdown immediate;
startup mount
alter database archivelog;
alter database open;
select log_mode from v$database;
alter database force logging;
将tnsnames.ora文件拷贝给备库。
tnsorcl =
(description =
(address = (protocol = tcp)(host = 192.168.100.20)(port = 1521))
(connect_data =
(server = dedicated)
(service_name = orcl)
)
)
tnsprod =
(description =
(address = (protocol = tcp)(host = 192.168.100.21)(port = 1522))
(connect_data =
(server = dedicated)
(sid = prod)
)
)
# listener.ora network configuration file: e:\app\administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
# generated by oracle configuration tools.
sid_list_listener =
(sid_list =
(sid_desc =
(sid_name = clrextproc)
(oracle_home = e:\app\administrator\product\11.2.0\dbhome_1)
(program = extproc)
(envs = "extproc_dlls=only:e:\app\administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
listener =
(description_list =
(description =
(address = (protocol = tcp)(host = win-t6052joo0gg)(port = 1521))
(address = (protocol = ipc)(key = extproc1521))
)
)
listener1 =
(description_list =
(description =
(address_list =
(address = (protocol = tcp)(host = 192.168.100.21)(port = 1522))
)
)
)
sid_list_listener1 =
(sid_list =
(sid_desc =
(global_dbname = orcl)
(sid_name = prod)
(oracle_home = e:\app\administrator\product\11.2.0\dbhome_1)
)
)
adr_base_listener = e:\app\administrator
lsnrctl start listener1
alter system set log_archive_config='dg_config=(orcl,prod)' scope=both;
alter system set log_archive_dest_1='location=e:\arch valid_for=(all_logfiles,all_roles) db_unique_name=orcl' scope=both;
alter system set log_archive_dest_2='service=tnsprod lgwr sync affirm valid_for=(online_logfiles,primary_role) db_unique_name=prod' scope=both;
alter system set standby_file_management=auto scope=both sid='*';
oradim -new -sid prod
set oracle_sid=pro
sqlplus / as sysdba
sqlplus sys/oracle@tnsorcl as sysdba
sqlplus sys/oracle@tnsprod as sysdba
orapwd file=e:\app\administrator\product\11.2.0\dbhome_1\database\pwdorcl.ora password=oracle entries=5
db_name='orcl'
db_unique_name='prod'
memory_target=2g
compatible='11.2.0.1.0'
control_files='e:\app\administrator\oradata\orcl\control01.ctl','e:\app\administrator\flash_recovery_area\orcl\control02.ctl'
log_archive_config='dg_config=(orcl,prod)'
log_archive_dest_1='location=e:\arch valid_for=(all_logfiles,all_roles) db_unique_name=prod'
log_archive_dest_2='service=tnsorcl lgwr sync affirm valid_for=(online_logfiles,primary_role) db_unique_name=orcl'
db_file_name_convert='e:\app\administrator\oradata\orcl','e:\app\administrator\oradata\orcl',
log_file_name_convert='e:\app\administrator\oradata\orcl','e:\app\administrator\oradata\orcl'
fal_client='tnsracdb'
fal_server='tnsprod'
standby_file_management='auto'
sql> create spfile from pfile;
sql> startup nomount
[oracle@rac2 ~]$ rman target sys/oracle@tnsorcl
rman> connect auxiliary sys/oracle@tnsprod
rman> duplicate target database for standby from active database nofilenamecheck;
alter database add standby logfile group 4 'e:\app\administrator\oradata\orcl\standby01.log' size 50m;
alter database add standby logfile group 5 'e:\app\administrator\oradata\orcl\standby02.log' size 50m;
alter database add standby logfile group 6 'e:\app\administrator\oradata\orcl\standby03.log' size 50m;
alter database add standby logfile group 7 'e:\app\administrator\oradata\orcl\standby04.log' size 50m;
standby redo log多少组合适
在单实例情况下
所有redo log组数 1即可。
在rac环境下
所有redo log组数 实例数
正常情况下,一般每个实例的redo log组数目是一样的,比如为n,则standbby redo log组数为(n 1)*thread
假如rac有三个实例,每个实例都是3个redo log组,那么如果要做dg的standby log要增加12个standby loggroup
(3 1)*3=12
假如有个rac共三个实例,实例1有3个log组,实例2有4个log组,实例3有5个log组,总共有12个log组,那么如果要做dg的standby log要增加15个standby loggroup
所有redo log组数 实例数=(3 4 5) 3=15
alter database open read only;
alter database recover managed standby database using current logfile disconnect from session;