当前位置:操作系统 > Unix/Linux >>

搭建实时同步data guard的最高可用-切换主备

搭建实时同步data guard的最高可用-切换主备
 
首先保证主库在归档模式下:错过N次了
准备二台机器(hostname gw hosts ech0)host-only
[root@node1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:9C:CC:51  
          inet addr:192.168.56.147  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe9c:cc51/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:750606 errors:0 dropped:0 overruns:0 frame:0
          TX packets:132742 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:179921301 (171.5 MiB)  TX bytes:2845074889 (2.6 GiB)
 
eth0:1    Link encap:Ethernet  HWaddr 08:00:27:9C:CC:51  
          inet addr:192.168.1.147  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 
 
 主库
 ip 192.168.1.147 node1.dg.com   安装好ORACLE,正常运行的数据库
 ipadd:  192.168.1.147  gw:192.168.1.1
     oracle sid: orcl  
     database name :orcl
     service  name :orcl   
备库
ip 192.168.1.157 node1.dg.com   只安装软件就可以了
     ipadd:  192.168.1.157
     gw:192.168.1.1
     oracle sid: orcl02  
     database name :orcl        -->??
     service  name :orcl        -->??
     步骤
1  --在二台机器上都建立oracleNET 即生成listner.ora及tnsnames.ora
--主库已有listner.ora and tnsnames.ora,需要增加tnsnames.ora到备库network service names
netmgr
--只需要在备库上建立(监听为静态监听)和tnsnames
--以上建立完毕,需要主备都启监听(注意VBOX可以调界面)
  1.1 ssh 192.168.1.147---> on primary
      netmgr
/*1.1       cp  -v  $ORACLE_HOME/network/admin/listner.ora $ORACLE_HOME/network/admin/listner.ora.std
       cp  -v  $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora.std
      vi  listner.ora.std
      vi  tnsnames.ora.std
      scp listner.ora.std  oracle@192.168.1.57:$ORACLE_HOME/network/admin/listner.ora
      scp tnsnames.ora.std oracle@192.168.1.57:$ORACLE_HOME/network/admin/tnsnames.ora
      [oracle@node1 ~]$ cat /u01/app/oracle/product/11.2.0.1/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0.1/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.1/db_1)
      (SID_NAME = orcl)
    )
  )
 
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.147)(PORT = 1521))
  )
 
ADR_BASE_LISTENER = /u01/app/oracle
 
*/
       lsnrctl start  -->on primary,stdby二边都要做
 2  --准备备库的parameter file
    --on primary
  SQL> show parameter name
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- 
db_file_name_convert                 string
db_name                              string      orcl
db_unique_name                       string      orcl
global_names                         boolean     FALSE
instance_name                        string      orcl
lock_name_space                      string
log_file_name_convert                string
service_names                        string      orcl
SQL> 
SQL> select name from v$controlfile;
 
NAME
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/control01.ctl
/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
 
SQL> select name from v$datafile;
 
NAME
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/undotbs1.dbf
 
7 rows selected.
SQL>
 
  --add parameter in spfile on primary 
SQL> alter system set db_unique_name='orcl' scope=spfile;
SQL> alter system set service_names='orcl' scope=spfile;
SQL> alter system set log_archive_config='dg_config=(orcl,orclstd)' ;
SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/archivelog/orcl  valid_for=(all_logfiles,all_roles) db_unique_name=orcl' ;
SQL> alter session set log_archive_dest_state_2=defer;
SQL>  alter system set log_archive_dest_2='service=to_157 valid_for=(online_logfile,primary_role) db_unique_name=orclstd';
 
dg_config   注册成员实例名:oracle_sid
 
 location   本地相关信息
 
 service=to_157 输送到备库监听名称 to_157字符串
--
--    alter system set log_file_name_convert='remote_archive_path','local_archive_path'
--                      /home/oracle/archive,/opt/oracle/oradata
--    alter system set db_file_name_convert='remote_oardata_path','local_oradata_path'
--                      /home/oracle/oradata,/opt/oracle/oradata
 
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,