Bonding
balance ve failover iki Ağ Uyarlayıcısıyla Yükleme
- İlk önce her iki ağ arayüzüde aynı ip adresleri ile ayarlanmalı:
yast lan
- Yeni yük paylaşım aracını çekirdeğe tanıtmalısınız:
echo "alias bond0 bonding" >> /etc/modprobe.conf.local
- Sonra dizgeyi(sistemi) önyükleme yapın:
reboot
- /etc/init.d/bond yazarak yeni bir açılış dizini oluşturun:
cd /etc/init.d touch bond chmod 755 bond vi bond
- Aşağıdakileri bu paylaşım dosyasına kopyalayın:
#! /bin/sh
# Copyright (c) 2002-2006 bpm consult ag, CH-Birsfelden. All rights reserved.
# <support@bpm.ch>
#
### BEGIN INIT INFO
# Provides: bond
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Short-Description: bonding
# Description: load balancing between two or more ethernet interfaces
# Version: 1.0.2 08.02.2006
### END INIT INFO
#
# init.d/bond
logfile="/var/log/bond.log"
ifs=""
ifcounter=0
for if in `ifconfig | cut -c1-5 | grep "^eth"`
do
ifs="$ifs $if"
ifcounter=`expr $ifcounter + 1`
done
if [ $ifcounter -le 1 ]
then
echo "not enough interfaces for bonding"
exit 1
fi
. /etc/rc.status
rc_reset
case "$1" in
start) # start bonding:
echo -n "create bond interface "
date > $logfile
ip=`ifconfig eth0 | grep "inet addr" | cut -d":" -f2 | cut -d" " -f1`
bc=`ifconfig eth0 | grep "inet addr" | cut -d":" -f3 | cut -d" " -f1`
nm=`ifconfig eth0 | grep "inet addr" | cut -d":" -f4 | cut -d" " -f1`
gw=`netstat -rn | grep ^0 | cut -c17-32`
ifconfig bond0 $ip netmask $nm broadcast $bc >> $logfile 2>> $logfile
rc_status -v
echo -n "start bonding "
ifenslave bond0 $ifs >> $logfile 2>> $logfile
route add -net default gw $gw bond0
rc_status -v
;;
stop) # stop bonding:
echo -n "remove bond interface "
date > $logfile
ifconfig bond0 down >> $logfile 2>> $logfile
rc_status -v
echo -n "reactivate ethernet interfaces "
for if in $ifs
do
ifconfig $if up >> $logfile 2>> $logfile
done
rc_status -v
;;
status) # check bonding:
if [ `ifconfig | grep "^bond0" | wc -l` -eq 1 ]
then
echo "bond interface is loaded"
mac=`ifconfig | grep "^bond0" | cut -c39-`
for if in $ifs
do
if [ `ifconfig | grep "^$if" | cut -c39-` == $mac ]
then
echo "$if used in bond0"
fi
done
else
echo "bonding is disabled"
fi
;;
*) # invalid option:
echo "error: invalid argument"
echo "usage: $0 {start|stop|status}"
exit 1
;;
esac
rc_exit
- Son olarak ağ yük paylaşımını başlatabilirsiniz:
./bond start create bond interface done start bonding done ./bond status bond interface is loaded eth0 used in bond0 eth1 used in bond0
- Bunu dizge(sistem) açılışında otomatik olarak çalıştırmak için, aşağıdaki komutu kullanın:
insserv -d bond