加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

NFS配置

发布时间:2020-12-14 00:36:53 所属栏目:Linux 来源:网络整理
导读:由于权限问题,开发人员没有访问生产环境was相关日志权限,因此他们是通过生产环境nfs挂载至测试环境,开发人员能够访问的环境进行查询。 ? NFS 1 .配置NFS LOG挂载目录源端操作[[email?protected] yc1]# cat /etc/redhat- release Red Hat Enterprise Linux

由于权限问题,开发人员没有访问生产环境was相关日志权限,因此他们是通过生产环境nfs挂载至测试环境,开发人员能够访问的环境进行查询。

?

NFS

1.配置NFS LOG挂载目录
源端操作

[[email?protected] yc1]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.5 (Santiago)

[[email?protected] yc1]# cat /etc/exports 
/opt/tmp 10.8.5.158(rw,no_root_squash)
/opt/IBM/WebSphere/yc1/logs 10.8.4.102(rw,no_root_squash)
/opt/IBM/WebSphere/logs 10.8.4.102(ro)

编辑NFS文件配置
vi /etc/exports
/opt/IBM/WebSphere/yc1/logs/yc1 10.8.0.56(ro,no_root_squash)

重启nfs服务
[[email?protected] yc1]# /etc/init.d/rpcbind restart
[[email?protected] yc1]# /etc/init.d/nfs restart

服务器端nfs服务是否开机自启动进行验证
[[email?protected] yc1]# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
chkconfig --level 345 nfs on

服务器nfs开启自启动已配置

验证,之前restart 是否影响其他客户端nfs服务,再次重启nfs服务,可以发现已配置的客户端,还是能正常读取,识别文件


客户端操作
安装nfs安装包
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
[[email?protected] ~]# rpm -qa | grep nfs
nfs-utils-lib-1.0.8-7.6.el5
nfs-utils-1.0.9-42.el5
[[email?protected] ~]# rpm -qa | grep portmap
portmap-4.0-65.2.2.1

[[email?protected] ~]# service portmap restart
[[email?protected] ~]# service nfs restart

需要挂载目录,创建
# mkdir /logs/yc01
测试挂载
[[email?protected] ~]# showmount -e 10.8.5.157
Export list for 10.8.5.157:
/opt/IBM/WebSphere/yc1/logs/yc1 10.8.0.56

# mount -t nfs 10.8.5.157:/opt/IBM/WebSphere/yc1/logs/yc1 /logs/yc01
# df -h
10.8.5.157:/opt/IBM/WebSphere/yc1/logs/yc1
                       36G   11G   23G  32% /logs
                       
[[email?protected] logs]# tail -200f SystemOut.log

[[email?protected] logs]# umount /logs/yc01
umount: /logs/yc01: device is busy
umount: /logs/yc01: device is busy
# fuser -km /logs/yc01

# umount /logs/yc01

# vi /etc/rc.local 
mount -t nfs 10.8.5.157:/opt/IBM/WebSphere/yc1/logs/yc1 /logs/yc01

再次执行
[[email?protected] logs]# touch a.log
touch: cannot touch `a.log: Permission denied

无写权限 
[[email?protected] logs]# tail -1f SystemOut.log
[9/17/19 10:41:00:057 HKT] 0000007e Syst
有读权限





2.客户端,重启主机后,NFS未正常挂载

客户端
-bash-3.2# df -h
Filesystem            Size  Used Avail Use% Mounted on10.8.2.100:/opt/IBM/WebSphere/Emp2/logs/emp2
                       18G   14G  2.8G  84% /emp_log/emp2


-bash-3.2# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you dont
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
mount 10.8.2.100:/opt/IBM/HTTPServer/logs /hrlog
mount 10.8.4.148:/opt/nginx/logs /ekplog/
mount 10.8.4.10:/ytnfsa/accesslog /opt/accesslog
mount 10.8.2.100:/opt/IBM/WebSphere/Emp2/logs/emp2      /emp_log/emp2
mount 10.8.3.183:/opt/IBM/WebSphere/Emp1/logs/emp1      /emp_log/emp1


确实发现 /emp_log/emp1 文件夹丢失

手工MOUNT报错
-bash-3.2# mount 10.8.3.183:/opt/IBM/WebSphere/Emp1/logs/emp1      /emp_log/emp1
mount: mount to NFS server 10.8.3.183 failed: RPC Error: Program not registered.



登陆NFS服务端

[[email?protected] ~]# cat /etc/exports 
/opt/IBM/WebSphere/Emp1/logs/emp1 10.8.3.102(ro)

[[email?protected] emp1]# ping 10.8.3.102
PING 10.8.3.102 (10.8.3.102) 56(84) bytes of data.
64 bytes from 10.8.3.102: icmp_seq=1 ttl=64 time=0.436 ms

[[email?protected] emp1]# service portmap status
portmap (pid 3735) is running...
[[email?protected] emp1]# service nfs status
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
[[email?protected] emp1]#  service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

[[email?protected] emp1]# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
[[email?protected] emp1]# 
[[email?protected] emp1]# 
[[email?protected] emp1]# 
[[email?protected] emp1]# chkconfig --level 345 nfs on
[[email?protected] emp1]# chkconfig --list nfs        
nfs             0:off   1:off   2:off   3:on    4:on    5:on    6:off

客户端
-bash-3.2# mount 10.8.3.183:/opt/IBM/WebSphere/Emp1/logs/emp1      /emp_log/emp1

-bash-3.2# df -h
Filesystem            Size  Used Avail Use% Mounted on
10.8.3.183:/opt/IBM/WebSphere/Emp1/logs/emp1
                       21G   16G  3.5G  83% /emp_log/emp1

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读