ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Data guard 配置之搭建物理备库

Data guard 配置之搭建物理备库

原创 Linux操作系统 作者:YallonKing 时间:2011-08-17 15:28:09 0 删除 编辑
知识获得不易,转载请注明出处!
Data guard 配置之物理备库
1.规划
1.1 主备机信息
OS:centos4.8
DB:oracle10.2
1.2 主备库配置信息
 
ip                             db_name             db_unique_name                  Net service name
 
Primary db
192.168.241.5      node1                   node1                                       node1
 
Standby db       
192.168.241.6      node1/2                node2                                       node2
 
保护模式:默认最大性能模式
2. 主库操作
2.1 设置日志模式
注:若已处于logging模式,此步骤可省略
2.2 创建密码文件
orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=5 force=y
2.3 配置备库日志
注:此步骤可省略
2.4 设置主库参数文件
SQL> alter system set db_unique_name=node1 scope=spfile;
SQL> alter system set log_archive_config='dg_config=(node1,node2)' scope=spfile;
SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/oradata/node1/archive1/ valid_for=(all_logfiles,all_roles) db_unique_name=node1' scope=spfile;
SQL> alter system set log_archive_dest_2='service=node2 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=node2' scope=spfile;
SQL> alter system set log_archive_dest_state_1=enable scope=spfile;
SQL> alter system set log_archive_dest_state_2=enable scope=spfile;
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;
SQL> alter system set log_archive_max_processes=5 scope=spfile;
*******************************************************************************
以下参数可省略
SQL> alter system set fal_server=node2 scope=spfile;
SQL> alter system set fal_client=node1 scope=spfile;
SQL> alter system set db_file_name_convert='node2','node1' scope=spfile;
SQL> alter system set log_file_name_convert='node2','node1' scope=spfile;
SQL> alter system set standby_file_management=auto scope=spfile;
2.5 设置主库归档模式
SQL> shutdown immediate
3. 创建物理备库
**************以下均在主库操作************
3.1 创建主库的备份
[oracle@xlong01 dbs]$ rman target /
RMAN> backup full database format '/tmp/dg/backup_%T_%s_%p.bak';
RMAN> sql 'alter system archive log current';
RMAN> backup archivelog all format='/tmp/dg/arch_%T_%s_%p.bak';
3.2 为备库创建控制文件
SQL> startup mount
SQL> alter database create standby controlfile as '/tmp/dg/staby_control01.ctl';
SQL> alter database open;
3.3 设置备库参数文件
SQL> create pfile='/tmp/dg/initnode2.ora' from spfile;
修改此参数文件(具体修改后内容参见后边相关文件)
3.4 复制主库备份至备库
将3.1中的备份移动(借助ftp软件)至备库的相同目录下,将3.2中的控制文件备份移动至备库的相关目录下并复用,将3.3中的参数文件(initnode2.ora)移动至备库相关文件下
[oracle@xlong01 node2]$ pwd
/u01/app/oracle/oradata/node2
[oracle@xlong01 node2]$ cp staby_control01.ctl staby_control02.ctl
[oracle@xlong01 node2]$ cp staby_control01.ctl staby_control03.ctl
3.5 设置主备库网络环境
①通过netmgr设置主备库listener.ora与tnsnames.ora
②重新启动主备库监听
[oracle@xlong01 ~]$ lsnrctl stop
[oracle@xlong01 ~]$ lsnrctl start
③检查主备库连接串解析情况
[oracle@xlong01 ~]$ tnsping node2    (主库操作)
[oracle@xlong01 node2]$ tnsping node1(备库操作)
3.6 启动备库
①将主库的密码文件拷贝至备库相关目录下(也可创建和主库一致的密码文件)
②修改备库的os配置文件(.bash_profile)(可能)
③由pfile生成spfile
SQL> create spfile from pfile;
④将备库nomount后执行rman下的restore和recover
[oracle@xlong01 ~]$ rman target /
RMAN> restore database;
RMAN> recover database;
SQL> startup mount
SQL> alter database recover managed standby database disconnect from session;
4. 验证物理备库是否成功
4.1 查看主备库之间的归档日志是否正常传递
 
 
4.2 查看主备库的归档文件是否已经归档到指定位置

4.3 查看主备库归档日志文件最大序号是否相同
5. 相关文件
5.1 主库信息
[oracle@xlong01 dbs]$ strings spfilenode1.ora
node1.__db_cache_size=197132288
node1.__java_pool_size=4194304
node1.__large_pool_size=4194304
node1.__shared_pool_size=75497472
node1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/node1/adump'
*.background_dump_dest='/u01/app/oracle/admin/node1/bdump'
*.compatible=' 10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/node1/control01.ctl','/u01/app/oracle/oradata/node1/control02.ctl','/u01/app/oracle/oradata/node1/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/node1/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='node2','node1'
*.db_name='node1'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='NODE1'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=node1XDB)'
*.fal_client='NODE1'
*.fal_server='NODE2'
*.job_queue_processes=10
*.log_archive_config='dg_config=(node1,node2)'
*.log_archive_dest_1='location=/u01/app/oracle/oradata/node1/archive1/ valid_for=(all_logfiles,all_roles) db_unique_name=node1'
*.log_archive_dest_2='service=NODE2 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=node2'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes=5
*.log_file_name_convert='node2','node1'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/node1/udump'
**************************************************
[oracle@xlong01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/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 = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = node1)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = node1)
    )
  )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = xlong01)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
**************************************************
 [oracle@xlong01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
 
NODE2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.6)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node2)
    )
  )
 
NODE1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.5)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node1)
    )
  )
 
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
 
5.2 备库信息
[oracle@xlong01 dbs]$ strings spfilenode2.ora
node2.__db_cache_size=197132288
node2.__java_pool_size=4194304
node2.__large_pool_size=4194304
node2.__shared_pool_size=75497472
node2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/node2/adump'
*.background_dump_dest='/u01/app/oracle/admin/node2/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/node2/staby_control01.ctl','/u01/app/oracle/oradata/node2/staby_control02.ctl','/u01/app/oracle/oradata/node2/staby_control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/node2/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='node1','node2'
*.db_name='node1'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='NODE2'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=node1XDB)'
*.fal_client='NODE2'
*.fal_server='NODE1'
*.job_queue_processes=10
*.log_archive_config='dg_config=(node2,node1)'
*.log_archive_dest_1='location=/u01/app/oracle/oradata/node2/archive1/ valid_for=(all_logfiles,all_roles) db_unique_name=node2'
*.log_archive_dest_2='service=NODE1 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=node1'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes=5
*.log_file_name_convert='node1','node2'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/node2/udump'
**************************************************
 [oracle@xlong01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/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 = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = node2)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = node2)
    )
  )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = xlong01)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
**************************************************
[oracle@xlong01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
 
NODE2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.6)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node2)
    )
  )
 
NODE1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.5)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node1)
    )
  )
 
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
6. 注意事项
6.1 下边的问题主要是listener.ora和tnsnames.ora设置不当引起,建议使用netmgr进行相关设置
 
6.2 下边问题可能通过设置一致的主备库密码文件解决
 
6.3 注意网络服务名在参数文件中的大小写以及文件目录权限

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26143577/viewspace-705130/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-08-07

  • 博文量
    72
  • 访问量
    260571