《Linux服务器调优(多网卡绑定技术)》要点:
本文介绍了Linux服务器调优(多网卡绑定技术),希望对您有用。如果有疑问,可以联系我们。
一、网络状态查看:
ss
netstat
iftop
iptraf
ethtool
ss代替netstat
ss -t -a
Display all TCP sockets.
ss -t -n--查看所已经连接上的TCP
ss -t -l -n--查看所有正在监听的TCP
ss -u -a
Display all UDP sockets.
ss -o state established ’( dport = :ssh or sport = :ssh )’
Display all established ssh connections.
ss -x src /tmp/.X11-unix/*
Find all local processes connected to X server.
ip代替ifconfig/route
ip link set DEVICE { up | down }--开启或者关闭网卡
ip link show [ DEVICE ]--查看网卡连接状态
ip addr { add | del } IFADDR dev STRING--添加IP地址
ip addr show {eth0 | eth1}--查看某个网卡的IP地址
ip route list--查看路由表
ip route add to 192.168.10.0/24 via 192.168.100.1
ip route add to 192.168.20.0/24 dev eth0--添加一条默认路由
ip route add to 0/0 via 192.168.100.1--添加默认路由
ip route del to 0/0 dev eth0--删除默认路由
# ethtool eth0--查看当前网卡的硬件信息
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Link detected: yes
二、更改速率及网卡的协商模式:
# ethtool -s eth0 speed 100 duplex full autoneg off
网卡绑定技术有助于保证高可用性特性并提供其它优势以提高网络性能,在这介绍的Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两块网卡具有相同的IP地址而并行链接聚合成一个逻辑链路工作,这样即使其中的一块物理网卡出现故障,也不会导致连接中断.
网卡绑定就是多张网卡逻辑上作为一张网卡用.可分为,负载均衡绑定和冗余绑定两种.
1、负载均衡:
# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.0.100
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.0
GATEWAY=192.168.0.254
ONBOOT=yes
BOOTPROTO=static
TYPE=BOND
BONDING_OPTS="mode=0 miimon=50"
2.编辑各网卡的配置文件
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
# vim /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3、加载内核模块
# vim /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=50 mode=0--mode=[0(banance-rr) | 1(active-backup)]
# modprobe bonding
4、重启服务:
# /etc/init.d/network restart
5、查看
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.1 (October 29, 2006)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 1
Permanent HW addr: 00:1b:b9:58:8b:b2
Slave Interface: eth1
MII Status: down
Link Failure Count: 0
Permanent HW addr: 00:07:40:6c:ac:c8
维易PHP培训学院每天发布《Linux服务器调优(多网卡绑定技术)》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。
转载请注明本页网址:
http://www.vephp.com/jiaocheng/8001.html