LoginSignup
0
1

More than 5 years have passed since last update.

NFSサーバのインストールと設定

Last updated at Posted at 2017-05-22

CentOS 7にNFSサーバをインストールし、設定してみる。

$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) 
$ df -h
$ pwd
/home/glire
$ mkdir foo
$ ls -l /home/glire/foo/
total 0
$ ls -l
total 0
drwxr-xr-x 2 glire glire 6 May 22 15:07 foo
$ ls -l /etc/exports
-rw-r--r--. 1 root root 0 Jun  7  2013 /etc/exports
$ sudo vi /etc/exports
$ ls -l /etc/exports
-rw-r--r-- 1 root root 53 May 22 15:10 /etc/exports
$ cat /etc/exports 
/home/glire/foo 192.168.119.0/24(rw,no_root_squash)
$ ps -ef | grep nfs
$ which service
/usr/sbin/service
$ sudo service nfs start
Redirecting to /bin/systemctl start  nfs.service
Failed to start nfs.service: Unit nfs.service failed to load: No such file or directory.
$ yum search nfs
$ sudo yum -y install nfs-utils
$ sudo service nfs start
Redirecting to /bin/systemctl start  nfs.service
$ ps -ef | grep nfs
root     11434     2  0 15:19 ?        00:00:00 [nfsd4]
root     11435     2  0 15:19 ?        00:00:00 [nfsd4_callbacks]
root     11449     2  0 15:19 ?        00:00:00 [nfsd]
root     11450     2  0 15:19 ?        00:00:00 [nfsd]
root     11451     2  0 15:19 ?        00:00:00 [nfsd]
root     11452     2  0 15:19 ?        00:00:00 [nfsd]
root     11453     2  0 15:19 ?        00:00:00 [nfsd]
root     11454     2  0 15:19 ?        00:00:00 [nfsd]
root     11455     2  0 15:19 ?        00:00:00 [nfsd]
root     11456     2  0 15:19 ?        00:00:00 [nfsd]
$ sudo getenforce
Disabled
$ sudo exportfs -rv
exporting 192.168.119.0/24:/home/glire/foo

NFSクライアントとなるホストでネットワークマウントし、試しに書き込んでみる。

$ sudo mkdir -p /net/bar
$ ls -ld /net/
drwxr-xr-x 3 root root 16 May 22 15:23 /net/
$ ls -ld /net/bar
drwxr-xr-x 2 root root 6 May 22 15:23 /net/bar
$ sudo mount -t nfs -o rw 192.168.119.28:/home/glire/foo /net/bar
$ df -h | grep bar
192.168.119.28:/home/glire/foo  9.4T  3.8T  5.6T  41% /net/bar
$ cp -pi /etc/hosts /net/bar/

NFSサーバ側のホストのファイルシステムで、問題なく書き込まれていることを確認。

$ ls -l /home/glire/foo/hosts
-rw-r--r-- 1 glire glire 778 Mar  8 23:01 /home/glire/foo/hosts
$ less /home/glire/foo/hosts
0
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
0
1