2015年2月13日金曜日

CentOSにNFSを設定してみた。

■Rocky8 linux NFS 設定(追記:2023 12/14 )
【サーバ側】
# dnf install nfs-utils
# vi /etc/idmapd.conf
Domain = stage.world
# vi /etc/exports
/data/ 10.0.11.0/24(rw,sync,wdelay,root_squash,insecure)
/data/ 10.0.12.0/24(rw,sync,wdelay,root_squash,insecure)
/data/ 10.0.13.0/24(rw,sync,wdelay,root_squash,insecure)
/data/ 10.0.14.0/24(rw,sync,wdelay,root_squash,insecure)
※ all_squash 全てのユーザ権限を下げる。(root_squash, all_squash)
# exportfs -rav
# firewall-cmd --add-service=nfs
# firewall-cmd --add-service={nfs3,mountd,rpc-bind}
# firewall-cmd --runtime-to-permanent

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

【クライアント側】
# dnf install nfs-utils rpcbind
# showmount -e 10.0.18.201
# vi /etc/idmapd.conf
Domain = stage.world

# systemctl restart rpcbind
# systemctl enable rpcbind

※サーバ側の変更時も、クライアント側の再起動が必要
 
# vi /etc/fstab
192.168.210.101:/data/  /.data                  nfs     rw,hard            0 0
10.0.18.201:/data /.data                               nfs     rw,hard            0 0

cd /
mkdir /.data
ln -s /.data aws

※ mount できない場合、dmesgで確認。


-----------------------------------------------------------------------------------------------
# サーバ側の設定
# cat /etc/redhat-release
CentOS release 6.5(Final)

# yum -y install nfs-utils

# vi /etc/exports

/work/ 129.1.68.0/24(rw,sync,no_root_squash,no_all_squash)

# vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT

# service iptables restart

#service rpcbind restart
#service rpcidmapd restart
#service nfs restart
#service nfslock restart
#chkconfig rpcbind on
#chkconfig rpcidmapd on
#chkconfig nfs on

# service rpcbind status
# chkconfig --list
# service nfs status
# rpcinfo -p
# exportfs -ra
# exportfs -v
# showmount -e 129.1.68.188


#クライアント側の設定
# vi /etc/idmapd.conf
Domain = centos.casio.co.jp

# service rpcbind restart

# chkconfig rpcbind on

# vi /etc/fstab
192.1.68.188:/work /work nfs4 default 0 0

# chkconfig netfs on
or
# mount -t nfs -o rw 129.1.68.188:/work /work




シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service [Unit] Description= stop httpgwd DefaultDependencies=no Before=shutdown.target RefuseManualStart=true ...