プログラミングとかLinuxとかの備忘録

プログラミング、Linuxでハマった箇所や環境構築のメモ

CentOS7でNFSサーバを使う

スポンサーリンク

インストール

minimalインストールではすでにインストールされていた.

多分,以下のコマンドでインストールできる

$ sudo yum -y install nfs-utils

ファイアウォールの設定

$ sudo firewall-cmd --add-service=nfs --permanent
$ sudo firewall-cmd --add-service=rpc-bind --permanent

$ sudo firewall-cmd --reload
$ sudo firewall-cmd --list-service
dhcpv6-client nfs rpc-bind samba ssh

共有ディレクトリの設定

/etc/exportsの設定

$ sudo vi /etc/exports
/path/to/share 192.168.1.0/24(rw,async,no_root_squash)
オプション 内容
rw 読み書きを許可する
async 非同期書き込み
no_root_squash rootをanonymousにマッピングしない

サービス起動

$ sudo systemctl start rpcbind nfs-server
$ sudo systemctl enable rpcbind nfs-server

公開状態の確認

$ exportfs
/path/to/share 192.168.1.0/24

クライアントの設定

$ sudo yum -y install nfs-utils

/etc/fstabの編集

$ sudo vi /etc/fstab
SERVER:/path/to/share    /mnt/tmp            nfs defaults    0 0

References

  1. CentOS 7 : NFSサーバーの設定 : Server World
  2. ディレクトリをディレクトリにマウント