/etc/hosts文件内容

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 oak1
192.168.20.101 oda1.oracle.com oda1
192.168.16.24 oda1-priv.oracle.com oda1-priv
192.168.20.109 oda1-vip.oracle.com oda1-vip
192.168.20.102 oda2.oracle.com oda2
192.168.16.25 oda2-priv.oracle.com oda2-priv
192.168.20.110 oda2-vip.oracle.com oda2-vip
192.168.20.111 oda-scan.oracle.com oda-scan

Public IP 机器的真实IP用于远程管理和数据库链接,节点失效时将不能正常访问,这也是平常单节点数据库所使用的服务地址,使用此IP时客户端tnsname.ora配置如下。

racdb1 =
   (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.109)(PORT = 1521))
     )
     (CONNECT_DATA =
       (SID = racdb1)
       (SERVER = DEDICATED)
     )
   )

Virtual IP 服务IP用于提供Oracle服务,当主机故障时此IP将漂移到正常的主机,此地址一般绑定在Public网卡上;Listener会同时侦听在Public IP和Virtual IP;Oracle 11g R2之前通过此地址提供服务。

Oracle客户端使用tnsname.ora中配置的地址列表访问服务,可配置为lb模式或者随机模式。

racdb =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.101)(PORT = 1521))
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.102)(PORT = 1521))
     (LOAD_BALANCE = yes)      //开启负载
     (CONNECT_DATA =
       (SERVER = DEDICATED)     //专用服务器,一个客户端连接对应一个服务器进程
       (SERVICE_NAME = racdb)   //对应数据库的服务名
       (FAILOVER_MODE =      //连接失败后处理的方式 
            (TYPE = session) //TYPE =SESSION表示当一个连接好的会话的实例发生故障,系统会自动将会话切换到其他可用的实例,前台应用无须再度发起连接,但会话正在执行的SQL 需要重新执行
            (METHOD = basic) //表示初始连接就连接一个接点 
            (RETRIES = 180)  //连接失败后重试连接的次数 
            (DELAY = 5)    //连接失败后重试的延迟时间(以秒为单位)
       )
     )
 )

Oracle 11g R2版本开始提供了Scan方式,可通过Scan IP提供服务,Scan IP可自动将请求发送给实际的服务节点。

Private IP 内部节点网络通讯使用

Scan IP Scan Lintener侦听在Scan IP上,将接收的请求转发给Local Listener提供服务。

racdb_scan =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.111)(PORT = 1521))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = racdb)
     (FAILOVER_MODE =
          (TYPE = session)
          (METHOD = basic)
          (RETRIES = 180)
          (DELAY = 5)  
     )
   )
 )

查看Listener

SQL> show parameter listener; 

NAME                     TYPE    VALUE
------------------------------------ ----------- ------------------------------
listener_networks            string
local_listener               string   (ADDRESS=(PROTOCOL=TCP)(HOST=
                         192.168.20.109)(PORT=1521))
remote_listener              string  oda-scan:1521
SQL> quit

[ 编辑 | 历史 ]
最近由“jilili”在“2021-04-11 13:41:41”修改