GNU/Linux >> Linux の 問題 >  >> Cent OS

CentOS / RHEL 7 :NFS サーバーと NFS クライアントの構成

NFS により、Linux サーバーは、ネットワークを介して他の UNIX クライアントとディレクトリを共有できます。 NFS サーバー ディレクトリと NFS クライアントをエクスポートします このディレクトリをマウントします。 RHEL 7 は、NFSv3 と NFSv4 の 2 つのバージョンの NFS をサポートします。

NFS サーバーと RPC プロセス

nfs-server を起動しています process は、NFS サーバーと他の RPC プロセスを開始します。 RPC プロセスには以下が含まれます:
rpc.statd :NFS クライアントと NFS サーバー間の監視プロトコル (NSM) を実装します
rpc.mountd :NFSv3 クライアントからのマウント要求のサーバー側を実装する NFS マウント デーモン。
rpc.idmapd :NFSv4 名とローカル UID および GID をマップします
rpc.rquotad :リモート ユーザーのユーザー クォータ情報を提供します。

NFS サーバーの構成

1. サーバーにまだインストールされていない場合は、必要な nfs パッケージをインストールします:

# rpm -qa | grep nfs-utils
# yum install nfs-utils rpcbind

2. 起動時にサービスを有効にします:

#  systemctl enable nfs-server
#  systemctl enable rpcbind
#  systemctl enable nfs-lock

RHEL7.1 (nfs-utils-1.3.0-8.el7) では、nfs-lock を有効にしても機能しません (そのようなファイルやディレクトリはありません)。 rpc-statd.service は静的であるため、有効にする必要はありません。

#  systemctl enable nfs-idmap

RHEL7.1 (nfs-utils-1.3.0-8.el7) では、これは機能しません (そのようなファイルまたはディレクトリはありません)。 nfs-idmapd.service は静的であるため、有効にする必要はありません。

3. NFS サービスを開始します:

#  systemctl start rpcbind
#  systemctl start nfs-server
#  systemctl start nfs-lock
#  systemctl start nfs-idmap

4. NFS サービスのステータスを確認します:

# systemctl status nfs

5. 共有ディレクトリを作成します:

# mkdir /test

6. ディレクトリをエクスポートします。 /etc/exports ファイルの形式は次のとおりです:

dir client1 (options) [client2(options)...]

クライアント オプションには以下が含まれます (デフォルトが最初に表示されます):
ro / rw :
a) ro :クライアントに共有への読み取り専用アクセスを許可します。
b) rw :クライアントに共有への読み取り/書き込みアクセスを許可します。
sync / async :
a) sync :NFS サーバーは、前の要求によって行われた変更がディスクに書き込まれた後にのみ要求に応答します。
b) async :サーバーが待機する必要がないことを指定します。
wdelay / no_wdelay
a) wdelay :NFS サーバーは、別の書き込み要求が差し迫っていると思われる場合、書き込み要求のコミットを遅らせます。
b) no_wdelay :このオプションを使用して、遅延を無効にします。 no_wdelay オプションは、デフォルトの 同期 の場合にのみ有効にできます オプションが有効です。
no_all_squash / all_squash :
a) no_all_squash :リモート ユーザーのマッピングを変更しません。
b) all_squash :root を含むすべてのリモート ユーザーをスカッシュします。
root_squash / no_root_squash :
a) root_squash :リモートで接続している root ユーザーが root アクセスできないようにします。リモートの root 権限を効果的に押しつぶします。
b) no_root_squash :root の押しつぶしを無効にします。

例:

# vi /etc/exports
/test *(rw)

7. 共有のエクスポート:

# exportfs -r

-r は、/etc/exports のエントリを再エクスポートし、/var/lib/nfs/etab を /etc/exports と同期します。 /var/lib/nfs/etab はマスター エクスポート テーブルです。 exportfs コマンドで使用できるその他のオプションは次のとおりです:

-a : exports entries in /etc/exports but do not synchronize with /var/lib/nfs/etab
-i : ignore entries in /etc/exports and uses command line arguments.
-u : un-export one or more directories
-o : specify client options on command line

8. NFS サービスを再起動します。

# systemctl restart nfs-server

NFS クライアントの構成

1. サーバーにまだインストールされていない場合は、必要な nfs パッケージをインストールします:

# rpm -qa | grep nfs-utils
# yum install nfs-utils

2. mount コマンドを使用して、エクスポートされたファイル システムをマウントします。コマンドの構文:

 mount -t nfs -o options host:/remote/export /local/directory

例:

# mount -t nfs -o ro,nosuid remote_host:/home /remote_home

この例では次のことを行います。
– リモート ホスト (remote_host) から /home をローカル マウント ポイント /remote_home にマウントします。
– ファイル システムは読み取り専用でマウントされ、ユーザーは setuid プログラムを実行できません ( -o ro,nosuid オプション)

3. /etc/fstab を更新して、起動時に NFS 共有をマウントします。

# vi /etc/fstab
remote_host:/home 	/remote_home	 nfs 	ro,nosuid 	0 	0

NFS サーバーでアクティブにする Firewalld サービス

NFS サーバーを機能させるには、firewall-config アプリケーションの関連ゾーンで、または firewall-cmd を使用して、nfs、mountd、および rpc-bind サービスを有効にします。

# firewall-cmd --add-service=nfs --zone=internal --permanent
# firewall-cmd --add-service=mountd --zone=internal --permanent
# firewall-cmd --add-service=rpc-bind --zone=internal --permanent


Cent OS
  1. CentOS7.2でのNFSサーバーとクライアントのセットアップ

  2. CentOS7へのNFSサーバーとクライアントのインストール

  3. CentOS 7 / RHEL 7にFTPサーバーをインストールして構成する–(vsftpfd)

  1. CentOS6.3でのNFSサーバーとクライアントのセットアップ

  2. OpenSUSE12.2でのNFSサーバーとクライアントのセットアップ

  3. CentOS / RHEL 7 で NTP サーバーとクライアントを構成する方法

  1. RHEL 8 / CentOS8LinuxにHAProxyをインストールして構成する

  2. CentOS 7 /RHEL7でNFSサーバーをセットアップする方法

  3. CentOS/RHEL で NFS クライアントのキャッシュを無効にする方法