{"id":5163,"date":"2013-06-27T14:18:42","date_gmt":"2013-06-27T06:18:42","guid":{"rendered":"http:\/\/jpuyy.com\/?p=5163"},"modified":"2013-06-27T14:48:47","modified_gmt":"2013-06-27T06:48:47","slug":"linux-network-bonding","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=5163","title":{"rendered":"linux\u53cc\u7f51\u5361\u7ed1\u5b9a"},"content":{"rendered":"<p>\u4ee5\u4e0b\u64cd\u4f5c\u5747\u5728CentOS\u4e0b\uff0c\u7f51\u5361\u7ed1\u5b9a\u6709\u591a\u79cd\u6a21\u5f0f\uff0c\u8fd9\u91cc\u662f\u4e3a\u4e86\u589e\u52a0\u5e26\u5bbd<\/p>\n<p>\u5b89\u88c5\u9700\u8981\u7684\u7ec4\u4ef6<\/p>\n<pre>yum install ethtool -y<\/pre>\n<p>\u6dfb\u52a0\u4e00\u4e2aifcfg-bond0\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u505a\u4e3amaster\uff0c\u9700\u8981\u7ed1\u5b9a\u7684\u7269\u7406\u7f51\u5361(ifcfg-eth0, ifcfg-eth1)\u505a\u4e3aslave<\/p>\n<p>vim \/etc\/sysconfig\/network-scripts\/ifcfg-bond0<\/p>\n<p>\u6dfb\u52a0<\/p>\n<pre>DEVICE=bond0\r\nONBOOT=yes\r\nIPADDR=192.168.1.12\r\nNETMASK=255.255.255.0\r\nNETWORK=192.168.1.0\r\nUSERCTL=no\r\nBOOTPROTO=none<\/pre>\n<p>vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/p>\n<p>\u6dfb\u52a0<\/p>\n<pre>DEVICE=eth0\r\nONBOOT=yes\r\nUSERCTL=no\r\nMASTER=bond0\r\nSLAVE=yes\r\nBOOTPROTO=none<\/pre>\n<p>vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth1<\/p>\n<p>\u6dfb\u52a0<\/p>\n<pre>DEVICE=eth1\r\nONBOOT=yes\r\nUSERCTL=no\r\nMASTER=bond0\r\nSLAVE=yes\r\nBOOTPROTO=none<\/pre>\n<p>USERCTL=yes\/no \u662f\u5426\u5141\u8bb8\u975eroot\u7528\u6237\u63a7\u5236\u8be5\u8bbe\u5907<\/p>\n<p>BOOTPROTO=none\/static\/dhcp \u6307\u5b9a\u542f\u52a8\u534f\u8bae\uff0c\u8fd9\u91cc\u4e0d\u6307\u5b9a<\/p>\n<p>\u5982\u679c\u8fd8\u6709\u66f4\u591a\u7f51\u5361\uff0c\u7167\u4e0a\u9762\u5199\u5373\u53ef<\/p>\n<p>\u63a5\u4e0b\u6765\u9700\u8981\u5728CentOS\u4e2d\u6ce8\u518c\u4e00\u4e0bbonding\u6a21\u5757<\/p>\n<p>vim \/etc\/modprobe.d\/bonding.conf<\/p>\n<p>\u6dfb\u52a0<\/p>\n<pre>alias bond0 bonding\r\noptions bond0 mode=4 miimon=100<\/pre>\n<p>mode\u53c2\u6570\u89c1\uff1a<\/p>\n<p>http:\/\/unixfoo.blogspot.com\/2008\/02\/network-bonding-part-ii-modes-of.html<\/p>\n<ul>\n<li><span style=\"font-size: small;\"><span style=\"font-size: small;\">Mode 0 (balance-rr)<br \/>\nThis mode transmits packets in a sequential order from the first available slave through the last. If two real interfaces are slaves in the bond and two packets arrive destined out of the bonded interface the first will be transmitted on the first slave and the second frame will be transmitted on the second slave. The third packet will be sent on the first and so on. This provides load balancing and fault tolerance.<\/span><\/span><\/li>\n<li><span style=\"font-size: small;\"><span style=\"font-size: small;\">Mode 1 (active-backup)<br \/>\nThis mode places one of the interfaces into a backup state and will only make it active if the link is lost by the active interface. Only one slave in the bond is active at an instance of time. A different slave becomes active only when the active slave fails. This mode provides fault tolerance.<\/span><\/span><\/li>\n<li><span style=\"font-size: small;\"><span style=\"font-size: small;\">Mode 2 (balance-xor)<br \/>\nTransmits based on XOR formula. (Source MAC address is XOR&#8217;d with destination MAC address) modula slave count. This selects the same slave for each destination MAC address and provides load balancing and fault tolerance.<\/span><\/span><\/li>\n<li><span style=\"font-size: small;\"><span style=\"font-size: small;\">Mode 3 (broadcast)<br \/>\nThis mode transmits everything on all slave interfaces. This mode is least used (only for specific purpose) and provides only fault tolerance.<\/span><\/span><\/li>\n<li><span style=\"font-size: small;\"><span style=\"font-size: small;\">Mode 4 (802.3ad)<br \/>\nThis mode is known as Dynamic Link Aggregation mode. It creates aggregation groups that share the same speed and duplex settings. This mode requires a switch that supports IEEE 802.3ad Dynamic link.<\/span><\/span><\/li>\n<li><span style=\"font-size: small;\"><span style=\"font-size: small;\">Mode 5 (balance-tlb)<br \/>\nThis is called as Adaptive transmit load balancing. The outgoing traffic is distributed according to the current load and queue on each slave interface. Incoming traffic is received by the current slave.<\/span><\/span><\/li>\n<li><span style=\"font-size: small;\">Mode 6 (balance-alb)<br \/>\nThis is Adaptive load balancing mode. This includes balance-tlb + receive load balancing (rlb) for IPV4 traffic. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the server on their way out and overwrites the src hw address with the unique hw address of one of the slaves in the bond such that different clients use different hw addresses for the server.<br \/>\n<\/span><\/li>\n<\/ul>\n<p>mode\u7684\u503c\u8868\u793a\u5de5\u4f5c\u6a21\u5f0f\uff0c\u5171\u67097\u79cd\u6a21\u5f0f\uff0c\u5e38\u7528\u7684\u4e3a0\uff0c1\uff0c4\u4e09\u79cd\u3002<\/p>\n<p>mode=0\u8868\u793aload balancing (round-robin)\u4e3a\u8d1f\u8f7d\u5747\u8861\u65b9\u5f0f\uff0c\u4e24\u5757\u7f51\u5361\u90fd\u5de5\u4f5c\u3002<br \/>\nmode=1\u8868\u793afault-tolerance (active-backup)\u63d0\u4f9b\u5197\u4f59\u529f\u80fd\uff0c\u5de5\u4f5c\u65b9\u5f0f\u662f\u4e3b\u5907\u7684\u5de5\u4f5c\u65b9\u5f0f,\u4e5f\u5c31\u662f\u8bf4\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u53ea\u6709\u4e00\u5757\u7f51\u5361\u5de5\u4f5c,\u53e6\u4e00\u5757\u505a\u5907\u4efd<br \/>\nmode=4\u662f\u901a\u7528\u7684802.3ad\u534f\u8bae\uff0c\u7c7b\u4f3c\u4e8e\u7b2c\u4e00\u79cd\uff0c\u63a5\u601d\u79d1\u4ea4\u6362\u673a\u65f6\u9700\u8981\u9009LACP\u6a21\u5f0f\u3002<\/p>\n<p>miimon\u662f\u7528\u6765\u8fdb\u884c\u94fe\u8def\u76d1\u6d4b\u7684\u3002\u6bd4\u5982:miimon=100\uff0c\u90a3\u4e48\u7cfb\u7edf\u6bcf100ms\u76d1\u6d4b\u4e00\u6b21\u94fe\u8def\u8fde\u63a5\u72b6\u6001\uff0c\u5982\u679c\u6709\u4e00\u6761\u7ebf\u8def\u4e0d\u901a\u5c31\u8f6c\u5165\u53e6\u4e00\u6761\u7ebf\u8def\uff1b<\/p>\n<p>\u91cd\u542f\u7f51\u7edc\u670d\u52a1<\/p>\n<pre>service network restart<\/pre>\n<p>\u4f7f\u7528<code>watch -n 1<\/code>\u53ef\u4ee5\u6bcf\u79d2\u66f4\u65b0bond0\u7684\u72b6\u6001<\/p>\n<pre>watch -n 1 'cat \/proc\/net\/bonding\/bond0'<\/pre>\n<p>\u53c2\u8003\uff1a<a href=\"http:\/\/www.cyberciti.biz\/howto\/question\/static\/linux-ethernet-bonding-driver-howto.php\">http:\/\/www.cyberciti.biz\/howto\/question\/static\/linux-ethernet-bonding-driver-howto.php<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u64cd\u4f5c\u5747\u5728CentOS\u4e0b\uff0c\u7f51\u5361\u7ed1\u5b9a\u6709\u591a\u79cd\u6a21\u5f0f\uff0c\u8fd9\u91cc\u662f\u4e3a\u4e86\u589e\u52a0\u5e26\u5bbd \u5b89\u88c5\u9700\u8981\u7684\u7ec4\u4ef6 yum install ethtool -y \u6dfb\u52a0\u4e00\u4e2aifcfg-bond0\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u505a\u4e3amaster\uff0c\u9700\u8981\u7ed1\u5b9a\u7684\u7269\u7406\u7f51\u5361(ifcfg-eth0, ifcfg-eth1)\u505a\u4e3aslave vim \/etc\/sysconfig\/network-scripts\/ifcfg-bond0 \u6dfb\u52a0 DEVICE=bond0 ONBOOT=yes IPADDR=192.168.1.12 NETMASK=255.255.255.0 NETWORK=192.168.1.0 USERCTL=no BOOTPROTO=none vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u6dfb\u52a0 DEVICE=eth0 ONBOOT=yes USERCTL=no MASTER=bond0 SLAVE=yes BOOTPROTO=none vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth1 \u6dfb\u52a0 DEVICE=eth1 ONBOOT=yes USERCTL=no MASTER=bond0 SLAVE=yes BOOTPROTO=none USERCTL=yes\/no \u662f\u5426\u5141\u8bb8\u975eroot\u7528\u6237\u63a7\u5236\u8be5\u8bbe\u5907 BOOTPROTO=none\/static\/dhcp \u6307\u5b9a\u542f\u52a8\u534f\u8bae\uff0c\u8fd9\u91cc\u4e0d\u6307\u5b9a \u5982\u679c\u8fd8\u6709\u66f4\u591a\u7f51\u5361\uff0c\u7167\u4e0a\u9762\u5199\u5373\u53ef \u63a5\u4e0b\u6765\u9700\u8981\u5728CentOS\u4e2d\u6ce8\u518c\u4e00\u4e0bbonding\u6a21\u5757 vim \/etc\/modprobe.d\/bonding.conf \u6dfb\u52a0 alias bond0 bonding options bond0 mode=4 miimon=100 mode\u53c2\u6570\u89c1\uff1a http:\/\/unixfoo.blogspot.com\/2008\/02\/network-bonding-part-ii-modes-of.html Mode [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-5163","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5163"}],"version-history":[{"count":16,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5163\/revisions"}],"predecessor-version":[{"id":5207,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5163\/revisions\/5207"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}