linux

Centos - nfs 설정

sysman 2020. 12. 27. 04:17

<nfs server>

[root@server1 ~]# dnf -y install nfs-utils*

[root@server1 ~]# systemctl status nfs-server

nfs-server.service - NFS server and services

   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)

   Active: inactive (dead)

[root@server1 ~]# systemctl enable nfs-server

Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.

[root@server1 ~]# systemctl start nfs-server

[root@server1 ~]# systemctl status nfs-server

nfs-server.service - NFS server and services

   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)

   Active: active (exited) since Sat 2020-12-26 13:50:22 EST; 10s ago

  Process: 28194 ExecStart=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=>

  Process: 28183 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)

  Process: 28181 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)

 Main PID: 28194 (code=exited, status=0/SUCCESS)

 

Dec 26 13:50:21 server1.example.com systemd[1]: Starting NFS server and services...

Dec 26 13:50:22 server1.example.com systemd[1]: Started NFS server and services.

[root@server1 ~]#

[root@server1 ~]# systemctl status rpcbind

rpcbind.service - RPC Bind

   Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)

   Active: active (running) since Sat 2020-12-26 13:50:21 EST; 21s ago

     Docs: man:rpcbind(8)

 Main PID: 28163 (rpcbind)

    Tasks: 1 (limit: 12241)

   Memory: 1.7M

   CGroup: /system.slice/rpcbind.service

           └─28163 /usr/bin/rpcbind -w -f

 

Dec 26 13:50:21 server1.example.com systemd[1]: Starting RPC Bind...

Dec 26 13:50:21 server1.example.com systemd[1]: Started RPC Bind.

[root@server1 ~]#

[root@server1 ~]#

[root@server1 ~]# systemctl start rpcbind

[root@server1 ~]# systemctl enable rpcbind

[root@server1 ~]#

[root@server1 ~]# cat /etc/exports

[root@server1 ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

 

192.168.10.200 server1.example.com

192.168.10.252 server2.example.com

[root@server1 ~]# vi /etc/exports

/temp 192.168.10.*(rw,sync)

[root@server1 ~]#

[root@server1 ~]#

[root@server1 ~]# export -r

-bash: export: -r: invalid option

export: usage: export [-fn] [name[=value] ...] or export -p

[root@server1 ~]# exports -r

-bash: exports: command not found

[root@server1 ~]# exportfs -r

exportfs: Failed to stat /temp: No such file or directory

exportfs: Failed to stat /temp: No such file or directory

[root@server1 ~]# mkdir /temp

[root@server1 ~]# exportfs -r

[root@server1 ~]# exportfs -v

/temp           192.168.10.*(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)

/temp           server*(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash) //nfs는 host의 dns 내용참조하기 때문에 없으면 client server에서 에러남 

[root@server1 ~]#

[root@server1 ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: ens33

  sources:

  services: cockpit dhcpv6-client ssh

  ports:

  protocols:

  masquerade: no

  forward-ports:

  source-ports:

  icmp-blocks:

  rich rules:

[root@server1 ~]# firewall-cmd --permanent --add-service=nfs

success

[root@server1 ~]# firewall-cmd --permanent --add-service=rpc-bind

success

[root@server1 ~]# firewall-cmd --permanent --add-service=mountd

success

[root@server1 ~]# firewall-cmd --reload

success

[root@server1 ~]# systemctl restart firewalld

[root@server1 ~]#

[root@server1 ~]#

 

 

<client server>

[root@server2 ~]# dnf -y install nfs-utils*

[root@server2 ~]# mkdir /tempclient

[root@server2 ~]# showmount -e 192.168.10.200

Export list for 192.168.10.200:

/temp server*,192.168.10.*

[root@server2 ~]#

[root@server2 ~]# mount -t nfs -v 192.168.10.200:/temp /tempclient

mount.nfs: timeout set for Sat Dec 26 14:10:47 2020

mount.nfs: trying text-based options 'vers=4.2,addr=192.168.10.200,clientaddr=192.168.10.252'

[root@server2 ~]#

[root@server2 ~]# df -Th

Filesystem           Type      Size  Used Avail Use% Mounted on

devtmpfs             devtmpfs  957M     0  957M   0% /dev

tmpfs                tmpfs     975M     0  975M   0% /dev/shm

tmpfs                tmpfs     975M  8.8M  967M   1% /run

tmpfs                tmpfs     975M     0  975M   0% /sys/fs/cgroup

/dev/sda6            xfs        39G  1.7G   38G   5% /

/dev/sda2            xfs        50G  610M   50G   2% /var

/dev/sda3            xfs       5.0G   68M  5.0G   2% /home

/dev/sda1            xfs       2.0G  176M  1.9G   9% /boot

tmpfs                tmpfs     195M     0  195M   0% /run/user/0

192.168.10.200:/temp nfs4       39G  1.7G   38G   5% /tempclient

[root@server2 ~]#

[root@server2 ~]# vi /etc/fstab
192.168.10.200:/temp                      /tempclient             nfs     defaults        0 0

[root@server2 ~]#
[root@server2 ~]# umount /tempclient
[root@server2 ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  957M     0  957M   0% /dev
tmpfs          tmpfs     975M     0  975M   0% /dev/shm
tmpfs          tmpfs     975M  8.8M  967M   1% /run
tmpfs          tmpfs     975M     0  975M   0% /sys/fs/cgroup
/dev/sda6      xfs        39G  1.7G   38G   5% /
/dev/sda2      xfs        50G  610M   50G   2% /var
/dev/sda3      xfs       5.0G   68M  5.0G   2% /home
/dev/sda1      xfs       2.0G  176M  1.9G   9% /boot
tmpfs          tmpfs     195M     0  195M   0% /run/user/0
[root@server2 ~]# mount -a
[root@server2 ~]# df -Th
Filesystem           Type      Size  Used Avail Use% Mounted on
devtmpfs             devtmpfs  957M     0  957M   0% /dev
tmpfs                tmpfs     975M     0  975M   0% /dev/shm
tmpfs                tmpfs     975M  8.8M  967M   1% /run
tmpfs                tmpfs     975M     0  975M   0% /sys/fs/cgroup
/dev/sda6            xfs        39G  1.7G   38G   5% /
/dev/sda2            xfs        50G  610M   50G   2% /var
/dev/sda3            xfs       5.0G   68M  5.0G   2% /home
/dev/sda1            xfs       2.0G  176M  1.9G   9% /boot
tmpfs                tmpfs     195M     0  195M   0% /run/user/0
192.168.10.200:/temp nfs4       39G  1.7G   38G   5% /tempclient
[root@server2 ~]#

'linux' 카테고리의 다른 글

Centos 8 - DB 설치  (0) 2020.12.27
Centos -samba  (0) 2020.12.27
centos linux -vsftpd 설정  (0) 2020.12.26
centos 8 - fuser  (0) 2020.12.21
centos 8 ntp (=chrony) 설정  (0) 2020.12.20