发布时间:2014-09-05 13:17:33作者:知识屋
[root@server ~]# yum install nfs* -y
[root@server ~]# /etc/init.d/nfs startStarting NFS services: [ OK ]Starting NFS mountd: [ OK ]Stopping RPC idmapd: [ OK ]Starting RPC idmapd: [ OK ]Starting NFS daemon: [ OK ][root@server ~]# chkconfig nfs on
[root@vpn client]# yum install nfs* -y
[root@vpn client]# /etc/init.d/nfs startStarting NFS services: [ OK ]Starting NFS quotas: [ OK ]Starting NFS mountd: [ OK ]Stopping RPC idmapd: [ OK ]Starting RPC idmapd: [ OK ]Starting NFS daemon: [ OK ][root@vpn client]# chkconfig nfs on
[root@server ~]# mkdir /home/ostechnix[root@server ~]# chmod 755 /home/ostechnix/
[root@server ~]# vi /etc/exports/home/ostechnix 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)其中, /home/ostechnix – 共享目录 192.168.1.0/24 – 客户端访问共享文件夹的IP地址范围 rw – 设定共享文件夹可写 sync – 创建新的文件/文件夹时同步共享目录 no_root_squash – 启用root权限(用户可以读取,写入和删除共享目录中的文件) no_all_squash – 允许用户权限 现在重新启动NFS服务。
[root@server ~]# /etc/init.d/nfs restartShutting down NFS daemon: [ OK ]Shutting down NFS mountd: [ OK ]Shutting down NFS services: [ OK ]Starting NFS services: [ OK ]Starting NFS mountd: [ OK ]Stopping RPC idmapd: [ OK ]Starting RPC idmapd: [ OK ]Starting NFS daemon: [ OK ] -
[root@vpn client]# mkdir -p /nfs/shared现在映射服务器上的共享目录,如下图所示
[root@vpn client]# mount -t nfs 192.168.1.200:/home/ostechnix/ /nfs/shared/这需要花一些时间,并显示连接超时的错误。好的,不要惊慌,防火墙可能会限制客户端从服务器挂载共享。简单地关闭iptables来纠正问题,也可以通过设定iptables允许NFS服务的端口。 要做到这一点打开/etc/sysconfig/nfs文件,并取消以黑体标出的部分的注释。
[root@server ~]# vi /etc/sysconfig/nfs## Define which protocol versions mountd # will advertise. The values are "no" or "yes"# with yes being the default#MOUNTD_NFS_V2="no"#MOUNTD_NFS_V3="no"### Path to remote quota server. See rquotad(8)#RQUOTAD="/usr/sbin/rpc.rquotad"# Port rquotad should listen on.RQUOTAD_PORT=875# Optinal options passed to rquotad#RPCRQUOTADOPTS=""### Optional arguments passed to in-kernel lockd#LOCKDARG=# TCP port rpc.lockd should listen on.LOCKD_TCPPORT=32803# UDP port rpc.lockd should listen on.LOCKD_UDPPORT=32769### Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)# Turn off v2 and v3 protocol support#RPCNFSDARGS="-N 2 -N 3"# Turn off v4 protocol support#RPCNFSDARGS="-N 4"# Number of nfs server processes to be started.# The default is 8. #RPCNFSDCOUNT=8# Stop the nfsd module from being pre-loaded#NFSD_MODULE="noload"# Set V4 grace period in seconds#NFSD_V4_GRACE=90#### Optional arguments passed to rpc.mountd. See rpc.mountd(8)#RPCMOUNTDOPTS=""# Port rpc.mountd should listen on.MOUNTD_PORT=892### Optional arguments passed to rpc.statd. See rpc.statd(8)#STATDARG=""# Port rpc.statd should listen on.STATD_PORT=662# Outgoing port statd should used. The default is port# is randomSTATD_OUTGOING_PORT=2020# Specify callout program #STATD_HA_CALLOUT="/usr/local/bin/foo"### Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)#RPCIDMAPDARGS=""## Set to turn on Secure NFS mounts. #SECURE_NFS="yes"# Optional arguments passed to rpc.gssd. See rpc.gssd(8)#RPCGSSDARGS=""# Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)#RPCSVCGSSDARGS=""## To enable RDMA support on the server by setting this to# the port the server should listen on#RDMA_PORT=20049现在重新启动NFS服务
[root@server ~]# /etc/init.d/nfs restartShutting down NFS daemon: [ OK ]Shutting down NFS mountd: [ OK ]Shutting down NFS services: [ OK ]Starting NFS services: [ OK ]Starting NFS mountd: [ OK ]Stopping RPC idmapd: [ OK ]Starting RPC idmapd: [ OK ]Starting NFS daemon: [ OK ]在‘/etc/sysconfig/iptables’ 文件中添加在以粗体显示的行。
[root@server ~]# vi /etc/sysconfig/iptables# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT-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 111 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT现在重新启动iptables服务。
[root@server ~]# service iptables restartiptables: Flushing firewall rules: [ OK ]iptables: Setting chains to policy ACCEPT: filter [ OK ]iptables: Unloading modules: [ OK ]iptables: Applying firewall rules: [ OK ]再次从客户端映射共享
[root@vpn client]# mount -t nfs 192.168.1.200:/home/ostechnix/ /nfs/shared/最后,NFS共享被映射,没有任何连接超时的错误。 为了验证共享目录是否被安装,请在客户端执行mount命令。
[root@vpn client]# mount/dev/mapper/vg_vpn-lv_root on / type ext4 (rw)proc on /proc type proc (rw)sysfs on /sys type sysfs (rw)devpts on /dev/pts type devpts (rw,gid=5,mode=620)tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")/dev/sda1 on /boot type ext4 (rw)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)nfsd on /proc/fs/nfsd type nfsd (rw)192.168.1.200:/home/ostechnix/ on /nfs/shared type nfs (rw,vers=4,addr=192.168.1.200,clientaddr=192.168.1.29)
[root@vpn shared]# mkdir test[root@vpn shared]# touch file1 file2 file3现在到服务器上,更换到“/home/ostechnix”目录。
[root@server ~]# cd /home/ostechnix/[root@server ostechnix]# lsfile1 file2 file3 test[root@server ostechnix]#现在列出由客户端创建的文件和目录。你也可以从服务器到客户端共享文件,反之亦然。
[root@vpn client]# vi /etc/fstab ## /etc/fstab# Created by anaconda on Wed Feb 27 15:35:14 2013## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#/dev/mapper/vg_vpn-lv_root / ext4 defaults 1 1UUID=59411b1a-d116-4e52-9382-51ff6e252cfb /boot ext4 defaults 1 2/dev/mapper/vg_vpn-lv_swap swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0192.168.1.200:/home/ostechnix/nfs/sharednfsrw,sync,hard,intr0 0
[root@vpn client]# mount/dev/mapper/vg_vpn-lv_root on / type ext4 (rw)proc on /proc type proc (rw)sysfs on /sys type sysfs (rw)devpts on /dev/pts type devpts (rw,gid=5,mode=620)tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")/dev/sda1 on /boot type ext4 (rw)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)192.168.1.200:/home/ostechnix on /nfs/shared type nfs (rw,sync,hard,intr,vers=4,addr=192.168.1.200,clientaddr=192.168.1.29)nfsd on /proc/fs/nfsd type nfsd (rw)这就是所有的了,祝你有美好的一天!
linux一键安装web环境全攻略 在linux系统中怎么一键安装web环境方法
Linux网络基本网络配置方法介绍 如何配置Linux系统的网络方法
Linux下DNS服务器搭建详解 Linux下搭建DNS服务器和配置文件
对Linux进行详细的性能监控的方法 Linux 系统性能监控命令详解
linux系统root密码忘了怎么办 linux忘记root密码后找回密码的方法
Linux基本命令有哪些 Linux系统常用操作命令有哪些
Linux必学的网络操作命令 linux网络操作相关命令汇总
linux系统从入侵到提权的详细过程 linux入侵提权服务器方法技巧
linux系统怎么用命令切换用户登录 Linux切换用户的命令是什么
在linux中添加普通新用户登录 如何在Linux中添加一个新的用户
2012-07-10
CentOS 6.3安装(详细图解教程)
Linux怎么查看网卡驱动?Linux下查看网卡的驱动程序
centos修改主机名命令
Ubuntu或UbuntuKyKin14.04Unity桌面风格与Gnome桌面风格的切换
FEDORA 17中设置TIGERVNC远程访问
StartOS 5.0相关介绍,新型的Linux系统!
解决vSphere Client登录linux版vCenter失败
LINUX最新提权 Exploits Linux Kernel <= 2.6.37
nginx在网站中的7层转发功能