NFS配置以及管理
NFS服务所需软件及主要配置文件:
安装NFS服务,需要安装两个软件,分别是:
• RPC主程序:rpcbind
NFS 其实可以被视为一个 RPC 服务,因为启动任何一个 RPC 服务之前,我们都需要做好 port 的对应 (mapping) 的工作才行,这个工作其实就是『 rpcbind 』这个服务所负责的!也就是说, 在启动任何一个 RPC 服务之前,我们都需要启动 rpcbind 才行! (在 CentOS 5.x 以前这个软件称为 portmap,在 CentOS 6.x 之后才称为 rpcbind 的!)。
• NFS主程序:nfs-utils
就是提供 rpc.nfsd 及 rpc.mountd 这两个 NFS daemons 与其他相关 documents 与说明文件、执行文件等的软件!这个就是 NFS 服务所需要的主要软件。
文章目录
NFS服务配置(windows->linux)
检查服务程序是否存在:
[root@localhost /]# rpm -q nfs-utils rpcbind
nfs-utils-1.3.0-0.el7.x86_64
rpcbind-0.2.0-23.el7.x86_64
[root@localhost /]# ^C
正确启动顺序应该是先启动rpcbind,再启动NFS:
[root@localhost /]# service rpcbind start
Redirecting to /bin/systemctl start rpcbind.service
[root@localhost /]# service nfs start
Redirecting to /bin/systemctl start nfs.service
[root@localhost /]#
查看nfs运行状态:
[root@localhost /]# service nfs status
Redirecting to /bin/systemctl status nfs.service
nfs-server.service - NFS Server
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled)
Active: active (exited) since 五 2020-09-18 09:49:36 CST; 45s ago
Process: 10692 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
Process: 10691 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
Process: 10704 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT (code=exited, status=0/SUCCESS)
Process: 10700 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Process: 10697 ExecStartPre=/usr/libexec/nfs-utils/scripts/nfs-server.preconfig (code=exited, status=0/SUCCESS)
Main PID: 10704 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
9月 18 09:49:36 localhost.localdomain systemd[1]: Starting NFS Server...
9月 18 09:49:36 localhost.localdomain systemd[1]: Started NFS Server.
设置开机自启以及防火墙放行:
[root@localhost init.d]# systemctl enable rpcbind
[root@localhost init.d]# systemctl start nfs-server nfs-secure-server
Job for nfs-secure-server.service failed. See 'systemctl status nfs-secure-server.service' and 'journalctl -xn' for details.
[root@localhost init.d]# systemctl enable nfs-server nfs-secure-server
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'
ln -s '/usr/lib/systemd/system/nfs-secure-server.service' '/etc/systemd/system/nfs.target.wants/nfs-secure-server.service'
[root@localhost init.d]# firewall-cmd --permanent --add-service=nfs
success
[root@localhost init.d]# firewall-cmd --reload
success
[root@localhost init.d]#
配置共享文件目录,编辑配置文件:
[root@localhost /]# mkdir /public
[root@localhost etc]# vi /etc/exports
/public 192.168.221.0/24(rw)
[root@localhost etc]# systemctl reload nfs
windows的NFS客户端配置:
windows2008x64上操作:【添加角色:文件服务器,勾选网络文件系统服务】才有mount命令!
(以上网络错误 – 53 为防火墙问题)
挂载命令:month \192.168.221.138\public x:
取消挂载命令:umount x:
关闭防火墙命令:systemctl stop firewalld
NFS目录赋权:chmod -R 777 /public
oracle创建nfs共享的逻辑目录:
SQL> create or replace directory dmp as '\\10.62.232.246\oradata\dmp';
目录已创建。
SQL> grant read,write on directory dmp to SYSTEM;
附:网络错误 - 122、- 5:
需要注意hosts.allow、hosts.deny文件限制情况:
1、为 /etc/hosts.allow文件添加"ALL: ALL"
2、为 /etc/hosts.deny文件注释行:“ALL:ALL”