LoginSignup
0
0

More than 1 year has passed since last update.

/homeをNFSマウントするときの忘備録

Last updated at Posted at 2021-06-11

目的

よく忘れるので忘備録として記載しておきます。
HPCのテスト環境として作ることを想定しているため、下記をイメージしています。

  • マウント元(export側): Master Server の/home
  • マウント先(マウントポイント): Compute Node の/home

NFS server 設定

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

command
sudo yum update -y
sudo yum install nfs-utils -y

NFS公開ディレクトリーの設定

/etc/exportsの編集

変数は環境に応じて変更すること

command
EXPORT_DIR="/home"
PUBLIC_HOSTS="10.0.1.0/24"
OPTIONS="rw,no_root_squash,sync"
sudo sh -c "echo \"${EXPORT_DIR} ${PUBLIC_HOSTS}(${OPTIONS})\" >> /etc/exports"

このケースにおけるオプションは

  • 10.0.1.0/24 : 公開するIPレンジ
  • rw : 書き込み可能
  • no_root_squash : rootのアクセス可能にします。
  • sync: 以前の要求で発生した変更がディスクに書き込まれるまで、要求に応答しません
    • 非同期書き込みを有効にするには、async オプションを指定します。

/etc/exportsの記述内容の反映

command
sudo exportfs -ar

デーモンの有効化/起動/確認

command
sudo systemctl enable nfs-server
sudo systemctl start nfs-server
sudo systemctl status nfs-server

NFS公開ディレクトリーの確認

command
sudo showmount -e
Export list for ip-10-0-1-202.ap-northeast-1.compute.internal:
/home 10.0.1.0/24

NFSクライアントの設定

公開ディレクトリーへのマウント

SOURCE_DIRは環境に応じて書き換えること

command
SOURCE_DIR="10.0.1.202:/home"
DEST_DIR="/home"
sudo mount -t nfs ${SOURCE_DIR} ${DEST_DIR}

マウント確認

command
df -h ${DEST_DIR}
Filesystem        Size  Used Avail Use% Mounted on
10.0.1.202:/home   32G  3.5G   29G  11% /home

NFS公開ディレクトリの起動時自動マウント

自動マウント設定

command
sudo sh -c "echo \"${SOURCE_DIR} ${DEST_DIR} nfs rw 0 0\" >> /etc/fstab"
sudo tail -1 /etc/fstab

0 0については "fstabについて"を参照

SELINUXの無効化

sshログインができるように、SELINUXを無効化します。

command
sudo sed -i s/"SELINUX=enforcing"/"SELINUX=disabled"/g /etc/selinux/config

再起動

command
sudo reboot
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0