MENU

溶けかけてるうさぎ HP GALLERY BLOG TOP RECENT ARTICLES POPULAR ARTICLES ABOUT THIS BLOG

CATEGORY

大学 (140) 仕事 (17) 航空宇宙 (104) 写真 (77) 旅行 (32) 飯・酒 (17) コンピュータ (118) その他 (44)

TAG

ARCHIVE

RECENT

【カメラ】X100 シリーズが好きすぎる(主にリーフシャッタ) 【カメラ】X100V から X100VI に買い替えました 【自宅サーバー】Google Domains から Cloudflare にドメインを移管 【カメラ】FUJIFILM XF レンズのサイズ比較ができるようにしてみた 【写真】自作写真閲覧ページにてフィルムシミュレーションで写真をフィルタできるようにした

【Ubuntu】Ubuntu ServerをRAID 1構成で構築する

事象発生日:2018-02-01

記事公開日:2018-02-03

アクセス数:70541

研究室に新しいサーバーを建てることになった.

堅牢につくりたかったので,RAID 1構成で構築した.

 

ハードウェアRAIDとソフトウェアRAIDあたりで手間取ったので,備忘録.

 

トップ画像の出典はこちら

1.環境

Ubuntu Server 16.04.3 LTS

Fujitsu PRIMERGY TX1310M1 3.5(E3-1225V3交換・メモリ16GB)

2TB HDD x 2

2.ハードウェアRAIDとソフトウェアRAID

RAID 1が組みたかったので,技術職員の方に「RAID 1が組めるPC買ってください.」とお願いし,PCが届いた.

 

まあ普通のCPUで,RAM 2GBでHDDは500GB x2 くらいで,とお願いしていたが,届いたのはXeon,RAM 16GB, HDD 2TB x2.

10万円超えなければ大学所有の資産にならないからなんでもいいらしいw

 

 

この富士通のハードウェアRAIDについてだが,どうやらCentOSには対応しているが,Debian系は動作未確認らしい.

動作未確認なだけならまあトライしても良かったが,RAIDのモニターユーティリティがRPMパッケージとして配布されていた.

おぉ,やっぱRed Hat系じゃないとだめか....

 

というわけで,Ubuntu標準搭載のソフトウェアRAIDで構築することにした.

3.インストールから起動まで

インストールディスクの作成

https://www.ubuntu.com/download/serverから最新のUbuntu Serverのインストールイメージをダウンロードする.

今回はサーバー用途なので,Desktop版ではなくUbuntu Serverである.

 

2018年2月1日現在,LTS版の最新版は16.04である.

あと数ヶ月すれば,18.04 LTSが出るんだけど....

Ubuntu Server サポート期間 [画像出典]

まあ,僕が修士で卒業するまでの間はサポート期間内だし,いいか.

 

さて,手軽にLive USBからインストールしようと思う.

ISOからLive USBを作るソフトとしてRufusを用いる.

 

Portableソフト原理主義者なので,ここでももちろんPortable版 (Ver.2.18) を使用した.

 

適当に設定.

なんか出てきたので,“はい”.

推奨されたので,“OK”.

“OK”.

書き込み中.

Live USB完成.

Ubuntu Serverのインストール

PCのハードウェア側のRAIDについて出てくるが無視.

ここからいつものUbuntu Serverインストール.

え,このPC,Ethernetポート2つあるのかよ....

今はまだネットにつながっていないので,なにもできない.

あれ? RAID選べないじゃん,って思ったが,まずパーティションテーブル作んないとね.

ようやくRAID設定.

スペアディスク,あったほうが良かったかな....(今更)

RAID 1になったので,パーティションを切る.

まあ,自動でいいよね.

インストール.

SSH (OpenSSH Server) はリモートログインに使うので必要.

これにてインストール終了.再起動.

不具合対応

まさかの初手で起動しないw

boot loaderの設定をみると,boot orderにHDDがない.

 

どうやらハードウェアRAIDと干渉しているっぽい.

 

boot loaderを漁ってると,SATA Configurationというものがあったので,ここでRAID設定を解除した.

 

すると起動するようになった.

4.MACアドレス取得

大学のLANに接続するにはMACアドレスを申請しないといけない.

MACアドレスは次のようなコマンドで確認できる.

このPCはEthernetポートが2つあるので,物理インターフェースも2つ表示されている.

${user}@${host}:~$ sudo ifconfig -a
enp0s25   Link encap:Ethernet  HWaddr ${MAC_address}
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:20 Memory:f7d00000-f7d20000

enp2s0    Link encap:Ethernet  HWaddr ${MAC_address}
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:f7c00000-f7c7ffff

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1792 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1792 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:133088 (133.0 KB)  TX bytes:133088 (133.0 KB)

${user}@${host}:~$ sudo ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ${MAC_address} brd ff:ff:ff:ff:ff:ff
3: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether ${MAC_address} brd ff:ff:ff:ff:ff:ff

5.ネットワーク設定

インターフェースの設定

MACアドレスの申請を終え,大学側のDHCPサーバーの設定が終わったようなので,こちら側のネットワークを行う.

 

最後の3行を追加した.

今回はIP固定などせず,普通にDHCPで.

大学側のDHCPサーバーがMACアドレスとの対応で毎回同じIPを振り割ってくれるのでこれで問題ない.

${user}@${host}:~$ sudo cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# Add on 2018.02.01
auto enp0s25
iface enp0s25 inet dhcp

不具合対応

再起動して,ネットワークに接続されたか確認するためにpingを打ってみたが,つながらない.

 

IPを確認すると,

&{user}@${host}:~$ sudo ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ${MAC_address} brd ff:ff:ff:ff:ff:ff
3: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether ${MAC_address} brd ff:ff:ff:ff:ff:ff
    inet6 ${IPv6}/64 scope link
       valid_lft forever preferred_lft forever

となっており,なぜかIPv6が振られている.

おかしいなぁ.こちらが申請したIPv4が振られているはずなんだけど....

 

とりあえず,以下のようにIPv6を無効に.

最後の2行を追加した.

${user}@${host}:~$ sudo cat /etc/sysctl.conf
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#

#kernel.domainname = example.com

# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3

##############################################################3
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
#  Enabling this option disables Stateless Address Autoconfiguration
#  based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1


###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#


# Add on 2018.02.01
net.ipv6.conf.all.disable_ipv6 = 1

これで再起動.

え,まだ繋がんないんだけど....

 

いろいろごにょごにょしてて,原因がわかりました.

 

えっと,Ethernetケーブルを差し込む情報コンセントを間違えてましたw

ちゃんと大学のVLANにつながる情報コンセントに挿しましょうwww

 

ちゃんと挿し直したら,つながりました.

&{user}@${host}:~$ sudo ifconfig -a
enp0s25   Link encap:Ethernet  HWaddr ${MAC_address}
          inet addr:${IPv4}  Bcast:${IPv4 24bit}.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:455826 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7118 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:113127333 (113.1 MB)  TX bytes:561017 (561.0 KB)
          Interrupt:20 Memory:f7d00000-f7d20000

enp2s0    Link encap:Ethernet  HWaddr ${MAC_address}
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:f7c00000-f7c7ffff

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

&{user}@${host}:~$ sudo ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ${MAC_address} brd ff:ff:ff:ff:ff:ff
3: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether ${MAC_address} brd ff:ff:ff:ff:ff:ff
    inet ${IPv4}/24 brd ${IPv4 24bit}.255 scope global enp0s25
       valid_lft forever preferred_lft forever</pre>

6.RAIDの確認

下のようなコマンドで確認してみた.

sda1sdb1md0としてRAID 1が組まれてそうなのことが確認できる.

 

というか,Partition 1 does not start on physical sector boundary.って無視してていいのかね....

${user}@${host}:~$ sudo df
Filesystem      1K-blocks    Used  Available Use% Mounted on
udev              8152928       0    8152928   0% /dev
tmpfs             1634620    8936    1625684   1% /run
/dev/md0p1     1906164492 1499880 1807814036   1% /
tmpfs             8173092       0    8173092   0% /dev/shm
tmpfs                5120       0       5120   0% /run/lock
tmpfs             8173092       0    8173092   0% /sys/fs/cgroup
tmpfs             1634620       0    1634620   0% /run/user/1000
${user}@${host}:~$ sudo fdisk -l
Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x3b38b698

Device     Boot Start        End    Sectors  Size Id Type
/dev/sda1        2048 3907028991 3907026944  1.8T fd Linux raid autodetect


Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf181cb0d

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb1  *     2048 3907028991 3907026944  1.8T fd Linux raid autodetect




Disk /dev/md0: 1.8 TiB, 2000263577600 bytes, 3906764800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x97e0d787

Device     Boot      Start        End    Sectors  Size Id Type
/dev/md0p1              63 3873367889 3873367827  1.8T 83 Linux
/dev/md0p2      3873367890 3906750959   33383070 15.9G  5 Extended
/dev/md0p5      3873367953 3906750959   33383007 15.9G 82 Linux swap / Solaris

Partition 1 does not start on physical sector boundary.
Partition 2 does not start on physical sector boundary.
Partition 5 does not start on physical sector boundary.
${user}@${host}:~$ sudo cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[1] sda1[0]
      1953382400 blocks super 1.2 [2/2] [UU]
      bitmap: 0/15 pages [0KB], 65536KB chunk

unused devices: <none>

7.今後

今後は,

SSH設定.リモートでいろいろいじくりたいしね.
シェル,というかbashに色を付ける.デフォルトは見にくいので.
コマンドログを残すための設定.
UFW(ファイアーウォール)の設定.
Subversionサーバーの構築
Subversionサーバーのデータ移行.

と進めていく.

8.参考サイト

Glamenv-Septzen.net. 技術 / Linux / Ubuntu 16.04 LTSのブートUSB作成例(2017-03時点). Retrieved February 1, 2018, from https://www.glamenv-septzen.net/view/1411
Qiita. ubuntu 14.04でのraid1作成、復旧手順(その1). Retrieved February 1, 2018, from https://qiita.com/miyumiyu/items/97120a49b78822932c9c
Linuxmania. RAIDボリュームからのブートとパーティション. Retrieved February 1, 2018, from https://www.linuxmania.jp/raid_md_grub.html

関連記事

コメントを投稿

名前

Email (※公開されることはありません)

コメント