LVS的配置詳解配置
2024-07-21 02:36:29
供稿:網(wǎng)友
Red Hat Cluster Manager
安裝操作系統(tǒng),選擇組件advance server,安裝LVS部分。
兩臺主機(jī),主機(jī)名為haha和hehe
主機(jī)haha的本地ip地址為net0:192.168.2.11,net1:192.168.2.14
主機(jī)hehe的本地ip地址為net0:192.168.2.12,net1:192.168.2.16
(主機(jī)網(wǎng)絡(luò)連線只能用直連線進(jìn)行連接,不能用交叉線連接,否則雙機(jī)不能進(jìn)行監(jiān)控)
修改/etc/hosts文件,封掉localhost行的內(nèi)容,寫入本地主機(jī)、對方主機(jī)和虛擬主機(jī)相應(yīng)的ip地址和主機(jī)名:(兩臺主機(jī)配置相同)
192.168.2.11 haha
192.168.2.12 hehe
192.168.2.13 xixi
進(jìn)入/etc/sysconfig/rawdevices文件,增加兩行內(nèi)容:(兩臺主機(jī)設(shè)置相同)
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdb2
以上兩行是LVS需要的兩個(gè)裸設(shè)備作為系統(tǒng)監(jiān)控使用,每個(gè)裸設(shè)備的空間不能小于10M。當(dāng)然需要fdisk建立兩個(gè)兩個(gè)相應(yīng)的設(shè)備。
然后從起主機(jī),進(jìn)入/sbin下,./clUConfig進(jìn)行cluster的配置:
Red Hat Cluster Manager Configuration Utility (running on haha) --haha為本地主機(jī)名
Enter cluster name [Red Hat Cluster Manager]:xixi --xixi為虛擬主機(jī)名
Enter IP address for cluster alias [NONE]:192.168.2.13 --地址為虛擬地址
--------------------------------
Information for Cluster Member 0
--------------------------------
Enter name of cluster member [haha]: --本地成員,回車即可
Enter number of heartbeat channels (minimum = 1) [1]: 2 --兩塊網(wǎng)卡心跳線(也可串口心跳)
Channel type: net or serial [net]: --第一塊網(wǎng)卡做心跳
Enter hostname of the cluster member on heartbeat channel 0 [haha]: --心跳線成員名稱
Channel type: net or serial [net]: --第二塊網(wǎng)卡做心跳線
Enter hostname of the cluster member on heartbeat channel 1:hehe --另外一個(gè)成員名稱
Information about Quorum Partitions
Enter PRimary Quorum Partition [/dev/raw/raw1]:
Enter Shadow Quorum Partition [/dev/raw/raw2]:
Information About the Power Switch That Power Cycles Member 'haha'
Choose one of the following power switches:
o NONE
o RPS10
o BAYTECH
o APCSERIAL
o APCMASTER
o WTI_NPS
o SW_WATCHDOG
Power switch [NONE]:
--------------------------------
Information for Cluster Member 1
--------------------------------
Enter name of cluster member:hehe --對方成員名
Enter hostname of the cluster member on heartbeat channel 0: hehe
Enter hostname of the cluster member on heartbeat channel 1: haha
Information about Quorum Partitions
Enter Primary Quorum Partition [/dev/raw/raw1]:
Enter Shadow Quorum Partition [/dev/raw/raw2]:
Information About the Power Switch That Power Cycles Member 'hehe'
Choose one of the following power switches:
o NONE
o RPS10
o BAYTECH
o APCSERIAL
o APCMASTER
o WTI_NPS
o SW_WATCHDOG
Power switch [NONE]:
Save the cluster member information?
yes/no [yes]: --對配置信息進(jìn)行保存
Save the cluster member information? yes/no [yes]:
Writing to configuration file...done
Configuration information has been saved to /etc/cluster.conf.
----------------------------
Setting up Quorum Partitions
----------------------------
Running cludiskutil -I to initialize the quorum partitions: done
Saving configuration information to quorum partitions: done
Do you wish to allow remote monitoring of the cluster? yes/no [yes]: --是否答應(yīng)遠(yuǎn)程主機(jī)進(jìn)行cluster監(jiān)視訪問
Configuration on this member is complete.
To configure the next member, invoke the following command on that system:
# /sbin/cluconfig --init=/dev/raw/raw1
Refer to the Red Hat Cluster Manager Installation and Administration Guide
for details.
本地主機(jī)配置完成
進(jìn)入對方主機(jī)的/sbin目錄,執(zhí)行cluconfig –init=/dev/raw/raw1顯示信息如下:
Information about Channel 0
/sbin/cluconfig: [: haha: unary Operator eXPected
Looking for host haha (may take a few seconds)...
Information about Channel 1
/sbin/cluconfig: [: hehe: unary operator expected
Looking for host hehe (may take a few seconds)...
Information about Quorum Partitions
Information About the Power Switch That Power Cycles Member 'haha'
Note: Operating a cluster without a remote power switch does not pr
maximum data integrity guarantees.
--------------------------------
Information for Cluster Member 1
--------------------------------
/sbin/cluconfig: [: hehe: unary operator expected
Looking for host hehe (may take a few seconds)...
Information about Channel 0
/sbin/cluconfig: [: hehe: unary operator expected
Looking for host hehe (may take a few seconds)...
Information about Channel 1
/sbin/cluconfig: [: haha: unary operator expected
Looking for host haha (may take a few seconds)...
Hostname does not map to any interface. Keep your selection? [yes]:
Information about Quorum Partitions
Information About the Power Switch That Power Cycles Member 'hehe'
Note: Operating a cluster without a remote power switch does not provide
maximum data integrity guarantees.
Press to continue. --按回車?yán)^續(xù)
Cluster name: xixi
Cluster alias IP address: 192.168.2.13
--------------------
Member 0 Information
--------------------
Name: haha
Primary quorum partition: /dev/raw/raw1
Shadow quorum partition: /dev/raw/raw2
Heartbeat channels: 2
Channel type: net, Name: haha
Channel type: net, Name: hehe
Power switch IP address or hostname: haha
Identifier on power controller for member haha: un
--------------------
Member 1 Information
--------------------
Name: hehe
Primary quorum partition: /dev/raw/raw1
Shadow quorum partition: /dev/raw/raw2
Heartbeat channels: 2
Channel type: net, Name: hehe
Channel type: net, Name: haha
Power switch IP address or hostname: hehe
Identifier on power controller for member hehe: un
--------------------------
Power Switch 0 Information
--------------------------
Power switch IP address or hostname: haha
Type: NONE
Login or port: unused
PassWord: unused
--------------------------
Power Switch 1 Information
--------------------------
Power switch IP address or hostname: hehe
Type: NONE
Login or port: unused
Password: unused
Save the cluster member information?
yes/no [yes]: --是否進(jìn)行保存
Writing to configuration file...done
Configuration information has been saved to /etc/cluster.conf.
Saving configuration information to quorum partitions: done
Do you wish to allow remote monitoring of the cluster? yes/no [yes]:
----------------------------------------------------------------
Configuration on this member is complete.
Execute "/sbin/service cluster start" to start the cluster software.
這時(shí),雙機(jī)軟件基本配置已經(jīng)完成,在兩臺主機(jī)上分別運(yùn)行service cluster start啟動服務(wù)
通過cluadmin進(jìn)行治理,如下所示:
cluadmin> cluster status
Cluster Status Monitor (xixi) 11:16:11
Cluster alias: xixi
========================= M e m b e r S t a t u s ==========================
Member Status Node Id Power Switch
-------------- ---------- ---------- ------------
haha Up 0 Good
hehe Up 1 Good
========================= H e a r t b e a t S t a t u s ====================
Name Type Status
------------------------------ ---------- ------------
haha <--> hehe network ONLINE
============