实现MutiPathing的脚本(转贴:bj.163.com)
发表于:2007-06-09来源:作者:点击数:
标签:
#!/bin/sh #ThescriptisusedtoconfigureIPMultiPathing.Thecurrentversionis1.0.Lastrevised:29April2003 #Author:liuliang;plsvisit"http://china.homeunix.com",sendfeedbackto:liulianga@digitalchina.com #Notice: #1.Themachineisonlytwointerfacecardf
#!/bin/sh
# The script is used to configure IP MultiPathing.The current version is 1.0.Last revised: 29 April 2003
# Author:liuliang;pls visit "http://china.homeunix.com",send feedback to: liulianga@digitalchina.com
# Notice:
# 1.The machine is only two interface card for MutiPathing use
# Suppose:
# 1.Adapter group number is only one.
# 2.Network parameter isn't configured.
# The configuration of the IP Networking Multipathing daemon is set in the /etc/default/mpathd file.
Interface1=$1
Interface2=$2
DataAddress1=$3
DataAddress2=$4
TestAddress1=$5
TestAddress2=$6
AdapterGroupName=$7
HostName=`cat /etc/nodename`
mv /etc/hosts /etc/hosts.I
PMP
echo "127.0.0.1 localhost loghost" > /etc/hosts
echo "${DataAddress1} ${HostName} ${HostName}." >> /etc/hosts
echo "${DataAddress2} ${HostName}-1" >> /etc/hosts
echo "${TestAddress1} ${HostName}-${Interface1}" >> /etc/hosts
echo "${TestAddress2} ${HostName}-${Interface2}" >> /etc/hosts
# echo "{NetworkNumber} ${Netmask}" >> /etc
.netmasks
eeprom local-mac-address?=true
touch /etc/notrouter
cat <<EOF >/etc/rc2.d/S99IPMP
#!/bin/sh
Interface1=${Interface1}
Interface2=${Interface2}
DataAddress1=${DataAddress1}
DataAddress2=${DataAddress2}
TestAddress1=${TestAddress1}
TestAddress2=${TestAddress2}
AdapterGroupName=${AdapterGroupName}
HostName=${HostName}
ifconfig ${Interface1} plumb
ifconfig ${Interface2} plumb
ifconfig ${Interface1} group ${AdapterGroupName}
ifconfig ${Interface2} group ${AdapterGroupName}
ifconfig ${Interface1} ${HostName} netmask + broadcast + failover up
ifconfig ${Interface2} ${HostName}-1 netmask + broadcast + failover up
ifconfig ${Interface1} addif ${HostName}-${Interface1} netmask + broadcast + -failover deprecated up
ifconfig ${Interface2} addif ${HostName}-${Interface2} netmask + broadcast + -failover deprecated up
echo "${HostName} netmask + broadcast + failover up group ${AdapterGroupName} addif ${HostName}-${Interface1} netmask + broadcast + deprecated -failover up" > /etc/hostname.${Interface1}
echo "${HostName}-1 netmask + broadcast + failover up group ${AdapterGroupName} addif ${HostName}-${Interface2} netmask + broadcast + deprecated -failover up" > /etc/hostname.${Interface2}
rm /etc/rc2.d/S99IPMP
EOF
reboot
zorrozolo 回复于:2003-04-30 12:17:32
|
这个是efq卡多网口用的吗
|
韦小宝 回复于:2003-04-30 12:51:50
|
任何两个以太网卡都可以,不一定非得要4口网卡(X1034A,qfe),系统自带的eri0加上一块X1033(hme0)就可以了,注意,执行这个脚本前先清除原先的网络设置!
|
zorrozolo 回复于:2003-04-30 13:35:33
|
它可以干什么用啊?
|
韦小宝 回复于:2003-04-30 13:41:39
|
网卡冗余
|
mmmmn 回复于:2003-04-30 13:50:39
|
给出配置格式就很简单啊,非要写个脚本干吗?
|
sunmarmot 回复于:2003-05-12 13:51:59
|
有双网卡的服务器的IP地址使用Multipathing 技术
以一个简单的例子阐述Multipathing
其实与实际不一样的就是IP地址,以及网口类型,根据实际情况需要修改内容。
multipathing test IP 10.170.1.81
multipathing test IP 10.170.1.82
Logical IP 10.170.1.80
Group Name mswitch
Network Card ge0,ge1
一:使用命令方式(机器重新启动将失效)
1:Become superuser.
2:如果ge0,ge1被配置了IP,请使用如下命令清除ge0,ge1上配置信息
ifconfig ge0 unplumb
ifconfig ge1 unplumb
3:使用如下命令配置multipathing
ifconfig ge0 plumb 10.17.1.80 group mswitch netmask + broadcast + up
(使ge0可用,配置ge0的IP为Loical IP 10.17.1.80、使ge0为mswitch组的一块网卡)
ifconfig ge0 addif 10.170.1.81 deprecated -failover netmask + broadcast + up
(配置ge0的test ip为10.170.1.81)
ifconfig ge1 plumb 10.170.1.82 group mswitch netmask + broadcast + deprecated -failover standby up
(配置ge1为mswitch 组的另外一块网卡,它的test ip为10.170.1.82 并且这块网卡为standby)
4:以上为所有的配置命令,使用ifconfig –a命令将看到ge0、ge0:1、ge1的IP分别为10.17.1.80、10.17.1.81、10.17.1.82
5:测试。拔掉ge0的网线,使用ifconfig –a会发现10.170.1.80的地址failover到了ge1:1上。10.170.1.80这个地址可以正常使用。插回网线,会发现ge1:1没有了,10.17.1.80又回到了ge0上。
二:使用文件方式(机器重新启动后生效)
edit the /etc/hostname.ge0 file and add the following line.
10.170.1.80 netmask + broadcast + group mswitch up \
addif 10.170.1.81 deprecated -failover netmask + broadcast + up
edit the /etc/hostname.ge1 file and add the following line.
10.170.1.82 netmask + broadcast + group mswitch up deprecated -failover standby up
顶上来研究一下,我在测试的时候发现如果拔掉active的网卡的网线,standby的网卡会自动接管active的IP。但是如果我拔了standby的网线,active和standby网卡上IP还有漂移IP会全挂了,一个也通不了。在实际应用中一般两快网卡是互为备份的,如果这种情况出现,说明在standby的网卡上是一个没有冗余的故障点。兄弟,有解决的办法没??
|
sunmarmot 回复于:2003-05-12 13:53:52
|
up!!!!!!!
|
nnfirst 回复于:2003-05-12 21:46:45
|
好东西,收藏!
|
原文转自:http://www.ltesting.net