您的位置:首页技术开发数据库教程 → oracle 11gR2 物理备用数据库搭建及切换

oracle 11gR2 物理备用数据库搭建及切换

时间:2011/2/12 10:28:38来源:本站原创作者:佚名我要评论(2)

在同一台机器上搭建物理备用数据库的步骤,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;    --查看归档日志序列号
 

本文导航

相关视频

    没有数据

相关阅读 Oracle PRKC-1002错误原因和解决方案oracle10g安装图解(win7)Oracle错误代码大全oracle查看实例名方法Oracle表空间恢复方案微软亚太研发集团总部大楼 扎根中国"硅谷"亚马逊网络服务推出Oracle RDS如何关闭oracle rac选项 make rac_off

文章评论
发表评论

热门文章 oracle10g安装图解(wi

最新文章 数据库流行度排行2019oracle10g安装图解(wi SQL2008全部数据导出导入两种方法SQL2005新建复制“找不到存储过程 错误:28Dos远程登录mysql数据库详细图文教程mysql怎么开启远程登录功能

人气排行 mysql自动定时备份数据库的最佳方法-支持wiVisual Foxpro 6.0安装向导图文教程SQL Server 2008 安装图文教程SQL2008全部数据导出导入两种方法SQL 2000/2005/2008 的收缩日志方法,和清理mysql出 Can't connect to MySQL server onoracle10g安装图解(win7)sql2005安装图解_(sql server2005)安装教程