CentOS 7.2-1511をセットアップしてソフトウェアRAID1を組んでSamba公開したい

CentOS 7.2

DVD ISOを入手し、GUIサーバーを選んだ。Everything ISOは2層DVDが必要らしい。

インストール
  1. 日本語を選ぶ
  2. ソフトウェアの選択
    • サーバー(GUI使用)
    • メールサーバー(ハードウェア異常報告をメール発信させたい)
    • FTPサーバー
    • ファイルストレージサーバー(Samba)
    • プリントサーバー(Sambaする上で付けておくと良いらしい)
    • ネットワークとホスト名(IPv4アドレスを自称させる。固定)
  3. sda を目いっぱい使うようにインストールする
  4. rootパスワード設定
  5. 一般ユーザーを作成。共用アカウントにするため、sudo 不可能とする
  6. インストールが終わったら再起動をクリック
  7. 再びDVDブートしてしまう。DVDを抜いて再起動
  8. CentOS ブート。ログインして日本語を選ぶ
初期設定
  1. 自動アップデートプロセスが現れたらアップデート
  2. 休み休み触るから、無操作でも画面ロックさせない

xrdpサーバー構築

Windowsからリモートデスクトップ接続したい。xrdp サーバーをさせる。

Red Hat 系の Linux ディストリビューションで xrdp & x11rdp を簡単にビルド&インストールするためのツールです。 簡単にいうと X11RDP-o-Matic の Red Hat 版です。

X11RDP-RH-Matic - 日本 xrdp ユーザ会

ビルドする上で、非rootかつsudoerが求められる。しかしインストール時にsudo 不可能としていた。

一時的にsudoer登録

一般ユーザーにパスワードなしでsudoコマンドを付与しました。環境はCentOSです。

CentOSの一般ユーザーにパスワードなしでsudoコマンドを使えるようにしました - Qiita

ぱっとみコメントアウトされているように見えますが、この # はコメントを意味するものではありません。#include や #includedir だけは行頭の # がコメントにはなりません。

sudoers は編集せずに sudoers.d の中に設定を書こう - Qiita
$ sudo echo "hogehoge"
$ su -
# echo "hoge ALL=(ALL) ALL" > /etc/sudoers.d/hogewheel.conf
# logout
$ sudo echo "hogehoge"

sudoer 非所属を確かめて、rootログインして、ユーザー「hoge」をsudoerに登録して、元の身分に戻って、sudo できているか確かめる。用事が済んだら、sudo rm /etc/sudoers.d/hogewheel する。

X11RDP-RH-Matic
sudo yum -y install git
git clone --depth 1 -b master https://github.com/metalefty/X11RDP-RH-Matic.git
cd X11RDP-RH-Matic
./X11RDP-RH-Matic.sh

shファイル実行(ビルド)に時間がかかる。この間にRAID1構築操作する。

RAID1構築

稼働中のシステムに HDD 2台を増設して RAID 1 を構成します。

CentOS 7 : RAID 1 を構成する : Server World

ここで操作するコンピューターは、システムドライブ(1台)+データ用RAID1(2台)、合計3台構成。

su -
parted --script /dev/sdb "mklabel gpt" 
parted --script /dev/sdc "mklabel gpt" 
parted --script /dev/sdb "mkpart primary 0% 100%" 
parted --script /dev/sdc "mkpart primary 0% 100%" 
parted --script /dev/sdb "set 1 raid on" 
parted --script /dev/sdc "set 1 raid on" 
mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1 
cat /proc/mdstat
    • create、RAID1同期が容量に比例した時間を要する。2GBのVDIは数秒だった。2TBは210分らしい。この間にxrdpサーバーを構築する。
#!/bin/bash
#
# Configuration file for /etc/cron.weekly/raid-check
#
# options:
#	ENABLED - must be yes in order for the raid check to proceed
#	CHECK - can be either check or repair depending on the type of
#		operation the user desires.  A check operation will scan
#		the drives looking for bad sectors and automatically
#		repairing only bad sectors.  If it finds good sectors that
#		contain bad data (meaning that the data in a sector does
#		not agree with what the data from another disk indicates
#		the data should be, for example the parity block + the other
#		data blocks would cause us to think that this data block
#		is incorrect), then it does nothing but increments the
#		counter in the file /sys/block/$dev/md/mismatch_count.
#		This allows the sysadmin to inspect the data in the sector
#		and the data that would be produced by rebuilding the
#		sector from redundant information and pick the correct
#		data to keep.  The repair option does the same thing, but
#		when it encounters a mismatch in the data, it automatically
#		updates the data to be consistent.  However, since we really
#		don't know whether it's the parity or the data block that's
#		correct (or which data block in the case of raid1), it's
#		luck of the draw whether or not the user gets the right
#		data instead of the bad data.  This option is the default
#		option for devices not listed in either CHECK_DEVS or
#		REPAIR_DEVS.
#	CHECK_DEVS - a space delimited list of devs that the user specifically
#		wants to run a check operation on.
#	REPAIR_DEVS - a space delimited list of devs that the user
#		specifically wants to run a repair on.
#	SKIP_DEVS - a space delimited list of devs that should be skipped
#	NICE - Change the raid check CPU and IO priority in order to make
#		the system more responsive during lengthy checks.  Valid
#		values are high, normal, low, idle.
#	MAXCONCURENT - Limit the number of devices to be checked at a time.
#		By default all devices will be checked at the same time.
#
# Note: the raid-check script intentionaly runs last in the cron.weekly
# sequence.  This is so we can wait for all the resync operations to complete
# and then check the mismatch_count on each array without unduly delaying
# other weekly cron jobs.  If any arrays have a non-0 mismatch_count after
# the check completes, we echo a warning to stdout which will then me emailed
# to the admin as long as mails from cron jobs have not been redirected to
# /dev/null.  We do not wait for repair operations to complete as the
# md stack will correct any mismatch_cnts automatically.
#
# Note2: you can not use symbolic names for the raid devices, such as you
# /dev/md/root.  The names used in this file must match the names seen in
# /proc/mdstat and in /sys/block.

ENABLED=yes
CHECK=check
NICE=low
# To check devs /dev/md0 and /dev/md3, use "md0 md3"
CHECK_DEVS="md0"
REPAIR_DEVS=""
SKIP_DEVS=""
MAXCONCURRENT=

物理4KBセクター

現在は自動的に対応するらしい。特別な操作はきっと不要だろう。

mkfs -t xfs -s size=4096 -f /dev/md1

トーク:CentOSでソフトウェアRAIDの構築 - maruko2 Note.

ということで xfsprogs 3.1.8 以降の mkfs.xfs ならなにもしなくとも最適な設定にしてくれるかもしれません (残念ながら次期リリースの Debian wheezy ではまだ 3.1.7 にとどまるようですが)。2012/12/26 17:52:00 JST

ほげめも: XFS セクタサイズチューニング