oracle 11gr2 物理备用数据库搭建及切换(同一主机上)-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 3503194
  • 博文数量: 718
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7790
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(718)

文章存档

2024年(4)

2023年(74)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

最近访客
相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2010-11-30 11:11:25

在同一台机器上搭建物理备用数据库的步骤,linux环境 oracle 11.2.0.1
主库:orcl
备库:stby

1 检查侦听是否启动
2 配置主备数据库的初始化参数文件
sqlplus "/as sysdba"
create pfile='/home/oracle/initprim.ora' from spfile;
cp /home/oracle/initprim.ora /home/oracle/initstby.ora
vi /home/oracle/initprim.ora
orcl.__db_cache_size=104857600
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/oracle'#oracle_base set from environment
orcl.__pga_aggregate_target=155189248
orcl.__sga_target=268435456
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=142606336
orcl.__streams_pool_size=4194304
*.audit_file_dest='/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/oradata/orcl/control01.ctl','/oradata/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/oradata/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/oracle'
*.dispatchers='(protocol=tcp) (service=orclxdb)'
*.memory_target=422576128
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.undo_tablespace='undotbs1'
 
*.fal_client='prim'
*.fal_server='stby'
*.standby_file_management=auto
*.log_archive_dest_1='location=/oradata/arch/orcl valid_for=(all_logfiles,all_roles) db_unique_name=prim'
*.log_archive_dest_2='service=stby valid_for=(online_logfiles,primary_role) db_unique_name=stby'
*.db_unique_name=prim
*.log_archive_config='dg_config=(prim,stby)'
 
编辑备库的参数文件
vi /home/oracle/initstby.ora

stby.__db_cache_size=104857600
stby.__java_pool_size=4194304
stby.__large_pool_size=4194304
stby.__oracle_base='/oracle'#oracle_base set from environment
stby.__pga_aggregate_target=155189248
stby.__sga_target=268435456
stby.__shared_io_pool_size=0
stby.__shared_pool_size=142606336
stby.__streams_pool_size=4194304
*.audit_file_dest='/oracle/admin/stby/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/oradata/stby/control01.ctl','/oradata/flash_recovery_area/stby/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'   #<-- 在同一台机器上搭建dg 要与主库的一样 否则ora-01103
*.db_recovery_file_dest='/oradata/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/oracle'
*.dispatchers='(protocol=tcp) (service=stbyxdb)'
*.memory_target=622576128
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.undo_tablespace='undotbs1'

*.db_file_name_convert='/oradata/orcl','/oradata/stby'
*.log_file_name_convert='/oradata/orcl','/oradata/stby'
*.fal_client='stby'
*.fal_server='prim'
*.standby_file_management=auto
*.log_archive_dest_1='location=/oradata/arch/stby valid_for=(all_logfiles,all_roles) db_unique_name=stby'
*.log_archive_dest_2='service=prim valid_for=(online_logfiles,primary_role) db_unique_name=prim'
*.db_unique_name='stby'
*.log_archive_config='dg_config=(prim,stby)'

备份主库
rman target /
backup database format '/u01/oradata/dbfull%u';
 
创建备库控制文件
export oracle_sid=orcl
sqlplus "/as sysdba"
alter database create standby controlfile as '/oradata/stby/stbycontrol.ctl';

cp /oradata/stby/stbycontrol.ctl /oradata/stby/control01.ctl
cp /oradata/stby/stbycontrol.ctl /oradata/flash_recovery_area/stby/control02.ctl
处理备库
export oracle_sid=stby
orapwd file=/oracle/product/11.2.0/db_1/dbs/orapwstby password=oracle entries=5 ignorecase=y  #一定要加ignorecase=y 要不然归档传不到备用库上

sqlplus "/as sysdba"
startup nomount
alter database mount;
rman target /
restore database;
重启主库
export oracle_sid=orcl
sqlplus "/as sysdba"
shutdown immediate
startup pfile='/home/oracle/initprim.ora'

配置tnsnames.ora(因为在同一台机器上,所以就改这一个文件)
orcl =
  (description =
    (address_list =
      (address = (protocol = tcp)(host = localhost)(port = 1521))
    )
    (connect_data =
      (sid = orcl)
      (server = dedicated)
    )
  )
stby =
  (description =
    (address_list =
      (address = (protocol = tcp)(host = localhost)(port = 1521))
    )
    (connect_data =
      (sid = stby)
      (server = dedicated)
    )
  )
 
将备库置于接收归档日志状态
export oracle_sid=stby
sqlplus "/as sysdba"
alter database recover managed standby database disconnect from session;
 
过一会儿检查是否收到日志
export oracle_sid=orcl
sqlplus "/as sysdba"
select max(sequence#) from v$archived_log;     --查看归档日志序列号
alter system switch logfile;
alter system switch logfile;
export oracle_sid=stby
sqlplus "/as sysdba"
select sequence#,applied from v$archived_log order by 1;    --查看归档日志序列号
 
 
 
主备库角色切换

角色切换
步骤1:验证主库能否进行角色切换,to standby表示可以进行
sql> select switchover_status from v$database;
switchover_status
-----------------
to standby
 
步骤2:在主库上执行角色切换到从库角色
sql> alter database commit to switchover to physical standby;

步骤3:关闭并重新启动之前的主库实例
sql> shutdown immediate
sql> startup mount
 
步骤4:在备库的v$database视图中查看备库的切换状态
sql> select switchover_status from v$database;
switchover_status
-----------------
to_primary
 
步骤5:切换备库到主库角色
sql> alter database commit to switchover to primary;
 
步骤6:完成备库到主库的切换
1. 如果备库没有以只读模式打开,直接执行以下语句打开到新的主库。
sql> alter database open;
2. 如果备库以只读模式打开,先关闭数据,然后再重新启动。
sql> shutdown immediate;
sql> startup;
 
步骤7:如果有必要,重新启动一下新的备库上的重做日志应用服务
sql> alter database recover managed standby database disconnect from session;
(注:可以通过select message from v$dataguard_status;查看当前备库应用重做日志的状态)

步骤8:开始发送重做数据到备库上
issue the following statement on the new primary database:
sql> alter system switch logfile;

备注:
alter database recover managed standby database using current logfile;
如果有缺失的归档日志文件,手工考背后,在备库上:
alter database register physical logfile 'filespec1';
force 关键词终止目标物理备数据库上活动的rfs 进程,使得故障转移能不用等待网络连接超时而立即进行。
alter database recover managed standby database finish force;
阅读(3358) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-12-01 15:20:53

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com

|
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图