如何在kickstart脚本中既配置br,又配置bonding呢?
基本篇:
以Dell R730为例,物理网卡名称是em1/em2/em3/em4
network --device=br0 --noipv6 --onboot=yes --bridgeslaves=bond0 --gateway=172.16.37.254 --ip=172.16.36.2 --nameserver=172.16.8.1 --netmask=255.255.254.0 --activate
network --device=bond0 --noipv6 --onboot=yes --bondslaves=em1,em2 --bondopts=mode=active-backup,balance-rr;primary=em1,miimon=80,updelay=60000 --activate
network --device=em1 --noipv6 --nodns --onboot=yes --activate
network --device=em2 --noipv6 --nodns --onboot=yes --activate
network --device=em3 --noipv6 --nodns --onboot=yes --activate
network --device=em4 --noipv6 --nodns --onboot=yes --activate
network --hostname=myhost-16-36-2
注意以上,是只做了 em1 和 em2 绑定成为 bond0 ,然后 br0 启动在 bond0 之上。
进阶篇:
基本篇的做法固然是做了四网卡绑定和桥接,副作用也是很可怕的。
大家去看/etc/sysconfig/network-scripts, 里面有一堆的ifcfg-br0-slave_1,ifcfg-bond0-slave_1, ifcfg-bond0-slave_2,更可恶的是进程中跑着好几个dhcp-client,一想就明白了,这是NetworkManager搞得。em3和em4不断去启停端口,试图获得地址,导致交换机端口忽断忽通。
这个试图自动化网络的东西在服务器跑上实在是太无聊了。
所以上面的做法摒弃。在%post把网络搞好:
...
%packages
@compat-libraries
@core
wget
net-tools
chrony
bridge-utils
%end
...
network --bootproto=static --device=em1 --noipv6 --nodns --onboot=yes --gateway=172.16.37.254 --ip=172.16.36.2 --nameserver=172.16.8.1 --netmask=255.255.254.0
network --bootproto=dhcp --device=em2 --noipv6 --nodns --onboot=no
network --bootproto=dhcp --device=em3 --noipv6 --nodns --onboot=no
network --bootproto=dhcp --device=em4 --noipv6 --nodns --onboot=no
network --hostname=myhost-16-36-2
...
%post
yum -y erase NetworkManager
cat </etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=172.16.36.2
NETMASK=255.255.254.0
GATEWAY=172.16.37.254
EOF
cat < /etc/modprobe.d/bonding.conf
alias bond0 bonding
BONDING_OPTS="miimon=100 mode=1 primary=em1"
EOF
cat < /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
USERCTL=no
BRIDGE=br0
EOF
cat < /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BRIDGE="br0"
EOF
cat < /etc/sysconfig/network-scripts/ifcfg-em2
DEVICE=em2
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BRIDGE="br0"
EOF
%end
注意上面,安装包必须安装bridge-utils,否则没有brctl,无法启动br0。
其次是卸载了NetworkManager,服务器网络都是手动配的,没人用自动化管理。
这样就完美了。