0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

NFSサーバの設定方法 (AlmaLinux 9.4)

Last updated at Posted at 2024-07-29

はじめに

NFSとはLinuxなどで利用されるファイル共有システム。
NFSサーバでディレクトリを公開し、NFSクライアントからマウントすることで共有ディレクトリにアクセスすることができる。
今回、NFSサーバの設定を行ったので備忘録として記載する。

環境

AlmaLinux 9.4

手順

  • インストール
$ sudo dnf install -y rpcbind nfs-utils
  • 共有ディレクトリの作成
    • 今回は/share/nfsというディレクトリを共有ディレクトリとする。
    • ディレクトリのアクセス権限をchmodで変更する。0777と指定する場合、全てのユーザーにrwx全てのアクセス権限を許可する。
$ sudo mkdir /share
$ sudo mkdir /nfs
$ sudo chmod 0777 /share
$ sudo chmod 0777 /nfs
  • 共有ディレクトリのエクスポート設定
    • NFSの共有ディレクトリの設定について/etc/exportsに記述する。
      • まず、/share/nfsのように公開ディレクトリのパスを記述する。
      • スペースを空け、アクセスできるホストの範囲を記述する。*の場合、全ホストに公開する。
      • rw(読み書き可能)、rootアクセス可能(no_root_squash)、async(非同期書き込み有効)。
/etc/exports
/share/nfs *(rw,no_root_squash,async)
  • firewall設定
    • NFS通信を許可する。
$ sudo firewall-cmd --permanent --zone=public --add-service=nfs
$ sudo firewall-cmd --reload
$ sudo firewall-cmd --list-all
  • サービス起動設定
$ systemctl start rpcbind
$ systemctl start nfs-server
$ systemctl enable rpcbind
$ systemctl enable nfs-server
  • サービスの起動状態を確認したい場合
$ systemctl status rpcbind
$ systemctl status nfs-server
  • 共有ディレクトリ内に、共有したいファイルを格納
$ touch /share/nfs/hoge.txt

:warning:/etc/exportsを変更するなど設定を変更した場合、NFSサーバの再起動を行い設定変更を有効化させる。

$ systemctl restart rpcbind
$ systemctl restart nfs-server
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?