Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1107904
  • 博文数量: 227
  • 博客积分: 6860
  • 博客等级: 准将
  • 技术积分: 2688
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-02 16:06
文章分类

全部博文(227)

文章存档

2015年(7)

2014年(8)

2012年(5)

2011年(62)

2010年(145)

分类: Oracle

2010-09-08 20:06:38

今天把DG实验全部做完。
实验类型:不同主机上用RMAN备份建立物理备用数据库
OS:WindowsXP
实例名:主库orcl    备库standby
IP主库:192.168.128.133         IP备库:192.168.128.134
前提准备
设置主数据库为force logging 模式 
SQL>alter database force logging;
. 设置主数据库为归档模式
SQL> archive log list
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> archive log list
1、RMAN全备份主库(orcl):
rman target
backup database plus archivelog;
backup current controlfile for standby;

然后切换日志alter system switch logfile;
2、在备库机器上建立存放standby库相关的OS目录
mkdir c:\standby
mkdir c:\standby\bdump
mkdir c:\standby\udump
mkdir c:\standby\archive
3、在备库机器上建立列程服务standby实例以及密码
oradim -new -sid standby -intpwd oracle
4、配置监听程序和网络服务名(在这里我把配置好的贴出来)主库的
listener.ora
# listener.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = c:\oracle\product\10.2.0\db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = c:\oracle\product\10.2.0\db_1)
      (SID_NAME = orcl)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.133)(PORT = 1521))
    )
  )

tnsname.ora
# tnsnames.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.134)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = standby)
    )
  )
ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.133)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

备库的:
listener.ora
# listener.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = c:\oracle\product\10.2.0\db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = standby)
      (ORACLE_HOME = c:\oracle\product\10.2.0\db_1)
      (SID_NAME = standby)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.134)(PORT = 1521))
    )
  )
tnsnames.ora
# tnsnames.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.134)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = standby)
    )
  )
ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.133)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )
5、准备主数据参数文件。
sqlplus as sysdba
create pfile from spfile;
编辑参数文件initorcl.ora  具体在c:\oracle\product\10.2.0\db_1\database目录下如下(我这里只添加要加的内容):
db_unique_name=orcl
log_archive_dest_1='location=C:\oracle\product\10.2.0\flash_recovery_area\ORCL\ARCHIVELOG valid_for=(all_logfiles,all_roles) db_unique_name=orcl'
log_archive_dest_2='SERVICE=standby valid_for=(online_logfiles,primary_role) db_unique_name=standby'
log_archive_config='dg_config=(orcl,standby)'
fal_server=standby
fal_client=orcl
standby_file_management=AUTO
6、建立服务器参数文件
shutdown immediate
create spfile from pfile='C:\oracle\product\10.2.0\db_1\database\initorcl.ora';
startup
7、准备备用参数文件。
sqlplus as sysdba
create pfile='C:\oracle\product\10.2.0\db_1\database\initstandby.ora' from spfile;
编辑initstandby.ora具体在c:\oracle\product\10.2.0\db_1\database目录下如下(我这里只添加要加的内容):
db_unique_name=standby
service_names=standby
instance_name=standby
control_files=c:\standby\control01.ctl
log_archive_dest_1='location=c:\standby\archive valid_for=(all_logfiles,all_roles) db_unique_name=standby'
log_archive_dest_2='SERVICE=orcl valid_for=(online_logfiles,primary_role) db_unique_name=orcl'
log_archive_config='dg_config=(orcl,standby)'
fal_server=orcl
fal_client=standby
db_file_name_convert='C:\oracle\product\10.2.0\oradata\orcl','c:\standby'
log_file_name_convert='C:\oracle\product\10.2.0\oradata\orcl','c:\standby'
standby_file_management=AUTO
standby_archive_dest='c:\standby\archive'
background_dump_dest='c:\standby\bdump'
user_dump_dest='c:\standby\udump'
8、建立standby的参数文件
sqlplus as sysdba
create spfile='c:\oracle\product\10.2.0\db_1\database\spfilestandby.ora' from pfile='c:\oracle\product\10.2.0\db_1\database\initstandby.ora';
9、复制相关文件到备机具体操作是把主机的C:\oracle\product\10.2.0下的flash_recovery_area这个文件考到备机C:\oracle\product\10.2.0下。把C:\oracle\product\10.2.0\db_1\database下有关standby的参数文件(initstandby.ora、spfilestandby.ora)拷贝到备机C:\oracle\product\10.2.0\db_1\database下
10、在备机上sqlplus as sysdba在建立备用数据库时备用数据库必须以nomount方式启动如下:
startup nomount之后在主机上(192.168.128.133)rman target auxiliary
连接上后执行duplicate target database for standby dorecover;这样RMAN就会把主库的数据恢复到备库
11、主库:sqlplus as sysdba
     alter system switch logfile;
      备库:sqlplus as sysdba
  select name from v$archived_log;
看能不能接受到日志,接收到表明DG配置成功,若收不到日志则好好检查你的参数文件是不是没配置成功。
12、在备库上增加临时表空间
alter database open
alter tablespace temp add tempfile 'd:\standby\temp.dbf' size 5m reuse

测试 在主库中建一张表后执行alter system switch logfile;
后在备库将备库转为重做应用状态:alter database recover managed standby database disconnect from session;
然后取消重做应用:alter database recover managed standby database cancel
这样就能在备库查到你在主库建的表了
查看日志应用状态:select sequence#,applied from v$archived_log; ­

阅读(1068) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~