computerの日記

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

STPトポロジ-3(パスコスト変更による通信経路の変更1)

このタスクでは、802.1d PVST Spanning-Tree VLAN-3 のある特定のパスを操ることによって、VLAN-3 に所属する R2 から R3 へのトラフィックping)を、SW3-->SW2 の経路ではなく、SW3-->SW1-->SW2 の経路を通るようにしなさい。

ただ一つのコマンドを、ただ一つのスイッチ上で、上記を実現させなさい。
SW3 から SW1 へのトラフィックは、Fa1/15 上で行いなさい。SW1 と SW2 との間で、EtherChannel のどのリンクがフレームの送信に使用されるかは、はっきりとしない。
このタスクを完遂するために、ルートブリッジの設定を変更することは許されない。

トポロジは、以下を使います。

f:id:intrajp:20171205031524p:plain

--------
現在のコストを確認すると、SW2 がルートブリッジで、SW3 は、SW2 と直接繋がっているので、パスコストは、19である事が分かる。
SW3 fa1/15-->SW1 fa1/15-->SW2 という経路にするためには、SW3-->SW2 のパスコスト 19 より小さいパスコストをとればよい。
したがって、総パスコストを、18にすれば、実現できるはずである。ここで、SW2 と SW1 のポートチャネルのパスコストを確認すると、
9 となっている。したがって、SW3 fa1/15 のパスコストを 9 にすれば、良いと思われる。

SW2#show spanning-tree vlan 3 brief

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c207.153c.0000
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 8192
Address c207.153c.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 0 8192 c207.153c.0000 128.41
FastEthernet1/6 128.47 128 19 FWD 0 8192 c207.153c.0000 128.47
FastEthernet1/7 128.48 128 19 FWD 0 8192 c207.153c.0000 128.48
FastEthernet1/8 128.49 128 19 FWD 0 8192 c207.153c.0000 128.49
Port-channel1 129.65 128 9 FWD 0 8192 c207.153c.0000 129.65

SW3#show spanning-tree vlan 3 brief

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c207.153c.0000
Cost 19
Port 47 (FastEthernet1/6)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c201.1621.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 19 32768 c201.1621.0000 128.41
FastEthernet1/6 128.47 128 19 FWD 0 8192 c207.153c.0000 128.47
FastEthernet1/7 128.48 128 19 BLK 0 8192 c207.153c.0000 128.48
FastEthernet1/8 128.49 128 19 BLK 0 8192 c207.153c.0000 128.49
FastEthernet1/13 128.54 128 19 BLK 9 32768 c206.152d.0001 128.54
FastEthernet1/14 128.55 128 19 BLK 9 32768 c206.152d.0001 128.55
FastEthernet1/15 128.56 128 19 BLK 9 32768 c206.152d.0001 128.56

SW1#show spanning-tree vlan 3 brief

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c207.153c.0000
Cost 9
Port 321 (Port-channel1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c206.152d.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/13 128.54 128 19 FWD 9 32768 c206.152d.0001 128.54
FastEthernet1/14 128.55 128 19 FWD 9 32768 c206.152d.0001 128.55
FastEthernet1/15 128.56 128 19 FWD 9 32768 c206.152d.0001 128.56
Port-channel1 129.65 128 9 FWD 0 8192 c207.153c.0000 129.65


では、コマンドを発行してみる。

SW3#conf t
SW3(config)#interface fa1/15
SW3(config-if)#spanning-tree vlan 3 cost 9

SW3#show spanning-tree vlan 3 brief

SW3 上で、fa1/6 がブロッキングになり、fa1/15 がフォワードになりました。

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c207.153c.0000
Cost 18
Port 56 (FastEthernet1/15)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c201.1621.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 18 32768 c201.1621.0000 128.41
FastEthernet1/6 128.47 128 19 BLK 0 8192 c207.153c.0000 128.47
FastEthernet1/7 128.48 128 19 BLK 0 8192 c207.153c.0000 128.48
FastEthernet1/8 128.49 128 19 BLK 0 8192 c207.153c.0000 128.49
FastEthernet1/13 128.54 128 19 BLK 9 32768 c206.152d.0001 128.54
FastEthernet1/14 128.55 128 19 BLK 9 32768 c206.152d.0001 128.55
FastEthernet1/15 128.56 128 9 FWD 9 32768 c206.152d.0001 128.56

ここで、目で見て確認したいと考えたのですが、いいコマンドがあります。
以下の debug コマンドで、spanning-tree の イベントを観察できます。

# debug spannin-tree events

停止するには、頭に no をつけます。

# no debug spanning-tree events

では、一度、SW3 の fa1/15 のパスコストを 19 に戻しておきます。

SW3(config-if)#spanning-tree vlan 3 cost 19

デバッグモードで、spanning-tree events を観察する設定にします。

SW3#debug spanning-tree events
Spanning Tree event debugging is on

では、もう一度、SW3 の fa1/15 のパスコストを 9 にして、また 19 に戻す、というのをやってみます。

SW3(config-if)#spanning-tree vlan 3 cost 9
SW3(config-if)#
*Mar 1 07:23:14.710: STP: VLAN3 new root port Fa1/15, cost 18
*Mar 1 07:23:14.710: STP: VLAN3 sent Topology Change Notice on Fa1/15
*Mar 1 07:23:14.762: STP: VLAN3 Fa1/6 -> blocking
*Mar 1 07:23:14.762: STP: VLAN3 Fa1/15 -> listening
SW3(config-if)#
*Mar 1 07:23:29.762: STP: VLAN3 Fa1/15 -> learning
SW3(config-if)#
*Mar 1 07:23:44.770: STP: VLAN3 sent Topology Change Notice on Fa1/15
*Mar 1 07:23:44.774: STP: VLAN3 Fa1/15 -> forwarding
SW3(config-if)#spanning-tree vlan 3 cost 19
SW3(config-if)#
*Mar 1 07:24:43.122: STP: VLAN3 new root port Fa1/6, cost 19
*Mar 1 07:24:43.158: STP: VLAN3 Fa1/6 -> listening
*Mar 1 07:24:43.158: STP: VLAN3 sent Topology Change Notice on Fa1/6
*Mar 1 07:24:43.158: STP: VLAN3 Fa1/15 -> blocking
SW3(config-if)#
*Mar 1 07:24:58.166: STP: VLAN3 Fa1/6 -> learning
SW3(config-if)#
*Mar 1 07:25:13.174: STP: VLAN3 sent Topology Change Notice on Fa1/6
*Mar 1 07:25:13.178: STP: VLAN3 Fa1/6 -> forwarding

30秒で変更されたようです。戻す時も同じでした。

デバッグモードを戻します。

SW3#no debug spanning-tree events
Spanning Tree event debugging is off

お疲れさまです。次回をお楽しみに。

STPトポロジ-2(ROOT BRIDGE の変更)

このタスクにおいては、あらかじめ設定されたスイッチに対して、802.1d PVST Spanning-Tree パラメータを操って、
特定の VLAN において、Spanning-Tree Root Bridge の役割を持たせます。

(タスク)

Switch-2 が、VLAN-3 において、ブリッジプライオリティ 8192 になるようなコマンドを発行しなさい。
Switch-1 が、VLAN-4 において、ブリッジプライオリティ 8192 になるようなコマンドを発行しなさい。

 

基本設定を、以下のリンクにしたがっておこなう。
http://intrajp-computer.hatenadiary.jp/entry/2017/12/03/231614

 

spanning-tree を確認する。

SW1#show spanning-tree vlan 3 brief

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address c201.1621.0000
Cost 19
Port 54 (FastEthernet1/13)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c206.152d.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/13 128.54 128 19 FWD 0 32768 c201.1621.0000 128.54
FastEthernet1/14 128.55 128 19 BLK 0 32768 c201.1621.0000 128.55
FastEthernet1/15 128.56 128 19 BLK 0 32768 c201.1621.0000 128.56
Port-channel1 129.65 128 9 FWD 19 32768 c206.152d.0001 129.65


SW2#show spanning-tree vlan 3 brief

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address c201.1621.0000
Cost 28
Port 321 (Port-channel1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c207.153c.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 28 32768 c207.153c.0000 128.41
Port-channel1 129.65 128 9 FWD 19 32768 c206.152d.0001 129.65


SW3#show spanning-tree vlan 3 brief

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address c201.1621.0000
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c201.1621.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 0 32768 c201.1621.0000 128.41
FastEthernet1/6 128.47 128 19 FWD 0 32768 c201.1621.0000 128.47
FastEthernet1/7 128.48 128 19 FWD 0 32768 c201.1621.0000 128.48
FastEthernet1/8 128.49 128 19 FWD 0 32768 c201.1621.0000 128.49
FastEthernet1/13 128.54 128 19 FWD 0 32768 c201.1621.0000 128.54
FastEthernet1/14 128.55 128 19 FWD 0 32768 c201.1621.0000 128.55
FastEthernet1/15 128.56 128 19 FWD 0 32768 c201.1621.0000 128.56

現在のところ、root bridge は、SW3 のようだ。
では、以下のコマンドを発行します。
Switch-2 が、VLAN-3 において、ブリッジプライオリティ 8192 になるようなコマンドを発行しなさい。

SW2(config)#spanning-tree vlan 3 priority 8192
確認します。SW2がルート・ブリッジになったことがわかります。
SW2#show spanning-tree vlan 3 brief

VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c207.153c.0000
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 8192
Address c207.153c.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 0 8192 c207.153c.0000 128.41
Port-channel1 129.65 128 9 FWD 0 8192 c207.153c.0000 129.65

では、トポロジに基づいて、VLAN 4 も作成しましょう。
まず、PC1,PC2を、それぞれ、SW2、SW1に接続します。
それぞれで、dhcp でアドレスを取得してみます。

PC1>dhcp
DDD
Can't find dhcp server

PC2>dhcp
DDD
Can't find dhcp server

できません。
SW1 に vlan 4 を設定して、トランクやスイッチポートを適切に設定して、IP アドレスを取得できました。
PC1> dhcp
DORA IP 4.4.4.2/24 GW 4.4.4.1
PC2> dhcp
DORA IP 4.4.4.3/24 GW 4.4.4.1

では、現在の STP を確認します。

SW1#show spanning-tree vlan 4 brief

VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address c201.1621.0002
Cost 19
Port 54 (FastEthernet1/13)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c206.152d.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 19 32768 c206.152d.0002 128.41
FastEthernet1/13 128.54 128 19 FWD 0 32768 c201.1621.0002 128.54
FastEthernet1/14 128.55 128 19 BLK 0 32768 c201.1621.0002 128.55
FastEthernet1/15 128.56 128 19 BLK 0 32768 c201.1621.0002 128.56
Port-channel1 129.65 128 9 FWD 19 32768 c206.152d.0002 129.65

SW2#show spanning-tree vlan 4 brief

VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address c201.1621.0002
Cost 19
Port 47 (FastEthernet1/6)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c207.153c.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/4 128.45 128 19 FWD 19 32768 c207.153c.0002 128.45
FastEthernet1/6 128.47 128 19 FWD 0 32768 c201.1621.0002 128.47
FastEthernet1/7 128.48 128 19 BLK 0 32768 c201.1621.0002 128.48
FastEthernet1/8 128.49 128 19 BLK 0 32768 c201.1621.0002 128.49
Port-channel1 129.65 128 9 BLK 19 32768 c206.152d.0002 129.65

SW3#show spanning-tree vlan 4 brief

VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address c201.1621.0002
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c201.1621.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/6 128.47 128 19 FWD 0 32768 c201.1621.0002 128.47
FastEthernet1/7 128.48 128 19 FWD 0 32768 c201.1621.0002 128.48
FastEthernet1/8 128.49 128 19 FWD 0 32768 c201.1621.0002 128.49
FastEthernet1/13 128.54 128 19 FWD 0 32768 c201.1621.0002 128.54
FastEthernet1/14 128.55 128 19 FWD 0 32768 c201.1621.0002 128.55
FastEthernet1/15 128.56 128 19 FWD 0 32768 c201.1621.0002 128.56

ここで、タスクを実行します。

Switch-1 が、VLAN-4 において、ブリッジプライオリティ 8192 になるようなコマンドを発行しなさい。

SW1(config)#spanning-tree vlan 4 priority 8192

SW1#show spanning-tree vlan 4 brief

VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c206.152d.0002
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 8192
Address c206.152d.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 0 8192 c206.152d.0002 128.41
FastEthernet1/13 128.54 128 19 FWD 0 8192 c206.152d.0002 128.54
FastEthernet1/14 128.55 128 19 FWD 0 8192 c206.152d.0002 128.55
FastEthernet1/15 128.56 128 19 FWD 0 8192 c206.152d.0002 128.56
Port-channel1 129.65 128 9 FWD 0 8192 c206.152d.0002 129.65

SW2#show spanning-tree vlan 4 brief

VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c206.152d.0002
Cost 9
Port 321 (Port-channel1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c207.153c.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/4 128.45 128 19 FWD 9 32768 c207.153c.0002 128.45
FastEthernet1/6 128.47 128 19 FWD 9 32768 c207.153c.0002 128.47
FastEthernet1/7 128.48 128 19 FWD 9 32768 c207.153c.0002 128.48
FastEthernet1/8 128.49 128 19 FWD 9 32768 c207.153c.0002 128.49
Port-channel1 129.65 128 9 FWD 0 8192 c206.152d.0002 129.65

SW3#show spanning-tree vlan 4 brief

VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c206.152d.0002
Cost 19
Port 54 (FastEthernet1/13)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32768
Address c201.1621.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/6 128.47 128 19 BLK 9 32768 c207.153c.0002 128.47
FastEthernet1/7 128.48 128 19 BLK 9 32768 c207.153c.0002 128.48
FastEthernet1/8 128.49 128 19 BLK 9 32768 c207.153c.0002 128.49
FastEthernet1/13 128.54 128 19 FWD 0 8192 c206.152d.0002 128.54
FastEthernet1/14 128.55 128 19 BLK 0 8192 c206.152d.0002 128.55
FastEthernet1/15 128.56 128 19 BLK 0 8192 c206.152d.0002 128.56

SW1 が、ROOT BRIDGE になりました。

f:id:intrajp:20171205031220p:plain

 

STPトポロジ-1(準備編)

お疲れさまです。

Cisco Switch を、GNS3 でエミュレートするシリーズです。

今回は、STP を実験しますが、先ずは、必要な機器を設定して、準備します。

以下のようなトポロジになります。スイッチには、3725 の NM-16ESW を使っています。ルータは、7200 です。

SW1をVTPサーバにして、設定を伝搬させます。また、DHCPサーバとして動作させ、アドレスをルータに配布します。Cisco機器のDHCPは、細かい設定がにがてみたいですけど。まあ、それが本位ではないので、ここでは、目をつぶりましょう。

トランクの設定や、スイッチポートにVLANを設定するのを忘れないように。また、ポートチャネルを設定しているので、その設定も覚えましょう。ここに書いてある設定ができたら、次に進んでいきます。

f:id:intrajp:20171203231231p:plain

・ホストネームの設定(各端末)

(一例)

SW1(config)#hostname SW1

SW2(config)#hostname SW2

SW3(config)#hostname SW3

 

・enable password 設定(各端末)

(一例)

SW1(config)#enable password cisco

SW2(config)#enable password cisco

SW3(config)#enable password cisco

 

telnet のパスワード設定(各端末)

(一例)

SW1(config)#line vty 0 5

SW1(config-line)password cisco

SW2(config)#line vty 0 5

SW2(config-line)password cisco

SW3(config)#line vty 0 5

SW3(config-line)password cisco

 

・管理 VLAN の設定

VLAN1 Management

SVI Sw1:1.1.1.1/24

SVI Sw2:1.1.1.2/24

SVI Sw3:1.1.1.3/24

(一例)

SW1#configure terminal

SW1(config)#interface vlan1

SW1(config-if)#ip address 1.1.1.1 255.255.255.0

SW1(config)#no shutdown

SW2#configure terminal

SW2(config)#interface vlan1

SW2(config-if)#ip address 1.1.1.2 255.255.255.0

SW2(config)#no shutdown

SW3#configure terminal

SW3(config)#interface vlan1

SW3(config-if)#ip address 1.1.1.3 255.255.255.0

SW3(config)#no shutdown

 

・VTPの設定

VTP DOMAIN cisco

VTP PASSWORD cisco

(一例)

SW1(config)#vtp version 2

SW1(config)#vtp mode server

SW1(config)#vtp domain cisco

SW2(config)#vtp version 2

SW2(config)#vtp domain cisco

SW2(config)#vtp password cisco

SW2(config)#vtp mode client

SW3(config)#vtp version 2

SW3(config)#vtp domain cisco

SW3(config)#vtp password cisco

SW3(config)#vtp mode client

 

・VLANの作成

(一例:SW1 だけで作成し、他のSWに伝搬する)

SW1#vlan database

SW1(vlan)#vlan 3

SW1(vlan)#exit

 

・ポートチャネルの設定

トポロジ参照

(一例)

SW1(config)#interface range fa1/10 - 12

SW1(config-if-range)#shutdown

SW1(config-if-range)#channel-protocol pagp

SW1(config-if-range)#channel-group 1 mode desireble (on)

SW1(config-if-range)#no shutdown

SW2(config)#interface range fa1/10 - 12

SW2(config-if-range)#shutdown

SW2(config-if-range)#channel-protocol pagp

SW2(config-if-range)#channel-group 1 mode auto (on)

SW2(config-if-range)#no shutdown

 

・トランクポートの設定

トポロジ参照

(一例)

SW1(config)#interface fa1/6 - 8 , fa/13 - 15 , po1

SW1(config-if-range)#switchport trunk enc dot1q

SW1(config-if-range)#switchport mode dynamic desirable (trunk)

SW1(config-if-range)#switchport trunk allowed vlan add 3

SW2(config)#interface fa1/6 - 8 , po1

SW2(config-if-range)#switchport trunk enc dot1q

SW2(config-if-range)#switchport mode dynamic desirable (trunk)

SW2(config-if-range)#switchport trunk allowed vlan add 3

SW3(config)#interface fa1/6 - 8 , fa/13 - 15

SW3(config-if-range)#switchport trunk enc dot1q

SW3(config-if-range)#switchport mode dynamic auto (trunk)

SW3(config-if-range)#switchport trunk allowed vlan add 3

 

・switchport にVLANを割り当てる設定

(一例)

SW2(conf)#interface fa1/0

SW2(conf-if)#switchport

SW2(conf-if)#switchport access vlan 3

SW3(conf)#interface fa1/0

SW3(conf-if)#switchport

SW3(conf-if)#switchport access vlan 3

 

DHCP SERVERの設定

(一例:SW1から、他のサーバに配布する)

SW1(config)#ip dhcp pool vlan3

SW1(dhcp-config)#network 3.3.3.1 255.255.255.0

SW1(dhcp-config)#default-router 3.3.3.1

SW1(config)#

SW1(config)#interface vlan3

SW1(config-if)#ip address 3.3.3.1 255.255.255.0

R1(config)#interface fa1/0

R1(config-if)#ip address dhcp

R1(config-if)#no shutdown

R2(config)#interface fa1/0

R2(config-if)#ip address dhcp

R2(config-if)#no shutdown

 

設定の確認方法

(確認方法の一例)

L2の隣接デバイス確認

#show cdp neighbors

VLANの確認:

#show vlan(-switch)

VTPの確認

#show vtp status

論理ポートの確認:

#show ip interface brief

トランクポートの確認

#show interface trunk

 

各スイッチに telnet 接続して、パスワード投入後、設定や確認を行いましょう。

各ルータがアドレスを取得したことも確認しましょう。

 

お疲れさまです。今回の実験は終了です。次回は、このトポロジを元に、踏み込んでいきたいと思ます。

次回をお楽しみに。

 

 

topology-1

こんなトポロジで遊んでいます。

VLANをSwitch-1 上で作成して、他のスイッチに伝搬させ、かつ、DHCPサーバとして動作させて、ルータにアドレスを配布する、って感じです。

 

f:id:intrajp:20171130051334p:plain

Switch-1#show ip dhcp server statistics
Memory usage 28077
Address pools 4
Database agents 0
Automatic bindings 8
Manual bindings 0
Expired bindings 0
Malformed messages 0
Secure arp entries 0

Message Received
BOOTREQUEST 0
DHCPDISCOVER 9
DHCPREQUEST 8
DHCPDECLINE 0
DHCPRELEASE 0
DHCPINFORM 0

Message Sent
BOOTREPLY 0
DHCPOFFER 9
DHCPACK 8
DHCPNAK 0

Switch-1#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
10.10.10.11 0063.6973.636f.2d63. Mar 02 2002 01:40 AM Automatic
6130.352e.3039.3532.
2e30.3031.632d.4661.
312f.30
10.10.10.12 0063.6973.636f.2d63. Mar 02 2002 01:42 AM Automatic
6130.362e.3039.3731.
2e30.3031.632d.4661.
312f.30
10.10.10.34 0063.6973.636f.2d63. Mar 02 2002 06:45 AM Automatic
6130.352e.3039.3532.
2e30.3031.642d.4661.
312f.31
10.10.10.35 0063.6973.636f.2d63. Mar 02 2002 06:45 AM Automatic
6130.362e.3039.3731.
2e30.3031.642d.4661.
312f.31
20.20.20.98 0063.6973.636f.2d63. Mar 02 2002 07:06 AM Automatic
6130.382e.3039.3866.
2e30.3031.642d.4661.
312f.31
20.20.20.99 0063.6973.636f.2d63. Mar 02 2002 07:06 AM Automatic
6130.372e.3039.3830.
2e30.3031.632d.4661.
312f.30
30.30.30.2 0063.6973.636f.2d63. Mar 02 2002 06:48 AM Automatic
6130.382e.3039.3866.
2e30.3031.632d.4661.
312f.30
30.30.30.3 0063.6973.636f.2d63. Mar 02 2002 06:48 AM Automatic
6130.372e.3039.3830.
2e30.3031.642d.4661.
312f.31

Rtr-1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES NVRAM administratively down down
FastEthernet1/0 10.10.10.11 YES DHCP up up
FastEthernet1/1 10.10.10.34 YES DHCP up up

Rtr-2#show ip int bri
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES NVRAM administratively down down
FastEthernet1/0 10.10.10.12 YES DHCP up up
FastEthernet1/1 10.10.10.35 YES DHCP up up

Rtr-3#show ip int bri
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES NVRAM administratively down down
FastEthernet1/0 20.20.20.99 YES DHCP up up
FastEthernet1/1 30.30.30.3 YES DHCP up up

Rtr-4#show ip int bri
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES NVRAM administratively down down
FastEthernet1/0 30.30.30.2 YES DHCP up up
FastEthernet1/1 20.20.20.98 YES DHCP up up

Rtr-1#ping 10.10.10.12
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.12, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 52/115/148 ms
Rtr-1#ping 10.10.10.35
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.35, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 64/127/180 ms
Rtr-1#ping 30.30.30.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 30.30.30.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 140/246/520 ms
Rtr-1#ping 30.30.30.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 30.30.30.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 132/330/568 ms
Rtr-1#ping 20.20.20.99
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.20.20.99, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 136/145/180 ms
Rtr-1#ping 20.20.20.98
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.20.20.98, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 224/309/584 ms

GNS3 で疑似的にインタフェースのスピードを変える方法

7200を利用すれば、Gig インタフェースが利用できますが、以下の様にしてもできるようです。

 

GNS3 | The software that empowers network professionals

 

なにかあればお知らせください。

Fedora27 で、GNS3 を動かす

Fedora27 にして、GNS3 を動かしてみたら、エラーになっていました。

直しました。結論的にいうと、gns3-gui は、Fedorarpm にして、gns3-server は、pip3 でインストールしました。

$ rpm -q gns3-gui

gns3-gui-2.1.0-0.rc3.fc27.noarch

---

$ pip3 list

...(snip)...

aiohttp (2.2.5)

...(snip)...

gns3-gui (2.1.0rc3)
gns3-net-converter (1.3.0)
gns3-server (2.1.0rc3)

...(snip)...

yarl (0.11.0)

 

$ gns3

しかしながら、、

-------------------------
今のところ、以下のバージョンしかうまくいかないみたいだ。
VirtualBox の、1.5.2 をダウンロードして、インポートする。
# pip3 install gns3-server==1.5.2
# pip3 install gns3-gui==1.5.2
# pip3 install aiohttp==1.1.6
# pip3 list
aiohttp (1.1.6)
gns3-gui (1.5.2)
gns3-net-converter (1.3.0)
gns3-server (1.5.2)
yarl (0.8.1)
デバッグ方法ー以下のコマンドで、立ち上がること。
$ gns3server
では、立ち上げてみる。
$ /usr/local/bin/gns3

お疲れさまです。何かあればお知らせください。

新人さんにポインタを教える

新人さん、said,

>int *x と *x の違いがよくわからない

Me said,

int* x の方が、理解しやすいと思います。
普通はあまりやらないみたいですけど。

実際に、プログラムを作って動かしてみると良いです。
例えば、以下のように。

1 #include <stdio.h>
2
3 int main() {
4 int* x;
5 int y;
6 int *y2;
7 int **z;
8 int ***z2;
9 y = 123;
10 y2 = &y;
11 x = y2;
12 z = &x;
13 z2 = &z;
14 printf ("%d\n",*x);
15 printf ("%d\n",y);
16 printf ("%d\n",*y2);
17 printf ("%d\n",**z);
18 printf ("%d\n",***z2);
19 return 0;
20 }

LVM のアーカイブファイル名の数字の限界は 5桁

以下のような実験で確かめました。

fdisk /dev/sdb
n
p
1
t
8e
w
mkfs.xfs /dev/sdb1
pvcreate /dev/sdb1
pvdisplay
vgcreate VgTest /dev/sdb1
vgdisplay
lvcreate -l 50%FREE -n LvTest VgTest
lvdisplay
vi /root/lv_test.sh
-------------
#!/bin/bash
while true
do
lvcreate -L 100M -n snap VgTest
sleep 1
lvremove -f /dev/VgTest/snap
done
-------------
chmod +x lv_test.sh

cd /etc/lvm/archive
ls -la
rm -f VgTest*
touch VgTest_99999-1234.vg

./lv_test.sh

ナンバリングが、インクリメントされることなく、以下のファイルが大量に作成されます。

VgTest_100000-<ランダムな数字>.vg

望ましい動作
100000 から、数字がインクリメントされていく。

何かあれば、お知らせください。

Fedora27 で Ruby 関連ソースパッケージをダウンロードする

お疲れさまです。

SHIRASAGI-hardening の RPM パッケージを作成してみた私ですが、あれ、Fedora なら、パッケージ色々とあるんじゃないか、とふと思いました。

ということで、以下のコマンドを実行しました。

$ cd

$ su

# dnf download --source ruby*

rubygems とかいっぱいダウンロードされました。

これは失敗した、どこかにディレクトリを作成してからやればよかった。

$ cd

$ mkdir RUBY

# chown me:me ruby*

# mv buby* RUBY

# ls lt | less

まだ先程ダウンロードしたファイルがあるようだ。me というホームディレクトリで、root でダウンロードしたので、時間的なことも考慮して移動させます。

# find ./ -type f -user root -maxdepth 1 -and -newermt '20171116' | xargs -I% mv % RUBY

できました。

# chown me:me RUBY -R

# exit

$ ls -l RUBY | wc -l

666

うわっ。

あるプロセスが使用しているメモリの正確な値を知る方法

お疲れさまです。あるプロセスが、どの程度メモリを使用しているかを知りたいという人がいると思います。

その回答となります。

例えば、 ps コマンドで以下のように出力してみます。
以下は、auditd のプロセスのみを取り出しました。

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
...(snip)...
root 885 0.0 0.0 56120 1936 ? S<sl 18:50 0:00 /sbin/auditd
...(snip)...

ここで、VSZ は、Virtual Set SiZe (仮想メモリのサイズ)
RSS は、Resident Set Size (物理メモリのサイズ)

と言われています。

これが、正確な値であるかどうかは、疑わしいです。
他の確認方法として、以下のコマンドを実行する方法があります。

# pmap -x <PID>

結構、いい感じですけど、
共有されているメモリなのか、自分だけに割り当てられているものなのかがわかりません。
そんなときに使えるのが、以下のコマンドです。

# cat /proc/<PID>/smaps

上記コマンドは、メモリをどの位使用しているかを正確に教えてくれます。
もっと重要なことには、メモリを private と shared に分割します。
したがって、いくつかのプログラムのインスタンスにより共有されているメモリを含めることなく、プログラムのインスタンスがどの程度メモリを使用しているかを、知ることができます。


(コマンド)
# pmap -x 885 | less
(結果の一部)
----------------------------
885: /sbin/auditd
Address Kbytes RSS Dirty Mode Mapping
0000560598052000 112 112 0 r-x-- auditd
0000560598052000 0 0 0 r-x-- auditd
000056059826e000 4 4 4 r---- auditd
000056059826e000 0 0 0 r---- auditd
000056059826f000 4 4 4 rw--- auditd
000056059826f000 0 0 0 rw--- auditd
0000560598270000 16 12 12 rw--- [ anon ]
...(snip)...
----------------------------
(コマンド)
# cat /proc/885/smaps | less
(結果の一部)
----------------------------
560598052000-56059806e000 r-xp 00000000 fd:00 3044478 /usr/sbin/auditd
Size: 112 kB
Rss: 112 kB
Pss: 112 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 112 kB
Private_Dirty: 0 kB
Referenced: 112 kB
Anonymous: 0 kB
LazyFree: 0 kB
AnonHugePages: 0 kB
ShmemPmdMapped: 0 kB
Shared_Hugetlb: 0 kB
Private_Hugetlb: 0 kB
Swap: 0 kB
SwapPss: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd ex mr mw me dw sd
56059826e000-56059826f000 r--p 0001c000 fd:00 3044478 /usr/sbin/auditd
Size: 4 kB
Rss: 4 kB
Pss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
...(snip)...

これなら、あるプロセスが使用しているメモリについて知りたいことが、全て明らかになりすね。

(参考)
https://stackoverflow.com/questions/131303/how-to-measure-actual-memory-usage-of-an-application-or-process

 

何かあれば、お知らせください。

Fedora27 アップグレード後に shell に落ちたときの対処法

標記の件、アップグレードシーケンス終了後の最初の起動時に、/etc/os-release がないと言われ、shell に落とされました。

 

幸い、既にアップグレードできていた Fedora27 が手元にあったので調べてみると、/etc/os-release は /usr/lib/os-release へのシンボリックリンクとなっていて、/usr/lib/os-release は、/usr/lib/os.release.d/os-release-fedora へのシンボリックリンクとなっていました。

 

起動に失敗した OS には、/usr/lib/os.release.d/os-release-fedora がなかったです。

 

/sysroot を rw でマウントして、上記ファイルを以下の内容で作成しました。

続きを読む

Fedora27 にアップグレードする

Fedora27 が出ました、ということで、早速アップグレードしました。

https://fedoraproject.org/wiki/DNF_system_upgrade

# dnf upgrade -y --refresh
# dnf install dnf-plugin-system-upgrade
# dnf system-upgrade download -y --refresh --releasever=27
# dnf system-upgrade reboot

ソフトウェア RAID 5 (ソフトウェア RAID)を MDADM で設定してみる

ソフトウェア RAID 5 (ソフトウェア RAID)を MDADM で設定してみる

今回は、RAID 5 について実験してみます。

というのも、私のノートパソコンなのですが、ご多分にもれず、壊れました。そこで、昔 RAID 5 システムを使っていたのですが、そのときは、ハードディスクに異常がでたら警報音(ピー、ピーという)がしてランプが点滅したので、ホットなままそのハードディスクを抜いて(引っ張り出す把手があるので)新しいハードディスクを挿す、ということをやっていたのを思い出したのです。

あれはいい気分はしませんでしたが、不思議とちゃんと直って問題なかったので、ああ、RAID 5 はいいな、と思い出した次第です。

さて、ネットにいい資料がありましたので、この記事を参考にして、私が昔、まさしく経験したことを再現してみます。
http://www.elinuxbook.com/how-to-configure-raid-5-in-linux-using-mdadm/

準備

RAID 5 は、( Redundant Array of Independent Disks )の略となります。Redundancy とは、もし何か障害があれば、その障害データを置き換えるバックアップデータがある、ということです。RAID は、1987 年に最初発明されました。RAID 5 の主な
目的は、データをミスするか失うことから守ることにあります。そして、読み込みスピードを増して、システムのパフォーマンスを向上させる事ができます。RAID は、データを守るために、ミラーリングパリティチェック、ストライピングという技術を利用します。
RAID には、たくさんのレベルがあり、それぞれのレベルには新しく発明された特徴があります。RAID レベルのタイプには、RAID 0,RAID 1, RAID 2, RAID 3, RAID 4, RAID 5, RAID 6 RAID 10 (RAID 0RAID 1 の組み合わせ)がありますが、最も利用され、有名な RAID レベルは以下となります。

RAID 0 – データのストライピング
RAID 1 – データのミラーリング
RAID 5パリティチェック付きストライピング
RAID 6 – ダブルパリティチェック付きストライピング
RAID 10ミラーリングとストライピング

ここでは、RHEL/CentOS 7 でどのように RAID 5 (ソフトウェア RAID) を設定するかについて確認して、ハードディスクに障害をおこして復旧させるということを、VirtualBox を使って実際にやってみます。

RAID 5 はどのように動作するのか ?

1010 1110 0110

HARDDISK1 HARDDISK2 HARDDSIK3
1 1 0
0 1 1
1 1 1
0 0 0

まずは、RAID 5 がどのように動作するかを理解します。RAID 5 は、データの安全化のためにストライピングとパリティチェック技術を使用しています。RAID 5 の実際のダイアグラムのスナップショットを上記に示しました。RAID 5 には、少なくとも 3つのハードディスクが必要です。ハードディスクにデータをコピーするときには、0 か 1 の数字のバイナリの形で保存します。したがって、1010 1110 0110 と上に示したようなデータを考えてみます。これらがハードディスクにコピーされたあとには、3つのハードディスク全てに分配されます。たとえば、上に示したように、1010 は ハードディスク1 に、1110 は ハードディスク2 に、0110 が ハードディスク3 に、コピーされます。データを複数のハードディスクに分配するのは、ストライピングと呼ばれています。データをコピーした後に、RAID 5 は、パリティビットを作成して、それぞれのハードディスクに保存します。RAID 5 は、パリティビットを計算するのに、XOR テーブル (Exclusive OR) を利用します。
以下の XOR テーブルを見てください。

XOR (Exclusive OR) Table :
A B Output
0 0 0
0 1 1
1 0 1
1 1 0

上記 XOR テーブルにしたがって、RAID 5 がどのようにパリティビットを計算するかについて見てみます。RAID 5 は、一度に 2つのハードディスクを取って、パリティビットを作成します。例えば、最初にハードディスク 1 と 2、次にハードディスク 2 と 3、最後に、ハードディスク 3 と 1 のように。
今回のシナリオでは、3つのハードディスクがあり、最初に例として、ハードディスク 1 とハードディスク 2 を考えてます。

注:RAID 5 は、パリティデータを全てのハードディスクに保存します。例えば、ハードディスク 1 と 2 のパリティを作成した後、ハードディスク1 とハードディスク2 の両方にパリティを保存します。そして、これは、ハードディスク2 とハードディスク3、ハードディスク3 とハードディスク1 も同様です。
今回は、ハードディスク 1 とハードディスク 2 は、以下のデータを保存しています :

Harddisk 1 Harddisk 2
1 1
0 1
1 1
0 0

パリティの計算方法:

ここで、 XOR テーブルを利用して、パリティチェックを計算してみます。
例 :

ハードディスク 1 の最初のビットは 1 であり、ハードディスク 2の最初のビットは 1であるので、 XOR テーブルは、A=1 B=1 Output=0
我々の最初のパリティビットは、0 となる。

ハードディスク 1 の2番目のビットは 0 であり、ハードディスク 2の2番目のビットは 1であるので、 XOR テーブルは、A=0 B=1 Output=1
我々の2番目のパリティビットは、1 となる。

ハードディスク 1 の3番目のビットは 1 であり、ハードディスク 2の3番目のビットは 1であるので、 XOR テーブルは、A=1 B=1 Output=0
我々の3番目のパリティビットは、0 となる。

ハードディスク 1 の4番目のビットは 0 であり、ハードディスク 2の4番目のビットは 0であるので、 XOR テーブルは、A=0 B=0 Output=0
我々の3番目のパリティビットは、0 となる。

Harddisk 1 Harddisk 2 Parity Check
1 1 0
0 1 1
1 1 0
0 0 0

したがって、ハードディスク 1 と 2 のパリティデータは、0 1 0 0 です。パリティデータを作成したのちに、ハードディスク1 と 2 の両方に、データを保存して、ハードディスクの障害に備えるのです。

FAID 5 は、上記のステップで、ハードディスク 2 と 3、ハードディスク 1 と 3 についてパリティピットを作成します。

最初のハードディスクである、ハードディスク 1 に障害が発生して、新しいハードディスクに交換したとしましょう。この場合、RAID 5 は、新しいハードディスクにどんな計算方法でデータをリカバするのでしょうか。

以下の方法をとります。

ハードディスク 2 には、それ自身だけでは、復旧できないのですが、RAID 5 は、パリティチェックデータを使用して、ハードディスク 1 のデータを復旧するのです。計算方法は以下となります。

ハードディスク 2 とパリティは、以下のデータを保存している :
Harddisk 2 Parity Check
1 0
1 1
1 0
0 0

したがって、ハードディスク 2 のデータとパリティから、 1 0 1 0 の結果を得るので、元のハードディスク 1 のデータを得るのです。
このように、例えばハードディスク 3 に障害が発生しても、同様のステップを経て、新しいハードディスクを交換してもデータを
復元できるのです。

RAID 5 の基本的な理解は以上となります。
では、以下の方法で、mdadm を使用して、RAID 5 (ソフトウェア RAID)を設定してみます。

前述の議論のとおり、 RAID 5 を設定するには、少なくとも 3 つの同じサイズのハードディスクが必要です。ここに、それぞれ 8GB のサイズのハードディスクを用意しました。つぎのアウトプットを見てください。

ーーーーーーーーーーーーーーー
Disk /dev/sda: 22.6 GB, 22630023168 bytes, 44199264 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 2508799 1G Microsoft basic
3 2508800 44197887 19.9G Linux LVM

Disk /dev/sdb: 3145.7 GB, 3145728000000 bytes, 6144000000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdc: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/cl-root: 3164.9 GB, 3164916940800 bytes, 6181478400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/cl-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
ーーーーーーーーーーーーーーーーー

さて、それぞれのハードディスクにパーティションを作成して、RAID 5 すなわち、fd にする必要があります。
以下のステップを実行します。

注:RAID 5 を設定するには、3つのパーティションを作成するか、3つのハードディスクを設定するかします。
今回は、3つのハードディスクを使用します。

/dev/sdc にパーティションを作成します。

========
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xd56ff420.

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-6291455, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215):
Using default value 16777215
Partition 1 of type Linux and of size 8 GiB is set

Command (m for help): t # To change the Partition ID
Selected partition 1
Hex code (type L to list all codes): fd # "fd" は、RAIDパーティションID です。
Changed type of partition 'Linux' to 'Linux raid autodet1ect'

Command (m for help): w # To save the Partition
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
ーーーーーーーーーーーーーーー

/dev/sdd、/dev/sde にも同様にパーティションを作成します(省略)。

さて、パーティションテーブルをシステムをリスタートせずに、partprobe コマンドを使用して保存してみます。以下のコマンドを実行する。

ーーーーーーーーーーーーーーーー
# partprobe /dev/sdc
# partprobe /dev/sdd
# partprobe /dev/sde
ーーーーーーーーーーーーーーーー

さて、RAID パーティションを作成した後のパーティションテーブル見てみます。

ーーーーーーーーーーーーーーーー
Disk /dev/sda: 22.6 GB, 22630023168 bytes, 44199264 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 2508799 1G Microsoft basic
3 2508800 44197887 19.9G Linux LVM

Disk /dev/sdb: 3145.7 GB, 3145728000000 bytes, 6144000000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdc: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x249194cd

Device Boot Start End Blocks Id System
/dev/sdc1 2048 16777215 8387584 fd Linux raid autodetect

Disk /dev/sdd: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x17f0171e

Device Boot Start End Blocks Id System
/dev/sdd1 2048 16777215 8387584 fd Linux raid autodetect

Disk /dev/sde: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x922fbad9

Device Boot Start End Blocks Id System
/dev/sde1 2048 16777215 8387584 fd Linux raid autodetect

Disk /dev/mapper/cl-root: 3164.9 GB, 3164916940800 bytes, 6181478400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/cl-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
ーーーーーーーーーーーーーーーーー

さて、RAID に必要なパーティションを作成したので、RAID 5 (ソフトウェア RAID)を設定していきます。
RAID 5 を設定するには、mdadm というパッケージが必要です。デフォルトでは、インストールされているはずですが、インストールされていなければ、以下のコマンドにより、インストールします。

# yum -y install mdadm

# rpm -q mdadm
mdadm-3.4-14.el7_3.1.x86_64

では、RAID 5 Array を作成します。

# mdadm -C /dev/md0 --level=raid5 --raid-devices=3 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: Defaulting to version 1.2 metadata
[ 1592.845647] md/raid:md0: raid level 5 active with 2 out of 3 devices, algorithm 2
mdadm: array /dev/md0 started.

上記コマンドのうち :

mdadm – RAID Arrey を作成するコマンド
-C – RAID を作成する
/dev/md0 – RAID ドライブのシンタックス
--level – RAID レベル, ここでは、RAID 5
--raid-devices – いくつハードディスクを使うか, ここでは、3つのハードディスクを使用する。

作成した RAID 5パーティションをチェックするには、以下のコマンドを使用します。

ーーーーーーーーーーーーーーー
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 16766976 (15.99 GiB 17.17 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Sun Jun 18 05:43:49 2017
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 18

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
3 8 65 2 active sync /dev/sde1
ーーーーーーーーーーーーーーーーーーーー

さて、RAID 5 パーティションを作成したので、ファイルシステムを作成してフォーマットしなければいけません。
したがって、RAID 5 のフォーマットは、以下のコマンドを使用します。

注:ここでは、xfs ファイルシステムを使用してフォーマットしています。もちろん、要求に応じて、他の異なるファイルシステムを使用してもよいです。

ーーーーーーーーーーーーーーーーーーー
# mkfs.xfs /dev/md0

meta-data=/dev/md0 isize=512 agcount=16, agsize=262016 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=4191744, imaxpct=25
= sunit=128 swidth=256 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=8 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
ーーーーーーーーーーーーーーーーーーー

さて、RAID ドライブをマウントするディレクトリを作成します。2つの方法でドライブをマウントできます。

1) 一時的なマウント 2) 永続的なマウント

一時的なマウントは、システムの再起動後に、自動的にアンマウントされ、次回ブート時にはマウントされないということである。
一時的なマウントをする場合には、以下のステップにしたがいます。

ーーーーーーーーーーーーーーーーーーー
# mkdir /data-md0
# mount /dev/md0 /data-md0
# ls -l /data/
total 0
ーーーーーーーーーーーーーーーーーーー

マウントされたデバイスをチェックするには、以下のコマンドを使用します。

ーーーーーーーーーーーーーーーーーーー
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 2.9T 1.7G 2.9T 1% /
devtmpfs 910M 0 910M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.4M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda2 1014M 175M 840M 18% /boot
/dev/sda1 200M 9.5M 191M 5% /boot/efi
tmpfs 184M 0 184M 0% /run/user/0
/dev/md0 16G 33M 16G 1% /data-md0
ーーーーーーーーーーーーーーーーーーー

2. 永続的なマウントは、システムを再起動してもパーティションがマウントされるように、/etc/fstab 設定ファイルにパーティションファイルシステムを記述します。

ーーーーーーーーーーーーーー
# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sun May 7 09:29:16 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=7ae3c25b-9467-4b3a-aaa0-8e6ee1eb9d61 /boot xfs defaults 0 0
UUID=A5BE-AA40 /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/cl-swap swap swap defaults 0 0

/dev/md0 /data-md0 xfs defaults 0 0
ーーーーーーーーーーーーーー

マウントテーブルをリフレッシュするために、以下のコマンドを実行します。

ーーーーーーーーーーーーーー
# mount -a
ーーーーーーーーーーーーーー

/etc/fstab により RAID 5 ドライブ をマウントしたのちに、マウントが適切にされたかを df -h コマンドを使用して、確認します。

ーーーーーーーーーーーーーー
# df -h | grep /dev/md0
/dev/md0 16G 33M 16G 1% /data-md0
ーーーーーーーーーーーーーー

では、今度はトラブルシュートをやってみます。
3つのハードディスクのうちの 1つに障害が発生したとします。データをどうやって復旧しましょうか。心配しなくても、いつもデータを復旧する方法はあります。
この Redundancy フィーチャーのおかげで RAID 技術がこんなにも有名になっているのです。世界中でこの技術は使われています。

これから、ハードディスクに障害が発生した時にデータを復旧させる方法を示します。以下のステップにしたがってください。
まずは、シナリオを作成して、以下のコマンドを使用してどれか一つのハードディスク、今回は /dev/sdd1 を実験的に障害をおこさせてみます。

ーーーーーーーーーーーーーーー
# mdadm /dev/md0 -f /dev/sde1 # ハードディスクに障害を発生させる
[ 3865.594531 ] md/raid:md0: Disk failure on sde1, disabling device.
[ 3865.594531 ] md/raid:md0: Operation continuing on 2 devices.
mdadm: set /dev/sde1 faulty in /dev/md0
ーーーーーーーーーーーーーーー

上記コマンドのうち :
f – ハードディスクに障害を発生させる

障害をおこしたハードディスクをチェックするには、以下のコマンドを使用します。
このように、/dev/sdd1 に障害が発生している事が確認できます。

ーーーーーーーーーーーーーーーーー
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 16766976 (15.99 GiB 17.17 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Sun Jun 18 06:21:00 2017
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 1
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 20

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
- 0 0 2 removed

3 8 65 - faulty /dev/sde1
ーーーーーーーーーーーーーーーーーー

次のステップは、システムからハードディスクを排除します。以下のコマンドを実行します。

========
[root@localhost ~]# mdadm /dev/md0 -r /dev/sde1 # 障害が発生したハードディスクを排除する
mdadm: hot removed /dev/sde1 from /dev/md0
========

上記コマンドのうち :
r – ハードディスクを取り除く

以下の出力で、障害をおこしたハードディスクがシステムから除外されたのが確認できます。
この状態では、新しいハードディスクに入れ替える必要があります。

ーーーーーーーーーーーーーー
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 16766976 (15.99 GiB 17.17 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 3
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Sun Jun 18 06:32:29 2017
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 21

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
- 0 0 2 removed
ーーーーーーーーーーーーーーーー

ということで、新しいハードディスク、/dev/sdf を接続しました。RAID の設定をします。以下のステップにしたがいます。

ーーーーーーーーーーーーーーーー
[root@localhost ~]# fdisk /dev/sdf
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-6291455, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215):
Using default value 16777215
Partition 1 of type Linux and of size 8 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
ーーーーーーーーーーーーーーーーーー

では、ハードディスク /dev/sdf1 RAID 5 ドライブ、すなわち、/dev/md0 に加えます。

ーーーーーーーーーーーーーーーーーー
[root@localhost ~]# mdadm /dev/md0 -a /dev/sdf1 # 新しいハードディスクを RAID ドライブに加える
mdadm: added /dev/sdf1
ーーーーーーーーーーーーーーーーーー

上記のコマンドのうち :
a – 新しいハードディスクを加える、という意味です。

状態を、以下のコマンドで確認します。
以下に出力されている用に、/dev/sdf1 が RAID ドライブに追加されました。

ーーーーーーーーーーーーーーーーーーーー
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 16766976 (15.99 GiB 17.17 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Sun Jun 18 06:42:56 2017
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 44

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
3 8 81 2 active sync /dev/sdf1
ーーーーーーーーーーーーーーーーー

以上で、RAID 5 (ソフトウェア RAID) を Linux 上で設定する方法を終わります。

大切なデータを冗長化技術を使って守るのは、システムの基本だと思います。せっかく利用できるものはどんどん利用してみましょう。
今回の実験を終了します。

次回をお楽しみに。

Linux で既存のソフトウェアRAID 5 の領域を増やす方法

Linux で既存のソフトウェアRAID 5 の領域を増やす方法

お疲れさまです。

Linux でソフトウェア RAID 5 を設定する方法について勉強したんですが。
今回は、既存のソフトウェア RAID 5 ストレージ容量を増やす方法を学びましょう。

さて問題は、なぜソフトウェア RAID 5 のストレージ容量を増やす必要があり、そのやり方はというところです。

さて、実際に前回ソフトウェア RAID 5 で作成しているストレージアレイの容量を増やすのはどうしたらいいのか、まずは、では、以下実際にやっていきましょう。

前回の設定で使用したマシンを使用します。
以下からわかる様に、RAID 5 パーティションサイズは 17.17 GB です。
RAIDバイスは、3 です。

As you can see below my RAID 5 Partition Size is 2.17 GB.
RAID devices are 3 (Highlighted in Red color).

========
# mdadm --detail /dev/md0 # RAID 5パーティションの詳細を確認します。

/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 16766976 (15.99 GiB 17.17 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Thu Jul 13 01:37:09 2017
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 44

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
3 8 81 2 active sync /dev/sdf1
================
RAIDバイスの詳細は、/proc/mdstat でも確認できます。
================
# cat /proc/mdstat # RAID 5バイスの詳細です

Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdc1[0] sdf1[3] sdd1[1]
16766976 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

unused devices: <none>
================
このシステムでは以下のように、RAID 5バイスは、/data-md0 ディレクトリにマウントされています。
================
# df -h # マウントデバイスをチェックします。

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 2.9T 1.7G 2.9T 1% /
devtmpfs 910M 0 910M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.4M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/md0 16G 33M 16G 1% /data-md0
/dev/sda2 1014M 174M 841M 18% /boot
/dev/sda1 200M 9.5M 191M 5% /boot/efi
tmpfs 184M 0 184M 0% /run/user/0
================
では、ソフトウェア RAID 5 のストレージ容量を、ハードディスクを追加することにより増やしてみましょう。
新しいハードディスクを、/dev/sdg として用意しました。
================
# fdisk -l | grep /dev/sdg
Disk /dev/sdg: 8589 MB, 8589934592 bytes, 16777216 sectors
================
では、/dev/sdg に新しいパーティションを作成し、パーティション ID を、RAID 5 、すなわち、fd にしていきます。
================
# fdisk /dev/sdg # Creating a New partition

n
p
Enter
Enter
t
fd
w
================
Linux システムにおいては、新しいパーティションを作成したら、システムを再起動してカーネルにおいてその情報をリフレッシュする必要がありますが、partprobe コマンドを使用することによりパーティションテーブルをカーネルにおいてリフレッシュできます。
================
# partprobe /dev/sdg # パーティションテーブルをリフレッシュする。
================
ということで、パーティション情報を確認すると、/dev/sdg1 は既存のソフトウェア RAID 5 パーティションに接続できる準備ができていることがわかります。
================
# fdisk -l | grep /dev/sdg
Disk /dev/sdg: 8589 MB, 8589934592 bytes, 16777216 sectors
/dev/sdg1 2048 16777215 8387584 fd Linux raid autodetect
================
新しいハードディスクを既存の RAID 5バイスに追加するには、以下のコマンドを実行します。
================
# mdadm --manage /dev/md0 --add /dev/sdg1 # 既存の RAID 5バイスに新しいハードディスクを追加する
mdadm: added /dev/sdg1

上記コマンドのうち:

/dev/md0 – 既存の RAID 5 パーティション
/dev/sdg1 – 新しく追加したパーティション
================
既存のソフトウェア RAID 5 パーティションに新しいハードディスクを追加しましたので、詳細について以下のコマンドにより確認します。
以下の表示のように、新しいハードディスク /dev/sdg1 が追加されました。
しかしながら、RAID 5バイスはまだスペアの状態です。容量は、まだ増えていません。
================
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 16766976 (15.99 GiB 17.17 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Thu Jul 13 02:45:54 2017
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 45

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
3 8 81 2 active sync /dev/sdf1

4 8 97 - spare /dev/sdg1
================
/proc/mdstat コマンドにより、RAID 5バイスの状態を簡単に確かめることができます。
================
# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdg1[4](S) sdf1[3] sdc1[0] sdd1[1]
16766976 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

unused devices: <none>

上記表示のうち :

S – Spare デバイス
================
では、以下のコマンドにより、RAID 5 パーティションサイズを増やしましょう。
================
# mdadm --grow /dev/md0 -n4 # RAID 5バイスストレージの容量を増やす
================
さて、デバイスの状態をチェックしましょう。

以下の表示からわかるように、RAID 5バイスの が、そのリサイズを新しく追加されたハードディスクを含み Reshape されています。
Reshape ステータスは、57 % です。
以下のコマンドを実行した結果により、RAID 5バイスが増えていることがわかります。
================
# mdadm --detail /dev/md0

/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 16766976 (15.99 GiB 17.17 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Thu Jul 13 02:58:07 2017
State : clean, reshaping
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Reshape Status : 57% complete
Delta Devices : 1, (3->4)

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 69

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
3 8 81 2 active sync /dev/sdf1
4 8 97 3 active sync /dev/sdg1
================
もう一度上記コマンドを実行すると、ソフトウェア RAID 5バイスは、25.75 GB に増加し、RAID 5バイスの数は、4 になりました。
================
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Jun 18 05:43:07 2017
Raid Level : raid5
Array Size : 25150464 (23.99 GiB 25.75 GB)
Used Dev Size : 8383488 (8.00 GiB 8.58 GB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Thu Jul 13 02:58:36 2017
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 09a7208f:869034d1:056672cf:238f70d1
Events : 73

Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
3 8 81 2 active sync /dev/sdf1
4 8 97 3 active sync /dev/sdg1
================
このシステムの RAID 5バイスは増加しましたが、df -h コマンドを実行してみると、元のサイズのままで増加してません。
これは、カーネルRAID 5バイスサイズが増加したことを、resize2fs コマンドにより通知する必要があります。
================
# df -h

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 2.9T 1.7G 2.9T 1% /
devtmpfs 910M 0 910M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.4M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda2 1014M 174M 841M 18% /boot
/dev/md0 16G 33M 16G 1% /data-md0
/dev/sda1 200M 9.5M 191M 5% /boot/efi
tmpfs 184M 0 184M 0% /run/user/0
================
したがって、次のコマンドを実行して、カーネルにリサイズした RAID 5バイスと、マウントポイントを通知しましょう。
================
# resize2fs /dev/md0
resize2fs 1.42.9 (28-Dec-2013)
Couldn't find valid filesystem superblock.

おっと、このシステムのファイルシステムが xfs だったのを忘れていました。
以下のコマンドでやり直します。

# xfs_growfs /dev/md0
meta-data=/dev/md0 isize=512 agcount=16, agsize=262016 blks
...(snip)...
data blocks changed from 4191744 to 6287616
================
上記プロセスののち、RAID 5 の容量がリサイズされます。以下の表示を見てください。
================
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 2.9T 1.7G 2.9T 1% /
devtmpfs 910M 0 910M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.4M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda2 1014M 174M 841M 18% /boot
/dev/md0 24G 33M 24G 1% /data-md0
/dev/sda1 200M 9.5M 191M 5% /boot/efi
tmpfs 184M 0 184M 0% /run/user/0
================
全ての設定を終えたら、/etc/mdadm.conf に設定を保存するのを忘れないようにしなければいけません。
以下のコマンドを実行します。
================
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
================
注意:RAID 設定を保存するのは必須です。設定を保存しないでシステムを再起動するとRAIDバイスを見つけられない可能性があります。

設定を保存したら、設定を以下のコマンドで確認します。
================
# cat /etc/mdadm.conf
ARRAY /dev/md/0 level=raid5 num-devices=4 metadata=1.2 name=localhost.localdomain:0 UUID=09a7208f:869034d1:056672cf:238f70d1
devices=/dev/sdc1,/dev/sdd1,/dev/sdf1,/dev/sdg1
================
お疲れさまです。今回の実験を終了します。

次回をお楽しみに。