computerの日記

Cisco,SHELL,C,Qt,C++,Linux,ネットワーク,Windows Scriptなどの発言です

sar-analyzer の開発状況(20180422)

Z オプションにより、関係ある項目の最高と最低値がとれるようになっていましたが、CPU の値も、取れるようにしました。

また、ボチボチ直していきます。

github.com

Fedora27 で、VMware Workstation Player(無償版)を動かす

VMware のアイコンをクリックしても、モジュールのインストールでエラーとなって、VMwre Workstation Player(無償版)が起動できないでいました。

以下のページを参考にしました。

 

tar ファイルを解凍、エラーログを元に、コードを修正しました。

# cd /usr/lib/vmware/modules/source/

# cp -p vmmontar vmmon.old.tar

# tar xvf vmmon.tar

# cd linux

driver.c と、hostif.c の所定の箇所を、問題が出ないように修正すればよいと思います。

固め直します。

communities.vmware.com

# tar cvf vmmon.tar vmmon-only

# vmware-modconfig --console --install-all

しかしながら、私のカーネルが 4.15 のせいなのか、コンパイルに失敗します。

 以下のパッチを当てて、上記コマンドを実行したら、コンパイルが通りました。

github.com

 

VMware のアイコンをクリックします。

起動しました。

 追記:Vmware が、14.1 にバージョンアップされました。14.1 には、上記のパッチが当たっているようで、不具合が解消されています。

sar-analyzer の開発状況(20180408)

sar-analyzer ですが、コンテキストスイッチ関連について、最高と最低の値を出せるようにしました。今までは、平均の最高と最低だけでしたが、進歩です。

コンテキストスイッチの最高と最低値を出すには、-Z  オプションを渡してください。

LVM ファイルシステムタイプのハードディスクをマウントする方法

今、/dev/sdd2 に LVM ファイルシステムタイプがあるとします。
/dev/sdd1 には、/boot が存在しており、こちらはマウントできます。
/dev/sdd2 を普通にマウントしようとしても、以下のようになり、マウントに失敗します。

 # mount /dev/sdd2 /mnt/sdd2

mount: /mnt/sdd2: 未知のファイルシステムタイプ 'LVM2_member' です.

 /dev/sdd を調べます。

 # fdisk -l /dev/sdd

ディスク /dev/sdd: 1.8 TiB, xxxxxx バイト, xxxxxx セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 4096 バイト / xxxxxx バイト
ディスクラベルのタイプ: dos
ディスク識別子: 0xxxxxxx

バイス 起動 開始位置 最後から セクタ サイズ Id タイプ
/dev/sdd1 * 2048 xxxxxx xxxxxx 500M 83 Linux
/dev/sdd2 xxxxxx xxxxxx xxxxxx 1.8T 8e Linux LVM

 では、この /dev/sdd2 をマウントしていきます。
まず、利用可能な volumne group を調査します。
以下のコマンドを実行します。

 # pvs

PV VG Fmt Attr PSize PFree
/dev/sda2 fedora lvm2 a-- <1.82t 0
/dev/sdd2 fedora lvm2 a-- <1.82t 4.00m

 実際に起動している OS の VolumeGroup 名前と、ハードディスクの Volume Group の名前が、”fedora" と同一名となっているので、ハードディスクの Volume Group の名前を別の名前にでもリネームしてみます。

UUID を調べます。

# vgdisplay

--- Volume group ---
VG Name fedora
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <1.82 TiB
PE Size 4.00 MiB
Total PE 476675
Alloc PE / Size 476675 / <1.82 TiB
Free PE / Size 0 / 0
VG UUID xxxxxxxxxxxxxxxxxx

--- Volume group ---
VG Name fedora
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <1.82 TiB
PE Size 4.00 MiB
Total PE 476806
Alloc PE / Size 476805 / <1.82 TiB
Free PE / Size 1 / 4.00 MiB
VG UUID xxxxxxxxxxxxxxxxxx ★<----これを使う

vgrename コマンドを使用して、ハードディスクの方の Volume Group 名をリネームします。

# vgrename xxxxxxxxxxxxxxxx fedora_old

Processing VG fedora because of matching UUID
xxxxxxxxxxxxxxxx
Volume group "xxxxxxxxxxxxxxxx" successfully
renamed to "fedora_old"

では、volume groupe をもう一度見てみます。

# pvs

PV VG Fmt Attr PSize PFree
/dev/sda2 fedora lvm2 a-- <1.82t 0
/dev/sdd2 fedora_old lvm2 a-- <1.82t 4.00m

 これで、fedora という名前の重複はなくなりました。
ハードディスクのほうは、fedora_old となりました。

では、マウントしていきます。

 # vgscan --mknodes

Reading volume groups from cache.
Found volume group "fedora" using metadata type lvm2
Found volume group "fedora_old" using metadata type lvm2

 ここで、lvscan をかけても、ハードディスクのほうは、inactive となっています。

 # lvscan

ACTIVE '/dev/fedora/swap' [<7.84 GiB] inherit
ACTIVE '/dev/fedora/home' [1.76 TiB] inherit
ACTIVE '/dev/fedora/root' [50.00 GiB] inherit
inactive '/dev/fedora_old/swap' [7.81 GiB] inherit
inactive '/dev/fedora_old/home' [1.76 TiB] inherit
inactive '/dev/fedora_old/root' [50.00 GiB] inherit

 ここで、mount コマンドを実行しても、マウントできません。

 # mount /dev/fedora_old/home /mnt/sdd2

mount: /mnt/sdd2: スペシャルデバイス /dev/fedora_old/home が存在しません.

 inactive となっているものを、有効化します。

 # vgchange -ay

3 logical volume(s) in volume group "fedora" now active
3 logical volume(s) in volume group "fedora_old" now active

 もう一度確認します。

 # lvscan

ACTIVE '/dev/fedora/swap' [<7.84 GiB] inherit
ACTIVE '/dev/fedora/home' [1.76 TiB] inherit
ACTIVE '/dev/fedora/root' [50.00 GiB] inherit
ACTIVE '/dev/fedora_old/swap' [7.81 GiB] inherit
ACTIVE '/dev/fedora_old/home' [1.76 TiB] inherit
ACTIVE '/dev/fedora_old/root' [50.00 GiB] inherit

 では、もう一度マウントしてみます。

 # mount /dev/fedora_old/home /mnt/sdd2

マウントできたようです。 

LACP 802.3ad の実験

今回の実験は、スイッチにおいて etherchannel 、サーバにおいて bonding を使って、Link Aggregation を実現できるか、というところです。

今回のトポロジは以下となります。

f:id:intrajp:20180325190140p:plain

さて、設定していきます。

スイッチから。

IOU1#debug etherchannel event
PAgP/LACP Shim Events debugging is on

IOU1#conf t

IOU1(config)#int range e0/0 - 1
IOU1(config-if-range)#chann
IOU1(config-if-range)#channel-pro
IOU1(config-if-range)#channel-protocol ?
lacp Prepare interface for LACP protocol
pagp Prepare interface for PAgP protocol

IOU1(config-if-range)#channel-protocol lacp

IOU1(config-if-range)#channel-group 1 mode active

IOU1#sho ip int bri
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 unassigned YES unset up up
Ethernet0/1 unassigned YES unset up up
Ethernet0/2 unassigned YES unset up up
Ethernet0/3 unassigned YES unset up up
Ethernet1/0 unassigned YES unset up up
Ethernet1/1 unassigned YES unset up up
Ethernet1/2 unassigned YES unset up up
Ethernet1/3 unassigned YES unset up up
Ethernet2/0 unassigned YES unset up up
Ethernet2/1 unassigned YES unset up up
Ethernet2/2 unassigned YES unset up up
Ethernet2/3 unassigned YES unset up up
Ethernet3/0 unassigned YES unset up up
Ethernet3/1 unassigned YES unset up up
Ethernet3/2 unassigned YES unset up up
Ethernet3/3 unassigned YES unset up up
Port-channel1 unassigned YES unset up up
Vlan1 unassigned YES unset administratively down down

うまくいくと、こうなる。

IOU1#show etherchannel summary
Flags: D - down P - bundled in port-channel
I - stand-alone s - suspended
H - Hot-standby (LACP only)
R - Layer3 S - Layer2
U - in use f - failed to allocate aggregator

M - not in use, minimum links not met
u - unsuitable for bundling
w - waiting to be aggregated
d - default port


Number of channel-groups in use: 1
Number of aggregators: 1

Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
1 Po1(SU) LACP Et0/0(P) Et0/1(P)

 

 

IOU1#
*Mar 25 12:02:34.740: FEC: lacp_fec_unbundle_internal: Et0/0
*Mar 25 12:02:34.740: FEC: lacp_switch_delete_port_from_agport_internal: removing Et0/0 from Po1
*Mar 25 12:02:34.740: FEC: pagp_switch_delete_port_from_agport_list: afb->nports-- = 1 [Et0/0]
*Mar 25 12:02:35.027: FEC: lacp_fec_unbundle_internal: Et0/1
*Mar 25 12:02:35.027: FEC: lacp_switch_delete_port_from_agport_internal: removing Et0/1 from Po1
*Mar 25 12:02:35.027: FEC: pagp_switch_delete_port_from_agport_list: afb->nports-- = 0 [Et0/1]
*Mar 25 12:02:35.744: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down
IOU1#
*Mar 25 12:02:36.031: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down
IOU1#
*Mar 25 12:02:37.031: %LINK-3-UPDOWN: Interface Port-channel1, changed state to down
*Mar 25 12:02:38.031: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to down
IOU1#
*Mar 25 12:02:39.878: FEC: lacp_fec_dontbundle_internal: Et0/0
IOU1#
*Mar 25 12:02:39.878: %EC-5-L3DONTBNDL2: Et0/0 suspended: LACP currently not enabled on the remote port.
*Mar 25 12:02:40.270: FEC: lacp_fec_dontbundle_internal: Et0/1
IOU1#
*Mar 25 12:02:40.270: %EC-5-L3DONTBNDL2: Et0/1 suspended: LACP currently not enabled on the remote port.
IOU1#
*Mar 25 12:02:50.219: FEC: lacp_fec_unbundle_internal: Et0/1
*Mar 25 12:02:50.219: FEC: Unbundling req for port: Et0/1 neitherstand-alone Agport nor in a bundle
*Mar 25 12:02:50.219: FEC: lacp_switch_add_port_to_associated_list_internal: Et0/1 added to list for Po1
*Mar 25 12:02:50.219: FEC: lacp_fec_unbundle_internal: Et0/0
*Mar 25 12:02:50.219: FEC: Unbundling req for port: Et0/0 neitherstand-alone Agport nor in a bundle
*Mar 25 12:02:50.220: FEC: lacp_switch_add_port_to_associated_list_internal: Et0/0 added to list for Po1
*Mar 25 12:02:51.223: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up
*Mar 25 12:02:51.223: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
IOU1#
*Mar 25 12:02:53.810: FEC: pagp_switch_add_port_to_agport_list: afb->nports++ = 1 [Et0/0]
*Mar 25 12:02:53.810: FEC: lacp_switch_add_port_to_agport_internal: Et0/0 added to aggregator Po1 list
*Mar 25 12:02:53.889: FEC: pagp_switch_add_port_to_agport_list: afb->nports++ = 2 [Et0/1]
*Mar 25 12:02:53.889: FEC: lacp_switch_add_port_to_agport_internal: Et0/1 added to aggregator Po1 list
IOU1#
*Mar 25 12:02:55.814: %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
*Mar 25 12:02:56.819: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up

 

次のコマンドの結果

IOU1#show etherchannel port-channel
Channel-group listing:
----------------------

Group: 1
----------
Port-channels in the group:
---------------------------

Port-channel: Po1 (Primary Aggregator)

------------

Age of the Port-channel = 0d:01h:33m:19s
Logical slot/port = 16/0 Number of ports = 2
HotStandBy port = null
Port state = Port-channel Ag-Inuse
Protocol = LACP
Port security = Disabled

Ports in the Port-channel:

Index Load Port EC state No of bits
------+------+------+------------------+-----------
0 00 Et0/0 Active 0
0 00 Et0/1 Active 0

Time since last port bundled: 0d:00h:28m:03s Et0/1
Time since last port Un-bundled: 0d:00h:29m:30s Et0/1

 

次のコマンドの結果

IOU1#show etherchannel load-balance
EtherChannel Load-Balancing Configuration:
src-dst-ip

EtherChannel Load-Balancing Addresses Used Per-Protocol:
Non-IP: Source XOR Destination MAC address
IPv4: Source XOR Destination IP address
IPv6: Source XOR Destination IP address

 

次のコマンドの結果

IOU1#show etherchannel detail
Channel-group listing:
----------------------

Group: 1
----------
Group state = L2
Ports: 2 Maxports = 4
Port-channels: 1 Max Port-channels = 4
Protocol: LACP
Minimum Links: 0


Ports in the group:
-------------------
Port: Et0/0
------------

Port state = Up Mstr Assoc In-Bndl
Channel group = 1 Mode = Active Gcchange = -
Port-channel = Po1 GC = - Pseudo port-channel = Po1
Port index = 0 Load = 0x00 Protocol = LACP

Flags: S - Device is sending Slow LACPDUs F - Device is sending fast LACPDUs.
A - Device is in active mode. P - Device is in passive mode.

Local information:
LACP port Admin Oper Port Port
Port Flags State Priority Key Key Number State
Et0/0 SA bndl 32768 0x1 0x1 0x1 0x3D

Partner's information:

LACP port Admin Oper Port Port
Port Flags Priority Dev ID Age key Key Number State
Et0/0 FA 255 0800.27a9.4bf0 16s 0x0 0x9 0x1 0xF

Age of the port in the current state: 0d:00h:22m:22s

Port: Et0/1
------------

Port state = Up Mstr Assoc In-Bndl
Channel group = 1 Mode = Active Gcchange = -
Port-channel = Po1 GC = - Pseudo port-channel = Po1
Port index = 0 Load = 0x00 Protocol = LACP

Flags: S - Device is sending Slow LACPDUs F - Device is sending fast LACPDUs.
A - Device is in active mode. P - Device is in passive mode.

Local information:
LACP port Admin Oper Port Port
Port Flags State Priority Key Key Number State
Et0/1 SA bndl 32768 0x1 0x1 0x2 0x3D

Partner's information:

LACP port Admin Oper Port Port
Port Flags Priority Dev ID Age key Key Number State
Et0/1 FA 255 0800.27a9.4bf0 16s 0x0 0x9 0x2 0xF

Age of the port in the current state: 0d:00h:22m:21s

Port-channels in the group:
---------------------------

Port-channel: Po1 (Primary Aggregator)

------------

Age of the Port-channel = 0d:01h:27m:37s
Logical slot/port = 16/0 Number of ports = 2
HotStandBy port = null
Port state = Port-channel Ag-Inuse
Protocol = LACP
Port security = Disabled

Ports in the Port-channel:

Index Load Port EC state No of bits
------+------+------+------------------+-----------
0 00 Et0/0 Active 0
0 00 Et0/1 Active 0

Time since last port bundled: 0d:00h:22m:21s Et0/1
Time since last port Un-bundled: 0d:00h:23m:48s Et0/1

 

サーバの bonding の設定は、よくあるやつでOK(802.3ad なので、mode = 4)

うまくいくと、こうなる。

# cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

802.3ad info
LACP rate: fast
Min links: 0
Aggregator selection policy (ad_select): stable
System priority: 65535
System MAC address: 08:00:27:a9:4b:f0
Active Aggregator Info:
Aggregator ID: 1
Number of ports: 2
Actor Key: 9
Partner Key: 1
Partner Mac Address: aa:bb:cc:00:01:00

Slave Interface: enp0s3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:a9:4b:f0
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 65535
system mac address: 08:00:27:a9:4b:f0
port key: 9
port priority: 255
port number: 1
port state: 63
details partner lacp pdu:
system priority: 32768
system mac address: aa:bb:cc:00:01:00
oper key: 1
port priority: 32768
port number: 1
port state: 61

Slave Interface: enp0s8
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:e0:d6:ae
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 65535
system mac address: 08:00:27:a9:4b:f0
port key: 9
port priority: 255
port number: 2
port state: 63
details partner lacp pdu:
system priority: 32768
system mac address: aa:bb:cc:00:01:00
oper key: 1
port priority: 32768
port number: 2
port state: 61

  

ここで、実験。

# ifdown bond0

# ifup bond0

したり、

スイッチを停止したり、再起動したりして確認する。

をやってみる。

サーバで、# ifdown bond0 としたときの、スイッチのデバッグログ(一例)

IOU1#
*Mar 25 12:09:08.045: FEC: lacp_fec_unbundle_internal: Et0/0
*Mar 25 12:09:08.045: FEC: lacp_switch_delete_port_from_agport_internal: removing Et0/0 from Po1
*Mar 25 12:09:08.045: FEC: pagp_switch_delete_port_from_agport_list: afb->nports-- = 1 [Et0/0]
*Mar 25 12:09:08.329: FEC: lacp_fec_unbundle_internal: Et0/1
*Mar 25 12:09:08.329: FEC: lacp_switch_delete_port_from_agport_internal: removing Et0/1 from Po1
*Mar 25 12:09:08.329: FEC: pagp_switch_delete_port_from_agport_list: afb->nports-- = 0 [Et0/1]
*Mar 25 12:09:09.052: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down
IOU1#
*Mar 25 12:09:09.330: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down
*Mar 25 12:09:10.330: %LINK-3-UPDOWN: Interface Port-channel1, changed state to down
IOU1#
*Mar 25 12:09:11.331: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to down
IOU1#
*Mar 25 12:09:13.590: FEC: lacp_fec_dontbundle_internal: Et0/1
IOU1#
*Mar 25 12:09:13.590: %EC-5-L3DONTBNDL2: Et0/1 suspended: LACP currently not enabled on the remote port.
*Mar 25 12:09:13.917: FEC: lacp_fec_dontbundle_internal: Et0/0
IOU1#
*Mar 25 12:09:13.917: %EC-5-L3DONTBNDL2: Et0/0 suspended: LACP currently not enabled on the remote port.

 

 

スイッチを停止した時の、/proc/net/bonding/bond0 の結果(Link Aggregation できていない)(一例)

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: down
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

802.3ad info
LACP rate: fast
Min links: 2
Aggregator selection policy (ad_select): stable
System priority: 65535
System MAC address: 08:00:27:a9:4b:f0
Active Aggregator Info:
Aggregator ID: 7
Number of ports: 1
Actor Key: 9
Partner Key: 1
Partner Mac Address: 00:00:00:00:00:00

Slave Interface: enp0s3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:a9:4b:f0
Slave queue ID: 0
Aggregator ID: 7
Actor Churn State: monitoring
Partner Churn State: monitoring
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 65535
system mac address: 08:00:27:a9:4b:f0
port key: 9
port priority: 255
port number: 1
port state: 79
details partner lacp pdu:
system priority: 65535
system mac address: 00:00:00:00:00:00
oper key: 1
port priority: 255
port number: 1
port state: 1

Slave Interface: enp0s8
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:e0:d6:ae
Slave queue ID: 0
Aggregator ID: 8
Actor Churn State: monitoring
Partner Churn State: monitoring
Actor Churned Count: 0
Partner Churned Count: 1
details actor lacp pdu:
system priority: 65535
system mac address: 08:00:27:a9:4b:f0
port key: 9
port priority: 255
port number: 2
port state: 71
details partner lacp pdu:
system priority: 65535
system mac address: 00:00:00:00:00:00
oper key: 1
port priority: 255
port number: 1
port state: 1

 

サーバで、# ifup bnod0 したときの、スイッチのデバッグログ(一例)

IOU1#
*Mar 25 12:11:37.006: FEC: lacp_fec_unbundle_internal: Et0/1
*Mar 25 12:11:37.006: FEC: Unbundling req for port: Et0/1 neitherstand-alone Agport nor in a bundle
*Mar 25 12:11:37.006: FEC: lacp_switch_add_port_to_associated_list_internal: Et0/1 added to list for Po1
*Mar 25 12:11:37.006: FEC: lacp_fec_unbundle_internal: Et0/0
*Mar 25 12:11:37.006: FEC: Unbundling req for port: Et0/0 neitherstand-alone Agport nor in a bundle
*Mar 25 12:11:37.006: FEC: lacp_switch_add_port_to_associated_list_internal: Et0/0 added to list for Po1
*Mar 25 12:11:38.006: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up
*Mar 25 12:11:38.006: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
IOU1#
*Mar 25 12:11:40.447: FEC: pagp_switch_add_port_to_agport_list: afb->nports++ = 1 [Et0/0]
*Mar 25 12:11:40.447: FEC: lacp_switch_add_port_to_agport_internal: Et0/0 added to aggregator Po1 list
*Mar 25 12:11:40.448: %IDBMAN-3-INVALIDAGGPORTBANDWIDTH: Port-channel1(16 / 0) has an invalid bandwidth value of 0
*Mar 25 12:11:40.639: FEC: pagp_switch_add_port_to_agport_list: afb->nports++ = 2 [Et0/1]
*Mar 25 12:11:40.639: FEC: lacp_switch_add_port_to_agport_internal: Et0/1 added to aggregator Po1 list
IOU1#
*Mar 25 12:11:40.639: %IDBMAN-3-INVALIDAGGPORTBANDWIDTH: Port-channel1(16 / 0) has an invalid bandwidth value of 0
IOU1#
*Mar 25 12:11:42.450: %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
*Mar 25 12:11:43.455: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up

 

スイッチを再起動した時の、/proc/net/bonding/bond0 の結果(一例)

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

802.3ad info
LACP rate: fast
Min links: 2
Aggregator selection policy (ad_select): stable
System priority: 65535
System MAC address: 08:00:27:a9:4b:f0
Active Aggregator Info:
Aggregator ID: 7
Number of ports: 2
Actor Key: 9
Partner Key: 1
Partner Mac Address: aa:bb:cc:00:01:00

Slave Interface: enp0s3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:a9:4b:f0
Slave queue ID: 0
Aggregator ID: 7
Actor Churn State: monitoring
Partner Churn State: monitoring
Actor Churned Count: 0
Partner Churned Count: 1
details actor lacp pdu:
system priority: 65535
system mac address: 08:00:27:a9:4b:f0
port key: 9
port priority: 255
port number: 1
port state: 63
details partner lacp pdu:
system priority: 32768
system mac address: aa:bb:cc:00:01:00
oper key: 1
port priority: 32768
port number: 1
port state: 13

Slave Interface: enp0s8
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:e0:d6:ae
Slave queue ID: 0
Aggregator ID: 7
Actor Churn State: monitoring
Partner Churn State: monitoring
Actor Churned Count: 1
Partner Churned Count: 2
details actor lacp pdu:
system priority: 65535
system mac address: 08:00:27:a9:4b:f0
port key: 9
port priority: 255
port number: 2
port state: 15
details partner lacp pdu:
system priority: 32768
system mac address: aa:bb:cc:00:01:00
oper key: 1
port priority: 32768
port number: 2
port state: 5

 

 

再起動しても、異常なく繋がった。

 (参考)

https://www.kernel.org/doc/Documentation/networking/bonding.txt

 

1台のハードディスクに OS をインストールしているが、ハードディスクを 1台追加し、 RAID1 (ミラーリング) を実現する方法

1. 同じサイズ(または新しいHDは大きい容量を持つ)の HD を用意する。

2. パーティションテーブルをコピーする。
# sfdisk -d /dev/sda | sfdisk --force /dev/sdb
確認する。
# lsblk -f
/dev/sda1 を真似して以下を実行する。
# mkfs.ext4 /dev/sdb1
確認する。
# lsblk -f

3. 以下を確認する。
# fdisk -l
/dev/sdb のパーティションを、Linux raid autodetect に変更すること。
やり方としては、fdisk /dev/sdb use "t" to convert all 3 partitions to "fd"
以下を確認する。
# fdisk -l
これも確認すること。
# parted
(parted) select /dev/sdb
(parted) print

(表示例)
========
1 ... boot,raid
2 ... raid
========

# mdadm --zero-superblock /dev/sdb1
# mdadm --zero-superblock /dev/sdb2
# mdadm --create /dev/md0 --level=1 --metadata=0.90 --raid-disks=2 missing /dev/sdb1
# mdadm --create /dev/md1 --level=1 --metadata=0.90 --raid-disks=2 missing /dev/sdb2
確認する。
# cat /proc/mdstat
# lsblk -f
# fdisk -l

4. /boot の内容を、/dev/mdX にコピーする。
# mkdir /mnt/tmp
初期化する。
# mkfs.ext4 /dev/mdX
# mount /dev/mdX /mnt/tmp
# rsync -aAXv --delete /boot/* /mnt/tmp
# umount /mnt/tmp

5. device.map を編集する
# vim /boot/grub/device.map
(表示例)
========
# this device map was generated by anaconda
(hd0) /dev/sda
----
以下を追加する。
(hd1) /dev/sdb
----
========
同様の作業を、/dev/mdX 上のデバイスでも実行する。
vim /mnt/tmp/grub/device.map
以下を追加して保存。
(hd1) /dev/sdb

以下のコマンドを実行する。
# grub-install /dev/sdb
(表示例)
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect.
fix it and re-run the script 'grub-install'.

# this device map was generated by anaconda
(hd0) /dev/sda
(hd1) /dev/sdb
----

これでよい。
まだまだ、作業が続きます。
ここで、一度仮想マシンを保存しておきます。
スナップショット作成 - "RAID-TEST-1"
ーーーーーーーーーーーーーーーーーーーーーーーー
以下を設定して、
# vim /boot/grub/grub.conf
rd_NO_MD を削除する。
再起動 - 起動した。

以下をやってみる。
mdadm --detail --scan
(表示)
ARRAY /dev/md/0_0 metadata=0.90 UUID=xxxx:xxxx:xxxx:xxxx
ARRAY /dev/md/1_0 metadata=0.90 UUID=xxxx:xxxx:xxxx:xxxx

mdadm --detail --scan > /etc/mdadm.conf
ここで、一度仮想マシンを保存しておきます。

#### スナップショット作成 - "RAID-TEST-2"

再起動する。
起動しました。

次に、/dev/sdb1 から boot させてみます。
/etc/fstab を編集して、/dev/sdb1 の ext4 にフォーマットされたデバイスの UUID にしてみます。
再起動します。
無事に、/dev/sdb1 の ext4 にフォーマットされたデバイスの UUID から起動したようです。
ここで、一度仮想マシンを保存しておきます。

#### スナップショット作成 - "RAID-TEST-3"

初期化する。
# mkfs.ext4 /dev/mdX
# lsblk -f

RAID アレイ /dev/md127 に LVM を作成して、現在の VG Name VolGroup に参加させる。
# pvcreate /dev/mdX
(表示例)
Physical volumn "/dev/mdX" successfully created
# vgextend VolGroup /dev/mdX
(表示例)
Volume group "VolGroup" successfully extended
確認する。

# pvdisplay
(表示例)
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup
PV Size 31.51 GiB /not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 8066
Free PE 0
Allocated PE 8066
PV UUID xxxx-xxxx-xxxx...
...(snip)...

--- Physical volume ---
PV Name /dev/mdX
VG Name VolGroup
PV Size 31.51 GiB /not usable 2.94 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 8066
Free PE 8066
Allocated PE 0
PV UUID xxxx-xxxx-xxxx...
...(snip)...

以下のコマンドでも確認する。
# vgs
(表示の一例)
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 2 0 wz- -n- 63.02g 31.51g

Volume Group を確認する。
# lvs -o+devices
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert Devices
lv_root VolGroup -wi-ao---- 28.31g /dev/sda2(0)
lv_swap VolGroup -wi-ao---- 3.20g /dev/sda2(7247)

データを移動する(コピーだと、/dev/sda2を抜けないので注意)。
実行
# pvmove -i 2 /dev/sda2 /dev/mdX
(表示例)
...(snip)...
/dev/sda2: Moved: 3.5%
...(snip)...
100% になったら終了

ここで、一度仮想マシンを保存しておきます。

#### スナップショット作成 - "RAID-TEST-4"

再起動する。

では、/dev/sda2 を抜いてみる。
VolGroup から /dev/sda2 を抜く
# vgreduce VolGroup /dev/sda2
(表示例)
Removed "/dev/sda2" from volume group "VolGroup"
# pvremove /dev/sda2
(表示例)
Labels on physical volume "/dev/sda2" successfully wiped
確認する
# pvdisplay
(表示例)
--- Physical volume ---
PV Name /dev/mdX
VG Name VolGroup
PV Size 31.51 GiB / not usable 2.94 MiB
...(snip)...

ここで、lsblk -f を確認する。
# lsblk -f
(確認)
sdb2 linux_raid_mem
|
-md127 LVM2_member
|-VolGroup-lv_root (dm-0)
ext4 xxxx-xxxx-... /
|-VolGroup-lv_swap (dm-1)
ext4 xxxx-xxxx-... [SWAP]

sda から消されて、sdb に、移った感じだ。

#### RAID-TEST-4.5 として保存する。####

ちゃんと起動しました。

grub.conf を編集する。

次のカーネルオプションを削除する。
rd_NO_MD rd_NO_DM
もう一度、mdadm.conf を作成します。
mdadm --detail --scan > /etc/mdadm.conf
そして、initramfs を再作成する。
設定等やドライバを含めまる。
# dracut -f -v --mdadmconf --lvmconf --add-drivers "raid1 raid10 raid456"

/boot に initramfs が異常なく作成できたようであれば、
ここで、一度仮想マシンを保存しておきます。

#### スナップショット作成 - "RAID-TEST-5"

再起動する。
# shutdown -r now

立ち上がった。
ここで、一度仮想マシンを保存しておきます。

#### スナップショット作成 - "RAID-TEST-6"

再起動する。
うまくいきました。
今、起動しているのは、/dev/sdb からという認識です。
grub.conf には、root (hd0,0) としていました。
これは、このままでいきます。
立ち上がりました。
ここで、一度仮想マシンを保存しておきます。

#### スナップショット作成 - "RAID-TEST-7"

それでは、実験です。
/dev/sda を切り離します。
その前に、fstab を編集します。
/dev/md127 /boot ext4 defaults 1 2
とします。
(そして、もう一度、mdadm を実行してみます。)

# fdisk /dev/sda
d 1 d 2 w

再起動します。
上手く起動しないようです。
レスキューDVDから起動します。
# grub
grub> find /grub/grub.conf としました。
grub> root
(hd0,0): Filesystem type unknown, partition type 0x0
grub> find /grub/grub.conf または、 find /grub/stage1
(hd0,0)
以下のようにした。
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
grub> root
(hd0,0): Filesystem type is ext2fs, partition type 0x0
grub> reboot

起動した。

#### スナップショット作成 - "RAID-TEST-8"

# lsblk -f
上記で、sda に何もぶら下がっていないことを確認します。
では、VirtualBox で、最初のハードディスクを切り離してみます。
シャットダウンして、ハードディスクを、1つにしてみます。
わおーー、起動しましたーーー!!

これで、最初のハードディスクが一つの状態から、別のハードディスクに RAID1 になった状態で
移行できたことにーー、まだなりません。
なぜなら、今、ハードディスクが一つだからです。では、もう一つ、同じ容量のハードディスクを
つなげて、本当のRAID1にしてみましょう。
さて、以下のコマンドを実行します。

# lsblk -f

NAME FSTYPE LABEL UUID MOUNTPOINT
sr0
sda
sda1 linux_raid_mem xxxxxxx
md127 ext4 xxxxxxx
sda2 linux_raid_mem xxxxxxx
md126 LVM2_member xxxxxxx
VolGroup-lv_root (dm-0)
ext4 xxxxxxx
VolGroup-lv_swap (dm-1)
swap xxxxxxx
すばらしいーー。

#### スナップショット作成 - "RAID-TEST-9"

では、ハードディスクを追加してみましょう。

同じ要領のディスクを追加します。
では、前と同じ様にやっていきます。

# sfdisk /dev/sda | sfdisk --force /dev/sdb
# mkfs.ext4 /dev/sdb1
# mkfs.ext4 /dev/sdb2

# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sda2[1]
33041344 blocks [2/1] [_U]
md127 : active raid1 sda1[1]
511936 blocks [2/1] [_U]
unused devices: <none>

# mdadm -D /dev/mdX
# mdadm -D /dev/mdX

# mdadm --manage /dev/mdX --add /dev/sdb1
# mdadm --manage /dev/mdX --add /dev/sdb2

# cat /proc/mdstat
100% になるまで、観察します。
完了しました。

#### スナップショット作成 - "RAID-TEST-10"

ハードディスクを外します。
再起動します。
立ち上がらないです。
レスキューモードで立ち上げます。
# grub
grub> root
(hd0,0)
となっていたので、
grub> set root (hd0,0)
grub> setup (hd0)
grub> root
grub> reboot
bash# reboot
立ち上がりました。
さがせなければ、以下のようにします。
grub> find /grub/grub.conf

#### スナップショット作成 - "RAID-TEST-11"

では、ハードディスクを追加します。
no such partition...
grub> edit > root (hd0,0)
立ち上がりました。

今までのハードディスクをポート0につなぎます。
新しいハードディスクをポート1につなぎます。
容量は、少し大きいものがよいでしょう。
# fdisk /dev/sdb
同じように設定します。

一度、/dev/sda を実行して、p して、メモしておきます。
/dev/sda1 * 1 64 51200 fd
/dev/sda2 64 4178 33041408 fd

# mdadm --manage /dev/mdX --add /dev/sdb1
# mdadm --manage /dev/mdX --add /dev/sdb2

# cat /proc/mdstat
100% になったら終了。
以下のコマンドを実行して、同じ構成になったことを確認する。
# lsblk -f

#### スナップショット作成 - "RAID-TEST-12"

再起動
立ち上がります。

grub.conf を編集ししてみます。
(hd0,0) を、(hd1,0) にしてみます。
立ち上がります。

元に戻します。(hd1,0) を、(hd0,0) に。

では、いよいよ、ハードディスクを外してみます。
新しいハードディスクを外します。
起動させます。起動しました。
シャットダウンします。
古いハードディスク(RAID-NEWDISK-ADDED)を外して、新しいハードディスク(RAID-NEWLY-ADDED2)を接続します。
起動します。
おめでとうございます!成功です。