关于虚拟 IP
10g 中为什么使用虚拟 IP (VIP)?为什么当它的主节点发生故障时它只是返回一个无效的连接?
这全是出于对应用程序可用性的考虑。当一个节点发生故障时,与其关联的 VIP 将被自动故障切换到另外某个节点上。当出现这种情况时,会发生两件事。
1. 新的节点重新进行地址解析,显示该地址的一个新的 MAC 地址。对于直连客户端,这通常使它们在连接旧地址时出现错误。
2. 到 VIP 的后续数据包将被传送到新的节点,该节点将把错误 RST 数据包返回客户端。这导致客户端立即收到错误信息。
这意味着,当客户端向故障节点发出 SQL 时,或者在连接状态下遍历地址列表时,客户端会接收到一个 TCP 重置信息,而不是等待很长的 TCP/IP 超时(大约 10 分钟)。发送 SQL 时,该信息为 ORA-3113。而连接时,使用 tnsname 中的下一个地址。
更进一步的操作是使用透明的应用程序故障切换 (TAF)。成功配置 TAF 后,就可以完全避免 ORA-3113 错误!第 31 节(“透明的应用程序故障切换 — (TAF)”)将更详细地介绍 TAF。
如果不使用 VIP,连接停用节点的客户端经常要等待 10 分钟的 TCP 超时,然后才收到错误信息。因此,如果没有 VIP, 用户将不能真正拥有一流的高可用性解决方案(来源 — Metalink 说明 220970.1)。
确保 RAC 节点名没有出现在环回地址中
确保在 /etc/hosts 文件的环回地址中不包含节点名(linux1 或 linux2)。如果机器名出现在环回地址条目中,如下所示:
127.0.0.1 linux1 localhost.localdomain localhost
需要按如下所示将其删除:
127.0.0.1 localhost.localdomain localhost
如果 RAC 节点名出现在环回地址中,您在 RAC 安装期间将接收到以下错误信息:
ORA-00603: ORACLE server session terminated by fatal error
或者
ORA-29702: error occurred in Cluster Group Service operation
验证 localhost 在 /etc/hosts 文件中定义为回送地址
确保 localhost.localdomain 和 localhost 项作为回送地址包含在每个 Oracle RAC 节点的 /etc/hosts 文件中:
127.0.0.1 localhost.localdomain localhost
如果 /etc/hosts 文件中不存在 localhost 项,Oracle 集群件将无法启动应用程序资源 — 特别是 ONS 进程。该错误将指明“Failed to get IP for localhost”并写入 ONS 的日志文件。例如:
CRS-0215 could not start resource 'ora.linux1.ons'. Check log file
"/u01/app/crs/log/linux1/racg/ora.linux1.ons.log"
for more details.
ONS 日志文件包含类似以下内容的行:
Oracle Database 10g CRS Release 10.2.0.1.0 Production Copyright 1996, 2005 Oracle.保留所有权利。
2007-04-14 13:10:02.729: [ RACG][3086871296][13316][3086871296][ora.linux1.ons]:Failed to get IP for localhost (1)
Failed to get IP for localhost (1)
Failed to get IP for localhost (1)
onsctl:ons failed to start
...
调整网络设置
在 Oracle 9.2.0.1 以及更高版本中,Oracle 在 Linux 上使用 UDP 作为进行过程间通信 (IPC) 的默认协议,如在 RAC 集群中实例之间的缓存融合和集群管理器缓冲区传输。
Oracle 强烈建议将默认的和最大的接收缓冲区大小(SO_RCVBUF 套接字选项)调整为 1MB,并将默认的和最大的发送缓冲区大小(SO_SNDBUF 套接字选项)调整为 256KB。
接收缓冲区由 TCP 和 UDP 用于保留所接收的数据,直到应用程序读出这些数据为止。由于不允许对端设备发送超过缓冲区大小窗口的数据,因此接收缓冲区不会溢出。这意味着,不适合套接字接收缓冲区可能导致发送设备发送的信息淹没接收设备的数据报将会被丢弃。
您无需重新引导即可在 /proc 文件系统中更改默认的和最大的窗口大小:
# su - root
# sysctl -w net.core.rmem_default=1048576
net.core.rmem_default = 1048576
# sysctl -w net.core.rmem_max=1048576
net.core.rmem_max = 1048576
# sysctl -w net.core.wmem_default=262144
net.core.wmem_default = 262144
# sysctl -w net.core.wmem_max=262144
net.core.wmem_max = 262144
以上命令更改正在运行的操作系统。现在,将以下各行程序添加到 RAC 集群中两个节点的 /etc/sysctl.conf 文件中,使以上更改永久生效(针对每次重新引导而言):
# +---------------------------------------------------------+
# | ADJUSTING NETWORK SETTINGS |
# +---------------------------------------------------------+
# | With Oracle 9.2.0.1 and onwards, Oracle now makes use |
# | of UDP as the default protocol on Linux for |
# | inter-process communication (IPC), such as Cache Fusion |
# | and Cluster Manager buffer transfers between instances |
# | within the RAC cluster. Oracle strongly suggests to |
# | adjust the default and maximum receive buffer size |
# | (SO_RCVBUF socket option) to 1024 KB, and the default |
# | and maximum send buffer size (SO_SNDBUF socket option) |
# | to 256 KB. The receive buffers are used by TCP and UDP |
# | to hold received data until it is read by the |
# | application. The receive buffer cannot overflow because |
# | the peer is not allowed to send data beyond the buffer |
# | size window. This means that datagrams will be |
# | discarded if they don't fit in the socket receive |
# | buffer. This could cause the sender to overwhelm the |
# | receiver. |
# +---------------------------------------------------------+
# +---------------------------------------------------------+
# | Default setting in bytes of the socket "receive" buffer |
# | which may be set by using the SO_RCVBUF socket option. |
# +---------------------------------------------------------+
net.core.rmem_default=1048576
# +---------------------------------------------------------+
# | Maximum setting in bytes of the socket "receive" buffer |
# | which may be set by using the SO_RCVBUF socket option. |
# +---------------------------------------------------------+
net.core.rmem_max=1048576
# +---------------------------------------------------------+
# | Default setting in bytes of the socket "send" buffer |
# | which may be set by using the SO_SNDBUF socket option. |
# +---------------------------------------------------------+
net.core.wmem_default=262144
# +---------------------------------------------------------+
# | Maximum setting in bytes of the socket "send" buffer |
# | which may be set by using the SO_SNDBUF socket option. |
# +---------------------------------------------------------+
net.core.wmem_max=262144
检查并关闭 UDP ICMP 拒绝
在 Linux 安装期间,我指示不配置防火墙选项。默认情况下,配置防火墙的选项由安装程序选择。这使我吃了好几次苦头,因此我要仔细检查防火墙选项是否未配置,并确保 udp ICMP 过滤已关闭。
如果 UDP ICMP 被防火墙阻塞或拒绝,Oracle 集群件软件将在运行几分钟之后崩溃。如果 Oracle 集群件进程出现故障,您的 <machine_name>_evmocr.log 文件中将出现以下类似内容:
08/29/2005 22:17:19
oac_init:2: Could not connect to server, clsc retcode = 9
08/29/2005 22:17:19
a_init:12!: Client init unsuccessful : [32]
ibctx:1:ERROR: INVALID FORMAT
proprinit:problem reading the bootblock or superbloc 22
如果遇到此类错误,解决方法是删除 udp ICMP (iptables) 拒绝规则,或者干脆关闭防火墙选项。之后,Oracle 集群件软件将开始正常工作,而不会崩溃。以下命令应该以 root 用户帐户的身份执行:
1. 检查以确保防火墙选项关闭。如果防火墙选项已停用(如下面的示例所示),则不必继续执行以下步骤。
# /etc/rc.d/init.d/iptables status
Firewall is stopped.
2. 如果防火墙选项已启用,您首先需要手动停用 UDP ICMP 拒绝:
# /etc/rc.d/init.d/iptables stop
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
3. 然后,针对下一次服务器重新引导关闭 UDP ICMP 拒绝(应该始终被关闭):
# chkconfig iptables off
关于虚拟 IP
最新推荐文章于 2023-08-14 16:56:00 发布