linux 查看nfs日志在哪

linux 查看nfs日志在哪,第1张

1 Linux下的NFS日志RedHat Linux 发行版NFS服务的日志记录在/var/log/messages文件中。下面我们用cat命令查看messages 文件,内容如下:# cat /var/log/messages |grep nfsDec 29 14:49:59 localhost nfs: rpc.mountdshutdown succeededDec 29 14:49:59 localhost kernel: nfsd: lastserver has exitedDec 29 14:49:59 localhost kernel: nfsd:unexporting all filesystemsDec 29 14:49:59 localhost nfs: nfsd -2succeededDec 29 14:49:59 localhost nfs: rpc.rquotadshutdown succeededDec 29 14:50:09 localhost nfslock: rpc.statdshutdown succeededDec 29 15:57:53 linux-1 nfslock: rpc.statd 启动 succeededDec 29 15:58:08 linux-1 nfs: 启动 NFS 服务:succeededDec 29 15:58:09 linux-1 nfs: rpc.rquotad 启动 succeeded从以上日志可以简单分析出服务启动时间和状态,但缺点是不能单独输出成独立的NFS服务日志,不便于阅读和查找错误。2 Solaris 下NFS服务器日志UNIX平台下NFS服务在虚拟化、中央存储系统、服务器集群中应用广泛,本节主要讲述Solaris平台下的NFS的日志。Solaris服务器平台配置好NFS服务后,如果不手动设置日志文件,那么日志记录方式与Linux相同,也是放在messages文件中,但Solaris下nfslogd daemon提供了非常详细的日志记录功能,启动该进程后会由NFS内核模块把NFS文件系统上的所有 *** 作都记录到一个缓存文件。记录内容包括时间戳、客户端IP地址、请求UID、访问文件和 *** 作类型等信息。Nfslogd进程的功能有如下四点: 从 *** 作记录中把原始数据转换成ASCII记录。 将IP解析成主机名。 将UID解析成登录名。 将文件句柄映射为路径名。所以Nfslogd进程在NFS服务器中必须启动,Solaris 系统中NFS服务的日志记录在配置文件/etc/nfs/nfslog.conf中定义。下面的例子使用默认值启动NFS日志后台进程#/usr/lib/nfs/nfslogd

安装NFS

[root@linuxprobe ~]# yum install nfs-utils

第1步:创建NFS服务端的共享目录。

清空iptables默认的规则链:

[root@linuxprobe ~]# iptables -F

保存清空后的iptables规则:

[root@linuxprobe ~]# service iptables save

创建nfsfile共享目录:

[root@linuxprobe ~]# mkdir /nfsfile

为共享目录设置权限(让其他人可以有写入权限):

[root@linuxprobe ~]# chmod -Rf 777 /nfsfile

写入一个文件,用于NFS客户端读取:

[root@linuxprobe ~]# echo "welcome to linuxprobe.com" >/nfsfile/readme

NFS服务端配置文件是"/etc/exports",用于定义要共享的目录以及相应权限。

[root@linuxprobe ~]# vim /etc/exports

//格式为:共享目录的绝对路径 允许访问NFS资源的客户端(权限参数)

/nfsfile 192.168.10.*(rw,sync,root_squash)

第2步:启动NFS服务端

刚刚讲到NFS服务是依赖于RPC服务的,但在红帽RHEL7系统中RPC服务已经默认运行(active)了,所以无需再配置RPC服务啦。

[root@linuxprobe ~]# systemctl status rpcbind

启动nfs-server程序:

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

设置NFS服务端为开机启动:

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

第3步:配置NFS客户端

如果NFS客户端也是红帽RHEL7系统,那么软件包nfs-utils一定也是已经默认安装,直接挂载共享就可以了。

查询远程NFS服务端中可用的共享资源:

[root@linuxprobe ~]# showmount -e 192.168.10.10

Export list for 192.168.10.10:

/nfsfile (everyone)

创建本地挂载目录:

[root@linuxprobe ~]# mkdir /nfsfile

[root@linuxprobe ~]# mount -t nfs 192.168.10.10:/nfsfile /nfsfile

顺利查看到刚刚写入文件内容:

[root@linuxprobe ~]# cat /nfsfile/readme

welcome to linuxprobe.com

如果希望开机后自动将NFS资源挂载到本地,那么就可以通过修改fstab文件来实现:

[root@linuxprobe ~]# vim /etc/fstab

192.168.10.10:/nfsfile /nfsfile nfs defaults 0 0

可以参考下http://www.linuxprobe.com/chapter-12.html#123_NFS,是讲怎么使用Samba或NFS去实现文件共享,希望对你有所帮助


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8359020.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-15
下一篇2023-04-15

发表评论

登录后才能评论

评论列表(0条)

    保存