Linux

如何在 Linux 集群上設置虛擬 IP?

  • May 11, 2012

我在設置虛擬 IP 和 Linux (Ubuntu) 集群時遇到了一些問題,希望有人能提供幫助。這是我嘗試設置的第一個節點集群,我沒有找到很多關於這個問題的資源。

我正在閱讀本指南以在 Ubuntu 上設置 DRBD/虛擬 IP:https ://wiki.edubuntu.org/ClusterStack/Natty#HA_Virtual_IP_Address

但是我在設置虛擬 IP 時遇到了一些重大問題。我已經設置了 DRBD,它可以毫無問題地同步和載入。但是當我嘗試添加虛擬 IP 時,我收到以下錯誤消息

pengine: [843]: info: native_color: Resource virtual_ip cannot run anywhere

這是我的 CRM 配置:

node EOA-MAIL-IB-1
node EOA-MAIL-IB-2
primitive drbd_eoa ocf:linbit:drbd \
   params drbd_resource="eoa-ib" \
   op monitor interval="15s"
primitive fs_drbd ocf:heartbeat:Filesystem \
   params device="/dev/drbd0" directory="/mnt" fstype="ext4" \
   meta target-role="Stopped"
primitive virtual_ip ocf:heartbeat:IPaddr2 \
   params ip="192.168.1.254" nic="eth1" \
   op monitor interval="30s"
group res_group fs_drbd virtual_ip
ms ms_drbd drbd_eoa \
   meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1$
colocation mnt_on_master inf: res_group ms_drbd:Master
order mount_after_drbd inf: ms_drbd:promote res_group:start
property $id="cib-bootstrap-options" \
   dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" \
   cluster-infrastructure="openais" \
   expected-quorum-votes="2" \
   stonith-enabled="false" \
   no-quorum-policy="ignore" \
   last-lrm-refresh="1336683121"

這是“crm 資源列表”的輸出:

Master/Slave Set: ms_drbd
Masters: [ EOA-MAIL-IB-1 ]
Slaves: [ EOA-MAIL-IB-2 ]
Resource Group: res_group
fs_drbd    (ocf::heartbeat:Filesystem) Stopped
virtual_ip (ocf::heartbeat:IPaddr2) Stopped

我在兩台伺服器上都安裝了兩個 NICS。

任何幫助將不勝感激。

謝謝!

原來 CRM 配置文件存在配置問題,請看圖。:)

以下是遇到此類問題的其他任何人的更新/正確配置文件:

node EOA-MAIL-IB-1
node EOA-MAIL-IB-2
primitive drbd_eoa ocf:linbit:drbd \
   params drbd_resource="eoa-ib" \
   op monitor interval="120s" \
op start interval="0" timeout="240s" \
op stop interval="0" timeout="100s"

primitive fs_drbd ocf:heartbeat:Filesystem \
   params device="/dev/drbd0" directory="/mnt/eoacluster" fstype="ext4" \
   op start interval="0" timeout="60s" \
op stop interval="0" timeout="60s"

primitive mysql_eoa ocf:heartbeat:mysql \
   params config="/etc/mysql/my.cnf" datadir="/mnt/eoacluster/mysql" \
binary="/usr/bin/mysqld_safe" pid="/var/run/mysql/mysql.pid" \
socket="/var/run/mysql/mysql.sock" log="/var/log/mysql/mysql.log" \
additional_parameters="--bind-address=192.168.1.254" \
   op start interval="0" timeout="120s" \
   op stop interval="0" timeout="120s" \
   op monitor interval="15s" user="mysql" group="mysql"

primitive virtual_ip ocf:heartbeat:IPaddr2 \
   params ip="192.168.1.254" nic="eth1" \
   op monitor interval="10s" \
meta is-managed="true"

group res_group virtual_ip fs_drbd mysql_eoa \
meta target-role="Started"

ms ms_drbd drbd_eoa \
   meta master-max="1" master-node-max="1" \
clone-max="2" clone-node-max="1" notify="true" \
target-role="Started"

location master-prefer-EOA-MAIL-IB-1 virtual_ip 25: EOA-MAIL-IB-1

colocation res_group_on_drbd_eoa inf: res_group ms_drbd:Master

order res_group_after_ms_drbd inf: ms_drbd:promote res_group:start

property $id="cib-bootstrap-options" \
   dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" \
   cluster-infrastructure="openais" \
   expected-quorum-votes="2" \
   stonith-enabled="false" \
   no-quorum-policy="ignore" \
   last-lrm-refresh="1336683121"

引用自:https://serverfault.com/questions/388097