1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NFSでCentOS7サーバー間ファイル共有

Posted at

NFSでサーバー間ファイル共有

複数サーバーでのファイル共有は、以前書いた記事でlsyncdを紹介しましたが、今回はNFSというサーバー間ファイル共有について紹介していきたいと思います

NFSとは

NFSとはネットワークを介して、サーバに公開されたディレクトリをローカルにマウントし共有することができる技術です。

NFSを利用すると、複数のホストから同じファイルを共有することができるなどの利点があります。

前提条件

・NFSサーバとNFSクライアントの2台のCentOS7サーバー

NFSの実装

ここからNFSを実装するための手順について、紹介していきたいと思います。

NFSサーバー側の設定

パッケージインストール

yumで、nfsに必要なパッケージnfs-utilsをインストールし、/mnt下に共有するディレクトリを作成します。

# yum -y install nfs-utils
# mkdir /mnt/nfsserv/

共有確認のためテキストファイル作成
# cd /mnt/nfsserv/
# vi test.txt
test

権限設定と起動

/etc/exports下に、ファイルの権限の設定を記載します。

権限は、全員読み込み書き込み可能の設定にし、その後サービスの起動をします。

# vi /etc/exports
/mnt/nfsserv/ *(rw,async,no_root_squash)

# systemctl enable rpcbind
# systemctl start rpcbind
# systemctl enable nfs-server
# systemctl start nfs-server

NFSクライアント側の設定

パッケージインストール、共有ファイル作成、起動

NFSサーバー側同様、nfs-utilsをインストールして、共有ファイルを作成し、起動します。

# yum -y install nfs-utils
# mkdir /mnt/nfsclient/
# systemctl start rpcbind

マウント設定

/etc/fstabを編集して起動時のマウント設定をし、マウントします。

# vi /etc/fstab
NFSサーバーのIPアドレス:/mnt/nfsserv/ /mnt/nfsclient/ nfs defaults 0 0

# mount -v NFSサーバーのIPアドレス:/mnt/nfsserv/ /mnt/nfsclient/

マウント元であるNFSサーバーのtest.txtが/mnt/nfsclient/に共有されていたら、NFSのサーバー間共有設定は無事完了です。

参考URL

https://qiita.com/sugimount/items/1c1ab9b45b0d862a7dd6#nfs%E3%82%AF%E3%83%A9%E3%82%A4%E3%82%A2%E3%83%B3%E3%83%88%E3%81%AE%E8%A8%AD%E5%AE%9A
https://qiita.com/rikudai/items/f9900e4865ce25a8464e
https://www.designet.co.jp/faq/term/?id=TkZT
https://eng-entrance.com/linux-mount

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?