Opensourcetechブログ

OpensourcetechによるNGINX/Kubernetes/Zabbix/Neo4j/Linuxなどオープンソース技術に関するブログです。

CentOS7でNICのチーミング(インストール時)を設定する

 

こんにちは、LinuCエバンジェリストこと、鯨井貴博@opensourcetechです。

 

CentOS7でNICのチーミング(インストール時)に関するメモです。

 

Virtualbox上で実施してます。

以下のように、NICを2つ(ブリッジアダプター)で用意して、CentOS7をインストールします。

f:id:opensourcetech:20200604104317p:plain


 

通常通り、CentOS7のインストーラを起動し、インストールを進めます。

f:id:opensourcetech:20200604104830p:plain

 

インストールに使用する言語の選択。

f:id:opensourcetech:20200604105004p:plain

 

インストール先の選択と、ネットワーク設定をします。

ネットワーク設定では、チーミングを設定します。

f:id:opensourcetech:20200604105107p:plain


PCに搭載されいている2つのNICがあります。

※Virtualboxで作成される「enp0s3」と「enp0s8」です。

f:id:opensourcetech:20200604105210p:plain


「+」をクリックし、「チーム(チーミング用NIC)」を追加します。

f:id:opensourcetech:20200604110415p:plain

なお、類似した「Bond」というものもあるので、注意。

「Bond」と「チーム」の違いについては、以下を参照。

ざっくりいうと、チーミングのほうが出来ることが多いです。

8.3. ネットワークチーミングとボンディングの比較 Red Hat Enterprise Linux 7 | Red Hat Customer Portal

 

まず、接続名を編集。

コマンドラインなどから操作するときにも使うので、使いやすいものを設定します。

そして、「追加」をクリックします。

f:id:opensourcetech:20200604110620p:plain

 

 「追加」のあとは、チーミングに含むNICの選択。

「Ethernet」から「enp0s3」と「enp0s8」を選択します。

f:id:opensourcetech:20200604110757p:plain

f:id:opensourcetech:20200604110912p:plain

f:id:opensourcetech:20200604110957p:plain

f:id:opensourcetech:20200604111035p:plain

f:id:opensourcetech:20200604111105p:plain

f:id:opensourcetech:20200604111236p:plain

 

パッケージのインストール。

f:id:opensourcetech:20200604111333p:plain

 

ユーザーアカウント設定。

f:id:opensourcetech:20200604111430p:plain

f:id:opensourcetech:20200604112324p:plain

再起動すれば、チーミングを含むCentOS7のインストールは完了です。

 

再起動後、ip addr showを実施すると、team0というチーミングNICにIPアドレスなどが設定されていることが確認できます。

f:id:opensourcetech:20200604112901p:plain

 

チーミングのステータスは、teamdctl team0(NIC名) stateとすれば表示できます。

runnerからはラウンドロビンでチーミングが使われること、

そしてチーミングに含まれる2つのNICがupとなっていることがわかります。

f:id:opensourcetech:20200604113218p:plain

 

チーミングの設定(JSON形式)をみるには、teamdctl team0 config dumpとすれば表示されます。

f:id:opensourcetech:20200604132653p:plain

 

では、チーミング設定を変更。

変更の元となる設定(~.conf)は、/usr/share/doc/teamd-*.**/example_config/に用意されています。

activebackup(アクティブバックアップ構成)・broadcast(全てのNICに送信される)・lacp(業界標準のLinkAggregation規格)・loadbalance(ロードバランシング)・ランダム・などがチーミングで利用できることが分かりますね。

f:id:opensourcetech:20200604113105p:plain

 

今回は、アクティブバックアップ構成にしてみようと思います。

なので、activebackup_ethtool_1.confをコピーして使います。

f:id:opensourcetech:20200604113432p:plain

 

以下のように編集(JSON形式)しました。

・enp0s3を高い優先度(prio:100)にして、このNICが生きている間は利用される(sticky:true)

・enp0s8を低い優先度(prio:-10)にする

・ethtool(NICがリンクアップしているかどうか)の監視をする

※"hwaddr_policy": "by_active"は、Virtualbox上の仮想マシンでは必要とのことなので、物理マシンで操作する場合は不要かもしれません。

f:id:opensourcetech:20200604132509p:plain


編集内容の反映。

nmcli con show Teaming(インストール時に設定したチーミングNICの接続名) | grep team.confi とすると既存状態の確認。

nmcli connection modify Teaming team.config activebackup_ethtool_1.conf で設定の適用。

f:id:opensourcetech:20200604140758p:plain

そして、設定の有効化の為に、CentOS7を再起動します。

 

 再起動後、以下のようにチーミング設定が適用されています。

f:id:opensourcetech:20200604141020p:plain

 

JSON形式の設定も、念のためチェック。

f:id:opensourcetech:20200604142728p:plain

 

では、動作確認。

2つのNICがupの場合、それぞれダウンした場合のPingを見てみます。

[root@localhost ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
enp0s3
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 1
enp0s8
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: enp0s3
[root@localhost ~]# ip link set enp0s3 down
[root@localhost ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
enp0s3
link watches:
link summary: down
instance[link_watch_0]:
name: ethtool
link: down
down count: 2
enp0s8
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: enp0s8
[root@localhost ~]# ip link set enp0s3 up
[root@localhost ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
enp0s3
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 2
enp0s8
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: enp0s3
[root@localhost ~]# ip link set enp0s8 down
[root@localhost ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
enp0s3
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 2
enp0s8
link watches:
link summary: down
instance[link_watch_0]:
name: ethtool
link: down
down count: 1
runner:
active port: enp0s3
[root@localhost ~]# ip link set enp0s8 up

 

結果的には、Ping落ちなし。

なかなかいいですね♪

f:id:opensourcetech:20200604142937p:plain

 

 

 

 おまけ

runnnerで設定できるNICの使われ方についてです。

runner.name (string)
Name of team device. The following runners are available:

broadcast ― Simple runner which directs the team device to transmit packets via all
ports.

roundrobin ― Simple runner which directs the team device to transmits packets in a
round-robin fashion.

activebackup ― Watches for link changes and selects active port to be used for data
transfers.

loadbalance ― To do passive load balancing, runner only sets up BPF hash function
which will determine port for packet transmit. To do active load balancing, runner
moves hashes among available ports trying to reach perfect balance.

lacp ― Implements 802.3ad LACP protocol. Can use same Tx port selection possibili‐
ties as loadbalance runner.

 

 

参考URL

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configure_a_network_team_using-the_command_line

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/networking_guide/sec-Configure_a_Network_Team_Using-the_Command_Line#sec-Configure_Network_Teaming_Using_nmcli

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/networking_guide/sec-configure_teamd_runners

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/networking_guide/sec-configure_a_network_team_using-the_command_line

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configure_teamd_runners

 

 

 

 

 

 

 

アフィリエイトのアクセストレード

 

 

 

 

 

 

www.slideshare.net

github.com

www.facebook.com

twitter.com

www.instagram.com

 

 

にほんブログ村 IT技術ブログ Linuxへ
Linux

にほんブログ村 IT技術ブログ オープンソースへ
オープンソース

 

 

Opensourcetech by Takahiro Kujirai