mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-27 02:30:10 +08:00
[Translated] tech/20150108 Interface (NICs) Bonding in Linux using nmcli
This commit is contained in:
parent
b2e2f272c1
commit
8263c03c48
@ -1,137 +0,0 @@
|
||||
Translating by ictlyh
|
||||
Interface (NICs) Bonding in Linux using nmcli
|
||||
================================================================================
|
||||
Today, we'll learn how to perform Interface (NICs) bonding in our CentOS 7.x using nmcli (Network Manager Command Line Interface).
|
||||
|
||||
NICs (Interfaces) bonding is a method for linking **NICs** together logically to allow fail-over or higher throughput. One of the ways to increase the network availability of a server is by using multiple network interfaces. The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical bonded interface. It is a new implementation that does not affect the older bonding driver in linux kernel; it offers an alternate implementation.
|
||||
|
||||
**NIC bonding is done to provide two main benefits for us:**
|
||||
|
||||
1. **High bandwidth**
|
||||
1. **Redundancy/resilience**
|
||||
|
||||
Now lets configure NICs bonding in CentOS 7. We'll need to decide which interfaces that we would like to configure a Team interface.
|
||||
|
||||
run **ip link** command to check the available interface in the system.
|
||||
|
||||
$ ip link
|
||||
|
||||

|
||||
|
||||
Here we are using **eno16777736** and **eno33554960** NICs to create a team interface in **activebackup** mode.
|
||||
|
||||
Use **nmcli** command to create a connection for the network team interface,with the following syntax.
|
||||
|
||||
# nmcli con add type team con-name CNAME ifname INAME [config JSON]
|
||||
|
||||
Where **CNAME** will be the name used to refer the connection ,**INAME** will be the interface name and **JSON** (JavaScript Object Notation) specifies the runner to be used.**JSON** has the following syntax:
|
||||
|
||||
'{"runner":{"name":"METHOD"}}'
|
||||
|
||||
where **METHOD** is one of the following: **broadcast, activebackup, roundrobin, loadbalance** or **lacp**.
|
||||
|
||||
### 1. Creating Team Interface ###
|
||||
|
||||
Now let us create the team interface. here is the command we used to create the team interface.
|
||||
|
||||
# nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'
|
||||
|
||||

|
||||
|
||||
run **# nmcli con show** command to verify the team configuration.
|
||||
|
||||
# nmcli con show
|
||||
|
||||

|
||||
|
||||
### 2. Adding Slave Devices ###
|
||||
|
||||
Now lets add the slave devices to the master team0. here is the syntax for adding the slave devices.
|
||||
|
||||
# nmcli con add type team-slave con-name CNAME ifname INAME master TEAM
|
||||
|
||||
Here we are adding **eno16777736** and **eno33554960** as slave devices for **team0** interface.
|
||||
|
||||
# nmcli con add type team-slave con-name team0-port1 ifname eno16777736 master team0
|
||||
|
||||
# nmcli con add type team-slave con-name team0-port2 ifname eno33554960 master team0
|
||||
|
||||

|
||||
|
||||
Verify the connection configuration using **#nmcli con show** again. now we could see the slave configuration.
|
||||
|
||||
#nmcli con show
|
||||
|
||||

|
||||
|
||||
### 3. Assigning IP Address ###
|
||||
|
||||
All the above command will create the required configuration files under **/etc/sysconfig/network-scripts/**.
|
||||
|
||||
Lets assign an IP address to this team0 interface and enable the connection now. Here is the command to perform the IP assignment.
|
||||
|
||||
# nmcli con mod team0 ipv4.addresses "192.168.1.24/24 192.168.1.1"
|
||||
# nmcli con mod team0 ipv4.method manual
|
||||
# nmcli con up team0
|
||||
|
||||

|
||||
|
||||
### 4. Verifying the Bonding ###
|
||||
|
||||
Verify the IP address information in **#ip add show team0** command.
|
||||
|
||||
#ip add show team0
|
||||
|
||||

|
||||
|
||||
Now lets check the **activebackup** configuration functionality using the **teamdctl** command.
|
||||
|
||||
# teamdctl team0 state
|
||||
|
||||

|
||||
|
||||
Now lets disconnect the active port and check the state again. to confirm whether the active backup configuration is working as expected.
|
||||
|
||||
# nmcli dev dis eno33554960
|
||||
|
||||

|
||||
|
||||
disconnected the active port and now check the state again using **#teamdctl team0 state**.
|
||||
|
||||
# teamdctl team0 state
|
||||
|
||||

|
||||
|
||||
Yes its working cool !! we will connect the disconnected connection back to team0 using the following command.
|
||||
|
||||
#nmcli dev con eno33554960
|
||||
|
||||

|
||||
|
||||
We have one more command called **teamnl** let us show some options with **teamnl** command.
|
||||
|
||||
to check the ports in team0 run the following command.
|
||||
|
||||
# teamnl team0 ports
|
||||
|
||||

|
||||
|
||||
Display currently active port of **team0**.
|
||||
|
||||
# teamnl team0 getoption activeport
|
||||
|
||||

|
||||
|
||||
Hurray, we have successfully configured NICs bonding :-) Please share feedback if any.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/interface-nics-bonding-linux/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
@ -0,0 +1,136 @@
|
||||
在 Linux 中用 nmcli 命令绑定网卡(NICs)
|
||||
================================================================================
|
||||
今天,我们来学习一下在 CentOS 7.x 中如何用 nmcli(Network Manager Command Line Interface:网络管理命令行接口) 进行网卡(NICs 译者注:Netword Interface Card,网卡或网络适配器)绑定(译者注:bond 是指把多个物理网卡绑定成一个逻辑上的网卡,这样多个网卡可以使用同一个 IP 从而可以避免单点故障)。
|
||||
|
||||
网卡绑定是将 **网卡** 逻辑地连接到一起从而允许故障转移或者提高吞吐率的方法。提高服务器网络可用性的一个方式是使用多个网卡。Linux 绑定驱动提供了一个将多个网卡聚合到一个逻辑绑定接口的方法。这是个并不影响 linux 内核中旧绑定驱动的新的实现;它提供了另一种实现方法。
|
||||
|
||||
**网卡绑定为我们提供了两个主要的好处:**
|
||||
|
||||
1. **高带宽**
|
||||
1. **冗余/弹性**
|
||||
|
||||
现在让我们在 CentOS 7 上配置网卡绑定吧。我们需要决定选取哪些接口配置成一个组接口。
|
||||
|
||||
运行 **ip link** 命令查看系统中可用的接口。
|
||||
|
||||
$ ip link
|
||||
|
||||

|
||||
|
||||
这里我们使用 **eno16777736** 和 **eno33554960** 网卡在 “主动备份” 模式下创建一个组接口。(译者注:关于不同模式可以参考:<a href="http://support.huawei.com/ecommunity/bbs/10155553.html">多网卡的7种bond模式原理</a>)
|
||||
|
||||
按照下面的语法,用 **nmcli** 命令为网络组接口创建一个连接。
|
||||
|
||||
# nmcli con add type team con-name CNAME ifname INAME [config JSON]
|
||||
|
||||
**CNAME** 指代连接的名称,**INAME** 是接口名称,**JSON** (JavaScript Object Notation) 指定所使用的处理器(runner)。**JSON** 语法格式如下:
|
||||
|
||||
'{"runner":{"name":"METHOD"}}'
|
||||
|
||||
**METHOD** 是以下的其中一个:**broadcast、activebackup、roundrobin、loadbalance** 或者 **lacp**。
|
||||
|
||||
### 1. 创建组接口 ###
|
||||
|
||||
现在让我们来创建组接口。这是我们创建组接口所使用的命令。
|
||||
|
||||
# nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'
|
||||
|
||||

|
||||
|
||||
运行 **# nmcli con show** 命令验证组接口配置。
|
||||
|
||||
# nmcli con show
|
||||
|
||||

|
||||
|
||||
### 2. 添加从设备 ###
|
||||
|
||||
现在让我们天际从设备到主设备 team0。这是添加从设备的语法。
|
||||
|
||||
# nmcli con add type team-slave con-name CNAME ifname INAME master TEAM
|
||||
|
||||
在这里我们添加 **eno16777736** 和 **eno33554960** 作为 **team0** 接口的从设备。
|
||||
|
||||
# nmcli con add type team-slave con-name team0-port1 ifname eno16777736 master team0
|
||||
|
||||
# nmcli con add type team-slave con-name team0-port2 ifname eno33554960 master team0
|
||||
|
||||

|
||||
|
||||
再次用命令 **#nmcli con show** 验证连接配置。现在我们可以看到从设备配置信息。
|
||||
|
||||
#nmcli con show
|
||||
|
||||

|
||||
|
||||
### 3. 分配 IP 地址 ###
|
||||
|
||||
上面的命令会在 **/etc/sysconfig/network-scripts/** 目录下创建需要的配置文件。
|
||||
|
||||
现在让我们为 team0 接口分配一个 IP 地址并启用这个连接。这是进行 IP 分配的命令。
|
||||
|
||||
# nmcli con mod team0 ipv4.addresses "192.168.1.24/24 192.168.1.1"
|
||||
# nmcli con mod team0 ipv4.method manual
|
||||
# nmcli con up team0
|
||||
|
||||

|
||||
|
||||
### 4. 验证绑定 ###
|
||||
|
||||
用 **#ip add show team0** 命令验证 IP 地址信息。
|
||||
|
||||
#ip add show team0
|
||||
|
||||

|
||||
|
||||
现在用 **teamdctl** 命令检查 **主动备份** 配置功能。
|
||||
|
||||
# teamdctl team0 state
|
||||
|
||||

|
||||
|
||||
现在让我们和激活的端口断开连接并再次检查状态来确认主动备份配置是否像希望的那样工作。
|
||||
|
||||
# nmcli dev dis eno33554960
|
||||
|
||||

|
||||
|
||||
断开激活端口后再次用命令 **#teamdctl team0 state** 检查状态。
|
||||
|
||||
# teamdctl team0 state
|
||||
|
||||

|
||||
|
||||
是的,它运行良好!!我们会使用下面的命令连接回到 team0 的断开的连接。
|
||||
|
||||
#nmcli dev con eno33554960
|
||||
|
||||

|
||||
|
||||
我们还有一个 **teamnl** 命令可以显示 **teamnl** 命令的一些选项。
|
||||
|
||||
用下面的命令检查在 team0 运行的端口。
|
||||
|
||||
# teamnl team0 ports
|
||||
|
||||

|
||||
|
||||
显示 **team0** 当前活动的端口。
|
||||
|
||||
# teamnl team0 getoption activeport
|
||||
|
||||

|
||||
|
||||
好了,我们已经成功地配置了网卡绑定 :-) ,如果有任何反馈,请告诉我们。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/interface-nics-bonding-linux/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
Loading…
Reference in New Issue
Block a user