Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
informatique:linux:bonding [2008/07/09 12:02] benoit |
informatique:linux:bonding [2018/09/06 19:10] (Version actuelle) |
||
---|---|---|---|
Ligne 121: | Ligne 121: | ||
Sous Red-Hat/Suse | Sous Red-Hat/Suse | ||
Dans /etc/sysconfig/network/, créé ifcfg-bond0 : | Dans /etc/sysconfig/network/, créé ifcfg-bond0 : | ||
- | /etc/sysconfig/network/fcfg-bond0 | + | /etc/sysconfig/network/ifcfg-bond0 |
ONBOOT=yes | ONBOOT=yes | ||
Ligne 223: | Ligne 223: | ||
La redondance des cartes réseaux est souvent perçue comme inutile et couteuse malgré une installation simple. | La redondance des cartes réseaux est souvent perçue comme inutile et couteuse malgré une installation simple. | ||
Avec ces 7 modes de fonctionnements, vous avez la possibilité d'obtenir une interface réseau haute disponibilité, répondant même à des besoins précis pour le load-balancing. Alors pourquoi s'en priver? | Avec ces 7 modes de fonctionnements, vous avez la possibilité d'obtenir une interface réseau haute disponibilité, répondant même à des besoins précis pour le load-balancing. Alors pourquoi s'en priver? | ||
+ | |||
+ | |||
===== 5. Script de configuration automatique sous Redhat ===== | ===== 5. Script de configuration automatique sous Redhat ===== | ||
Ligne 228: | Ligne 230: | ||
##### modification utilisateur ########## | ##### modification utilisateur ########## | ||
# Mettre ici le nom de l'interface maitre | # Mettre ici le nom de l'interface maitre | ||
- | bondname="bond0" | + | bond0name="bond0" |
- | # indiquer ici les interfaces esclaves | + | bond0if0="eth4" |
+ | bond0if1="eth7" | ||
+ | bond0ip="10.3.0.5" | ||
+ | bond0mask="255.255.0.0" | ||
+ | bond0speed="1000" | ||
+ | bond0mode="4" # agregation des liens | ||
+ | |||
+ | bond1name="bond1" | ||
+ | bond1if0="eth5" | ||
+ | bond1if1="eth6" | ||
+ | bond1ip="10.4.0.5" | ||
+ | bond1mask="255.255.0.0" | ||
+ | bond1speed="1000" | ||
+ | bond1mode="4" # agregation des liens | ||
+ | | ||
#mode="0" # equilibrage de charge | #mode="0" # equilibrage de charge | ||
- | mode="1" # sauvegarde active | + | #mode="1" # sauvegarde active |
#mode="2" # balance Xor | #mode="2" # balance Xor | ||
#mode="3" # broadcast | #mode="3" # broadcast | ||
Ligne 238: | Ligne 254: | ||
#mode="6" # adaptive load balancing | #mode="6" # adaptive load balancing | ||
######## fin modif utilisateur ######### | ######## fin modif utilisateur ######### | ||
- | echo "alias $bondname bonding" >> /etc/modprobe.conf | + | |
- | echo "options $bondname -o bond0 mode=$mode miimon=100" >> /etc/modprobe.conf | + | |
- | cat <<EOF >> /etc/sysconfig/network-scripts/ifcfg-$bondname | + | #---- debut configuration de bond0 |
- | ONBOOT=yes | + | grep ${bond0name} /etc/modprobe.conf >> /dev/null 2>&1 |
- | DEVICE=$bondname | + | if [ "$?" != "0" ] |
- | BOOTPROTO=static | + | then |
- | IPADDR= | + | cat <<EOF >> /etc/modprobe.conf |
- | NETMASK= | + | alias ${bond0name} bonding |
- | GATEWAY= | + | options ${bond0name} mode=${bond0mode} miimon=100 max_bonds=2 |
EOF | EOF | ||
- | cp /etc/sysconfig/network-scripts/ifcfg-$nic1 $HOME/ifcfg-${nic1}_`date +%F-%H-%M` | + | fi |
- | cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$nic1 | + | |
+ | # Configuration des interfaces physiques | ||
+ | for interface in ${bond0if0} ${bond0if1} | ||
+ | do | ||
+ | cp /etc/sysconfig/network-scripts/ifcfg-${interface} $HOME/ifcfg-${interface}_`date +%F-%H-%M` | ||
+ | cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-${interface} | ||
ONBOOT=yes | ONBOOT=yes | ||
- | DEVICE=$nic1 | + | DEVICE=${interface} |
- | MASTER=$bondname | + | MASTER=${bond0name} |
SLAVE=yes | SLAVE=yes | ||
- | ETHTOOL_OPTS="speed 100 duplex full autoneg off" | + | ETHTOOL_OPTS="speed ${bond0speed} duplex full autoneg off" |
- | POST_UP_SCRIPT=ifen$nic1 | + | POST_UP_SCRIPT=ifen${interface} |
EOF | EOF | ||
- | cp /etc/sysconfig/network-scripts/ifcfg-$nic2 $HOME/ifcfg-${nic2}_`date +%F-%H-%M` | + | |
- | cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$nic2 | + | # Creation des scripts de mise en esclaces des interfaces physiques |
+ | cat << EOF > /etc/sysconfig/network-scripts/ifen${interface} | ||
+ | #!/bin/sh | ||
+ | ifenslave ${bond0name} ${interface} | ||
+ | EOF | ||
+ | chmod +x /etc/sysconfig/network-scripts/ifen${interface} | ||
+ | |||
+ | # Configuration de l'interface | ||
+ | cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-${bond0name} | ||
ONBOOT=yes | ONBOOT=yes | ||
- | DEVICE=$nic2 | + | DEVICE=${bond0name} |
- | MASTER=$bondname | + | BOOTPROTO=static |
+ | IPADDR=${bond0ip} | ||
+ | NETMASK=${bond0mask} | ||
+ | EOF | ||
+ | done | ||
+ | #---- fin configuration de bond0 | ||
+ | |||
+ | if [ ${bond1name} ] | ||
+ | then | ||
+ | #---- debut configuration de bond1 | ||
+ | grep ${bond1name} /etc/modprobe.conf >> /dev/null 2>&1 | ||
+ | if [ "$?" != "0" ] | ||
+ | then | ||
+ | cat <<EOF >> /etc/modprobe.conf | ||
+ | alias ${bond1name} bonding | ||
+ | options ${bond1name} mode=${bond1mode} miimon=100 | ||
+ | EOF | ||
+ | fi | ||
+ | |||
+ | # Configuration des interfaces physiques | ||
+ | for interface in ${bond1if0} ${bond1if1} | ||
+ | do | ||
+ | cp /etc/sysconfig/network-scripts/ifcfg-${interface} $HOME/ifcfg-${interface}_`date +%F-%H-%M` | ||
+ | cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-${interface} | ||
+ | ONBOOT=yes | ||
+ | DEVICE=${interface} | ||
+ | MASTER=${bond1name} | ||
SLAVE=yes | SLAVE=yes | ||
- | ETHTOOL_OPTS="speed 100 duplex full autoneg off" | + | ETHTOOL_OPTS="speed ${bond1speed} duplex full autoneg off" |
- | POST_UP_SCRIPT=ifen$nic2 | + | POST_UP_SCRIPT=ifen${interface} |
EOF | EOF | ||
- | cat << EOF > /etc/sysconfig/network-scripts/ifen$nic1 | + | |
+ | # Creation des scripts de mise en esclaces des interfaces physiques | ||
+ | cat << EOF > /etc/sysconfig/network-scripts/ifen${interface} | ||
#!/bin/sh | #!/bin/sh | ||
- | ifenslave $bondname $nic1 | + | ifenslave ${bond1name} ${interface} |
EOF | EOF | ||
- | chmod +x /etc/sysconfig/network-scripts/ifen$nic1 | + | chmod +x /etc/sysconfig/network-scripts/ifen${interface} |
- | cat << EOF > /etc/sysconfig/network-scripts/ifen$nic2 | + | |
- | #!/bin/sh | + | # Configuration de l'interface |
- | ifenslave $bondname $nic2 | + | cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-${bond1name} |
+ | ONBOOT=yes | ||
+ | DEVICE=${bond1name} | ||
+ | BOOTPROTO=static | ||
+ | IPADDR=${bond1ip} | ||
+ | NETMASK=${bond1mask} | ||
EOF | EOF | ||
- | chmod +x /etc/sysconfig/network-scripts/ifen$nic2 | + | done |
+ | #---- fin configuration de bond1 | ||
+ | fi |