MMA的东西,正好手上有机器,以前老偷懒不写过程,现在也要给写出来作手册。。。。[@more@]
其实配置过程对老手来说可能就花在备份数据库上了呵呵
下面以prdb作为primary,lstdb作为standby,用lstdb做名字是因为接下来一篇还要把physical standby(dataguard)转换成逻辑的standby(logical standby)
这里介绍一个快速装dataguard的方法,就是索性在standby端直接dbca安装一个数据库,这样必要的文件夹有了,密码文件也不需要从primary传过来了,监听也有现成的了。新手犯错误的概率会降低很多。
prdb端:
首先修改设置:
ALTER DATABASE FORCE LOGGING;
alter system set log_archive_dest_1='location=+data/prdb/arch valid_for=(all_logfiles,all_roles) db_unique_name=prdb' scope=both;
alter system set standby_archive_dest='location=+data/prdb/arch' scope=both;
alter system set fal_client='prdb' scope=both;
alter system set fal_server='lstdb' scope=both;
alter system set db_file_name_convert='+data/lstdb','+data/prdb' scope=spfile;
alter system set log_file_name_convert='+data/lstdb','+data/prdb' scope=spfile;
alter system set standby_file_management=auto scope=both;
alter system set db_unique_name='prdb' scope=spfile;
startup mount force 让参数生效
alter database archivelog; 打开归档模式
然后进行备份:
rman target /
BACKUP DEVICE TYPE DISK FORMAT '/nas_data/orabackup/%U' DATABASE plus ARCHIVELOG;
BACKUP DEVICE TYPE DISK FORMAT '/nas_data/orabackup/st_%U' CURRENT CONTROLFILE FOR STANDBY;
备份完以后最好运行一下
alter system archive log current;
否则如果传送到standby端开始duplicate的时候,primary还没有切换过日志,那么会报错找不到可用的控制文件备份.
把备份传送到standby端同样的目录.
lstdb:
startup nomount pfile='pst.ora'
create spfile='+DATA/lstdb/spfilelstdb.ora' from pfile='pst.ora';
startup nomount force;
就可以了pst.ora是参数文件,后面会贴出来。
然后进行复制备用数据库:
rman target auxiliary /
DUPLICATE TARGET DATABASE FOR STANDBY DORECOVER;
复制最后可能会报一些错误如:
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '+DATA/lstdb/datafile/system.272.676722947'
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 01/21/2009 10:36:20
RMAN-03015: error occurred in stored script Memory Script
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of log thread 2 seq 7 lowscn 542060 found to restore
RMAN-06025: no backup of log thread 2 seq 6 lowscn 541904 found to restore
RMAN-06025: no backup of log thread 1 seq 8 lowscn 542063 found to restore
这些都没关系,只要保证日志没有缺失就可以,少的日志都可以通过FAL传送过去
完成以后就可以开始进行保护恢复了:
lstdb:
alter database recover managed standby database disconnect from session;
prdb:
alter system set log_archive_dest_2='service=lstdb reopen=120 valid_for=(online_logfiles,primary_role) db_unique_name=prdb' scope=both;
上面是最大性能,如果要作最大保护和最大可用就要添加standby redo和修改下log_archive_dest_2
dataguard的设置其实就是个经验问题,测试下双方是不是能用sys登录对方,参数设置是不是有问题。事后看看alert和arch或者lgwr的trc就差不多了。
下面是2个集群的初始化文件:
[oracle@jiaoyou1 ~]$ more pr.ora
prdb1.__db_cache_size=889192448
prdb2.__db_cache_size=889192448
prdb1.__java_pool_size=16777216
prdb2.__java_pool_size=16777216
prdb1.__large_pool_size=16777216
prdb2.__large_pool_size=16777216
prdb1.__shared_pool_size=285212672
prdb2.__shared_pool_size=285212672
prdb1.__streams_pool_size=0
prdb2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/prdb/adump'
*.background_dump_dest='/u01/app/oracle/admin/prdb/bdump'
*.cluster_database_instances=2
*.cluster_database=true
*.compatible='10.2.0.3.0'
*.control_files='+DATA/prdb/controlfile/current.386.676829633'
*.core_dump_dest='/u01/app/oracle/admin/prdb/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='+data/lstdb','+data/prdb'
*.db_name='prdb'
*.db_unique_name='prdb'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=prdbXDB)'
*.fal_client='prdb'
*.fal_server='lstdb'
prdb1.instance_number=1
prdb2.instance_number=2
*.job_queue_processes=10
*.log_archive_dest_1='location=+data/prdb/arch valid_for=(all_logfiles,all_roles) db_unique_name=prdb'
*.log_archive_dest_2='service=lstdb reopen=120 valid_for=(online_logfiles,primary_role) db_unique_name=prdb'
*.log_file_name_convert='+data/lstdb','+data/prdb'
*.open_cursors=300
*.pga_aggregate_target=406847488
*.processes=150
*.remote_listener='LISTENERS_PRDB'
*.remote_login_passwordfile='exclusive'
*.sga_target=1222639616
*.standby_archive_dest='location=+data/prdb/arch'
*.standby_file_management='AUTO'
prdb2.thread=2
prdb1.thread=1
*.undo_management='AUTO'
prdb2.undo_tablespace='UNDOTBS2'
prdb1.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/prdb/udump'
[oracle@jy1 ~]$ more pst.ora
lstdb2.__db_cache_size=1929379840
lstdb1.__db_cache_size=1862270976
lstdb2.__java_pool_size=16777216
lstdb1.__java_pool_size=16777216
lstdb2.__large_pool_size=16777216
lstdb1.__large_pool_size=16777216
lstdb2.__shared_pool_size=503316480
lstdb1.__shared_pool_size=570425344
lstdb2.__streams_pool_size=0
lstdb1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/lstdb/adump'
*.background_dump_dest='/u01/app/oracle/admin/lstdb/bdump'
*.cluster_database_instances=2
*.cluster_database=TRUE
*.compatible='10.2.0.3.0'
*.control_files='+DATA/lstdb/controlfile/current.652.676829111'#Restore Controlfile
*.core_dump_dest='/u01/app/oracle/admin/lstdb/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='+data/prdb','+data/lstdb'
*.db_name='prdb'
*.db_unique_name='lstdb'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=lstdbXDB)'
*.fal_client='lstdb'
*.fal_server='prdb'
lstdb2.instance_number=2
lstdb1.instance_number=1
*.job_queue_processes=10
*.log_archive_dest_1='location=+data/lstdb/arch valid_for=(all_logfiles,all_roles) db_unique_name=lstdb'
*.log_archive_dest_2='service=prdb valid_for=(online_logfiles,primary_role) db_unique_name=lstdb'
*.log_file_name_convert='+data/prdb','+data/lstdb'
*.open_cursors=300
*.pga_aggregate_target=825229312
*.processes=150
*.remote_listener='LISTENERS_LSTDB'
*.remote_login_passwordfile='exclusive'
*.service_names='LSTDB'
*.sga_target=2476736512
*.standby_archive_dest='location=+data/lstdb/arch'
*.standby_file_management='AUTO'
lstdb2.thread=2
lstdb1.thread=1
*.undo_management='AUTO'
lstdb2.undo_tablespace='UNDOTBS2'
lstdb1.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/lstdb/udump'