Centos5.8搭建NFS 服务器实例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos5.8搭建NFS 服务器实例相关的知识,希望对你有一定的参考价值。
Centos5.8搭建NFS 服务器实例:
服务器系统 | 角色 | IP |
CentOS-5.8-111-server1 | NFS服务器端 | 192.168.1.111 |
CentOS-5.8-119-client | NFS客户端 | 192.168.1.119 |
共享CentOS-5.8-111-server1中/data/bbs目录,使192.168.1.1 IP段所有主机都可以访问
配置服务端:
首先创建实验环境目录
[[email protected] ~]# mkdir /data/bbs –p [[email protected] bbs]# chown -Rnfsnobody.nfsnobody /data/bbs [[email protected] bbs]# ls -ld /data/bbs drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Jan19 17:08 /data/bbs
检查服务器系统信息
操本系统版本信息:
[[email protected] ~]# cat /etc/redhat-release CentOS release 5.8 (Final) [[email protected] ~]# uname -r 2.6.18-308.el5 [[email protected] ~]# uname -n 58server1 [[email protected] ~]# uname -a Linux 58server1 2.6.18-308.el5 #1 SMP TueFeb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux [[email protected] ~]# uname -m x86_64 [[email protected] ~]# ifconfig eth0 Link encap:Ethernet HWaddr00:0C:29:92:A2:4A inet addr:192.168.1.111 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1284 errors:0 dropped:0 overruns:0 frame:0 TX packets:109 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:81933 (80.0 KiB) TXbytes:12330 (12.0 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:100 (100.0 b) TXbytes:100 (100.0 b)
分别查看服务端的相关信息,如ip,主机名等等
检查NFS软件
[[email protected] ~]# rpm -aq |egrep"nfs-utils|portmap" nfs-utils-1.0.9-60.el5 portmap-4.0-65.2.2.1 nfs-utils-lib-1.0.8-7.9.el5
查看服务器的centos中5.8 portmap、6.4 rpcbind服务有没有启动和检查nfs、启动nfs
[[email protected] ~]# /etc/init.d/portmapstatus portmap is stopped [[email protected] ~]# /etc/init.d/nfs status rpc.mountd is stopped nfsd is stopped rpc.rquotad is stopped [[email protected] ~]# /etc/init.d/portmapstart Starting portmap: [ OK ] [[email protected] ~]# /etc/init.d/nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS daemon: [ OK ] Starting NFS mountd: [ OK ] Starting RPC idmapd: [ OK ] [[email protected] ~]# /etc/init.d/portmapstatus portmap (pid 25698) is running... [[email protected] ~]# /etc/init.d/nfsstatus rpc.mountd (pid 25766) is running... nfsd (pid 25763 25762 25761 25760 2575925758 25757 25756) is running... rpc.rquotad (pid 25729) is running...
配置portmap(Centos6.4下为rpcbind)及NFS服务开机自启动
[[email protected] ~]# echo "#NFS serverstart at dingjian to 2014.01.09">>/etc/rc.local [[email protected] ~]# echo"/etc/init.d/portmap start">>/etc/rc.local [[email protected] ~]# echo"/etc/init.d/nfs start">>/etc/rc.local [[email protected] ~]# tail -3 /etc/rc.local #NFS server start at dingjian to 2014.01.09 /etc/init.d/portmap start /etc/init.d/nfs start
配置NFS服务
[[email protected] ~]# echo "/data/bbs192.168.1.1/24(rw,sync)">>/etc/exports [[email protected] ~]# tail -1/etc/exports /data/bbs 192.168.1.1/24(rw,sync)
六、/etc/init.d/nfs reload 或exportfs -rv进行nfs重新加载
[[email protected] ~]# /etc/init.d/nfs reload [[email protected] ~]# exportfs -rv exporting 192.168.1.1/24:/data/bbs
r意思是重新挂载
v意思是显示过程
七、showmount -e localhost show一下自己,看服务端有没有配置好
[[email protected] bbs]# showmount -elocalhost Export list for localhost: /data/bbs 192.168.1.1/24
配置客户端:
检查系统环境
[[email protected] ~]# cat /etc/redhat-release CentOS release 5.8 (Final) [[email protected] ~]# uname -n 58client [[email protected] ~]# uname -r 2.6.18-308.el5 [[email protected] ~]# uname -a Linux 58client 2.6.18-308.el5 #1 SMP TueFeb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux [[email protected] ~]# uname -m x86_64
2.检查和启动portmap(6.4rpcbind)服务(注意无需启动NFS服务)
[[email protected] ~]# rpm -aq|grep portmap portmap-4.0-65.2.2.1 [[email protected] ~]# /etc/init.d/portmapstatus portmap is stopped [[email protected] ~]# /etc/init.d/portmapstart Starting portmap: [ OK ] [[email protected] ~]# /etc/init.d/portmapstatus portmap (pid 22949) is running...
3.把portmap加入开机自启动
[[email protected] ~]# echo "#NFS Clientstart at dingjian to 2014.01.19">>/etc/rc.local [[email protected] ~]# echo"/etc/init.d/portmap start">>/etc/rc.local [[email protected] ~]# tail -2 /etc/rc.local #NFS Client start at dingjian to 2014.01.19 /etc/init.d/portmap start
4扫描NFS服务器的文件共享例表
[[email protected] ~]# showmount -e 192.168.1.111 Export list for 192.168.1.111: /data/bbs 192.168.1.1/24
5.挂载NFS服务器共享目录到本地系统
[[email protected] ~]# mount -t nfs192.168.1.111:/data/bbs /mnt [[email protected] ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 17981340 2124648 14928540 13% / /dev/sda1 295561 16842 263459 7% /boot tmpfs 60136 0 60136 0% /dev/shm 192.168.1.111:/data/bbs 17981344 2117824 14935376 13% /mnt
6.配置开机自动挂载NFS共享目录
[[email protected] ~]# echo "mount -t nfs192.168.1.111:/data/bbs /mnt" >>/etc/rc.local [[email protected] ~]# tail -1 /etc/rc.local mount -t nfs 192.168.1.111/data/bbs /mnt
7.测试数据
[[email protected] ~]# cd /data/bbs [[email protected] bbs]# touch aa [[email protected] ~]# ls /mnt aa
提示:1.NFS服务端/var/lib/nfs/rmtab这个文件可以查看挂载的信息
/var/lib/nfs/xtab
2.配置NFS服务端后,不用重启NFS服务,只要使用exportfs -rv或/etc/init.d/nfs reload重新加载就可以了
3.rpc主程序Centos5.8下为portmap 、Centos6.4下为rpcbind
4.NFS共享目录不要授权于777权限,可以改所属主和组为nfsnobody,因为nfsnobody权限不是很大,也不能登陆
rpcinfo–p localhost 查看本机的rpcinfo对外提供哪些端口
本文出自 “Mr.Xiong`s 运维日志” 博客,请务必保留此出处http://mrxiong2017.blog.51cto.com/12559394/1932236
以上是关于Centos5.8搭建NFS 服务器实例的主要内容,如果未能解决你的问题,请参考以下文章