oracle 11gr2 rac中的4种IP解说
关于在配置oracle11gr2rac时的4种IP,有不少朋友对此很迷惑,本文在此解说一下。打开一个RAC节点的/etc/hosts文件cat/etc/hosts#PublicIP192.168.1.138rac1.loca
关于在配置oracle 11gr2 rac时的4种IP,有不少朋友对此很迷惑,本文在此解说一下。
打开一个RAC节点的/etc/hosts文件
cat /etc/hosts
# Public IP
192.168.1.138rac1.localdomain rac1
192.168.1.139rac2.localdomain rac2
#Private IP
172.16.10.138rac1-priv.localdomain rac1-priv
172.16.10.139rac2-priv.localdomain rac2-priv
#Virtual IP
192.168.1.140 rac1-vip.localdomain rac1-vip
192.168.1.141 rac2-vip.localdomain rac2-vip
#SCAN IP
192.168.1.142 rac-scan.localdomain rac-scan
这个文件里设计四种IP,分别有Public IP、Private IP、Virtual IP、SCAN IP
private ip:即内部IP。用于节点间的通信,通信内容包括network heartbeat和cache fusion
public ip:即外部IP。用于提供对外数据服务。
Virtual IP:即虚拟IP。其最大作用是用于故障切换。
Oracle RAC中每个节点都有一个虚拟IP,,简称VIP, 与公网PUBLIC IP在同一个网段。vip 附属在public网口接口。
Virtual IP和PUBLIC IP最主要的不同之处在于:VIP是浮动的,而PUBLIC IP是固定的。在所有节点都正常运行时,每个节点的VIP会被分配到public NIC上;在linux下ifconfig查看,public网卡上是2个IP地址;如果一个节点宕机,这个节点的VIP会被转移到还在运行的节点上。也就是幸存的节点的public NIC这个网卡上,会有3个IP地址。
如果没有vip,连接失败节点的process会有一个比较长的tcp超时等待,才能返回错误,有了vip后,节点失效后,由于vip漂移到其它节点,连接该vip的process很快就能返回错误,从而更快的尝试连接其它活动的节点,避免客户端反复连接node1的实例。 如果应用程序和客户机都配置了透明的应用程序故障转移选项,可以在客户端重新连接到剩余的实例。
使用Virtual ip的另一个原因,我认为是负载均衡。客户端在配置tnsnames.ora时,有些场合是要使用的vip,而有些场合又必须使用Public IP。例如,当你在定位一个数据库的死锁时,使用Public IP,可以确保连到你想处理的机器。相反此时使用VIP时,会出现不确定性,因为服务器默认是开启负载均衡的,也就是有可能你想连A机,系统却给你分配了B机。
SCAN IP:在oracle 11gR2中,SCAN IP是作为一个新增IP出现的, scan ip其实是oracle在客户端与数据库之间,新加的一个连接层,当有客户端访问时,连接到 SCAN IP LISTENER, 而SCAN IP LISTENER接收到连接请求时,会根据 LBA 算法将该客户端的连接请求,转发给对应的instance上的VIP LISTENER,从而完成了整个客户端与服务器的连接过程。简化如下:
client -> scan listener -> local listener -> local instance
你也可以把scan理解为一个虚拟主机名,它对应的是整个RAC集群。客户端主机只需通过这个scan name即可访问数据库集群的任意节点。当然访问的节点是随机的,oracle强烈建议通过DNS Server的round robin模式配置解析SCAN,实现负载均衡(即轮换连接SCAN对应的IP地址)。这有点类似通过vip和listener loadbalance配置实现负载均衡的原理。
那么有了Virtual ip后为什么还增加了一个SCAN IP呢?
在oracle 11.2之前,client链接数据库的时候要用vip,假如你的oracle cluster有4个节点,那么客户端的tnsnames.ora中就对应有四个主机vip的一个连接串,如果cluster增加了一个节点,那么对于每个连接数据库的客户端都需要修改这个tnsnames.ora。
引入了scan以后,就方便了客户端连接的一个接口,顾名思义 single client access name ,简单客户端连接名,这是一个唯一的名称,在整个公司网络内部唯一,并且在DNS中可以解析为三个ip地址,客户端连接的时候只需要知道这个名称,并连接即可, 每个SCAN VIP对应一个scan listener,cluster内部的service在每个scan listener上都有注册,scan listener接受客户端的请求,并foward到不同的Local listener中去,还是由local 的listener提供服务给客户端。
scan ip主要是为了简化客户端连接,假如你的oracle 集群有20个节点,客户端连接的时候,是不是需要配置20个vip,如果用scan,只需要一个scan name就行了,剩下的事情,scan帮你做了。
本文出自 “滴水穿石孙杰” 博客,请务必保留此出处

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.
