Quantcast
Channel: 钻戒 and 仁豆米
Viewing all articles
Browse latest Browse all 290

PXE远程安装设定Bridge、Bonding的进阶篇

$
0
0

之前文章中说到远程用kickstart安装CentOS7的时候,怎样在ks文件中直接设定网卡绑定并桥接的方式,就是以下这个脚本:

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  

但是,这样固然是做了四网卡绑定和桥接,副作用也是很可怕的。 大家去看/etc/sysconfig/network-scripts, 里面有一堆的ifcfg-br0-slave1,ifcfg-bond0-slave1, ifcfg-bond0-slave_2,更可恶的是进程中跑着好几个dhcp-client,一想就明白了,这是NetworkManager搞得。em3和em4不断去启停端口,试图获得地址,导致交换机端口忽断忽通。

这个试图自动化网络的东西在服务器跑上实在是太无聊了。

所以上面的做法摒弃。在%post把网络搞好: ```language-bash ... %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,服务器网络都是手动配的,没人用自动化管理。

这样就完美了。


Viewing all articles
Browse latest Browse all 290

Trending Articles