-
nfs:network file system
-
-
-
RPC:远程过程调用
-
-
-
1.nfs安装
-
-
-
centos5.x中,portmap就是指centos6.x中的rpcbind
-
-
-
shell> yum install rpcbind nfs-utils
-
-
-
2.检查RPC的注册情况
-
-
-
rpcinfo -p [ip|hostname]
-
-
-
rpcinfo -t|-u ip|hostname 程序名称
-
-
-
-p:针对某个IP或者主机名显示出所有的端口和程序信息。
-
-
-
-t/-u:针对某主机的某个程序检查其tcp/udp数据包所在的软件版本。
-
-
-
[root@s01 samba]# /etc/init.d/rpcbind stop
-
-
-
[root@s01 samba]# /etc/init.d/rpcbind start
-
-
-
//检查nfs开启的端口
-
-
-
shell> netstat -ntulp|grep -E '(rpc|nfs)'
-
-
-
shell> netstat -ntulp|egrep '(rpc|nfs)'
-
-
-
3.配置文件语法
-
-
-
vim /etc/exports
-
-
-
共享目录 IP地址|IP地址段|主机名(权限)
-
-
-
/tmp 10.10.54.0/24(rw)
-
-
-
//查看服务器端共享的目录数据
-
-
-
[root@tech03 /]# showmount -e 10.10.54.226
-
-
-
案例1.nfs基本搭建
-
-
服务器端(54.226):
-
-
-
1.安装软件
-
-
-
yum install rpcbind.x86_64 nfs-utils.x86_64
-
-
-
2.配置配置文件
-
-
-
vim /etc/exports
-
-
-
3.重启服务
-
-
-
/etc/init.d/rpcbind restart
-
-
-
/etc/init.d/nfs restart
-
-
-
4.手工挂载
-
-
-
mount -t nfs 10.10.54.226:/tmp /mnt/tmp
-
-
-
案例2.创建映射用户
-
-
-
服务端
-
-
-
1.创建映射用户
-
-
-
[root@s01 /]# cat /etc/passwd|grep upload
-
-
-
upload:x:508:508::/home/upload:/bin/bash
-
-
-
mkdir /tech
-
-
-
chmod 757 /tech
-
-
-
2.配置配置文件
-
-
-
[root@s01 tech]# cat /etc/exports
-
-
-
/tmp 10.10.54.0/24(rw)
-
-
-
/home/upload 10.10.54.0/24(rw,async,all_squash,anonuid=508,anongid=508)
-
-
-
/tech 10.10.54.0/24(rw,all_squash)
-
-
-
3.重启nfs
-
-
-
-
-
客户端
-
-
-
1.客户端挂载在本地目录
-
-
mount -t nfs 10.10.54.226:/tmp/ /mnt/tmp/
-
-
-
mount -t nfs 10.10.54.226:/home/upload /mnt/upload/
-
-
-
mount -t nfs 10.10.54.226:/tech /mnt/tech/
-
-
2.挂载目录后,写入文件,查看文件权限
-
-
-
案例3.nfs固定端口配置
-
-
vim /etc/sysconfig/nfs
-
-
# TCP port rpc.lockd should listen on.
-
-
-
LOCKD_TCPPORT=32803
-
-
-
# UDP port rpc.lockd should listen on.
-
-
-
LOCKD_UDPPORT=32769
-
-
-
# Port rpc.mountd should listen on.
-
-
-
MOUNTD_PORT=892
-
-
-
# Port rquotad should listen on.
-
-
-
RQUOTAD_PORT=875
-
-
-
# Port rpc.statd should listen on.
-
-
-
STATD_PORT=662
-
-
共享/stu1目录,允许所有的客户端访问该目录,但只具有只读权限。
-
-
-
2.共享/stu2目录,允许10.10.54.0/24网段客户端访问,并且对该目录具有只读权限。
-
-
-
3.共享/stu3目录,10.10.54.0/24网段的客户端具有只读权限,并且将root用户映射成匿名用户。
-
-
-
4.共享/stu4目录,所有人具有读写权限,但当用户使用该共享目录的时候将帐号映射为匿名用户,指定匿名用户的uid/gid为600。
-
-
-
-
-
-
-
客户端
-
-
-
1.使用showmount命令查看nfs服务器发布的共享目录
-
-
-
2.挂载服务器端的/stu1目录到本地的/mnt/stu1目录
-
-
-
3.卸载/mnt/stu1目录
-
-
-
4.自动挂载nfs服务器上/stu4到本地的/mnt/stu4目录
-
-
-
-
-
-
-
//环境介绍
-
-
-
nfs服务器:10.10.54.150
-
-
-
测试机:10.10.54.154
-
-
-
-
-
-
-
//服务器设置
-
-
-
1.
-
-
-
shell> vim /etc/exports
-
-
-
/stu1 *(ro)
-
-
-
/stu2 10.10.54.0/24(ro)
-
-
-
/stu3 10.10.54.0/24(ro,root_squash)
-
-
-
/stu4 *(rw,anonuid=600,anongid=600)
-
-
-
-
-
-
-
2.重启服务
-
-
-
shell> /etc/init.d/rpcbind restart
-
-
-
shell> /etc/init.d/nfs restart
-
-
-
-
-
-
-
//客户机测试
-
-
-
1.使用showmount命令查看nfs服务器发布的共享目录
-
-
-
shell> showmount -e 10.10.54.150
-
-
-
Export list for 10.10.54.150:
-
-
-
/stu4 *
-
-
-
/stu1 *
-
-
-
/stu3 10.10.54.0/24
-
-
-
/stu2 10.10.54.0/24
-
-
-
-
-
-
-
2.挂载服务器端的/stu1目录到本地的/mnt/stu1目录
-
-
-
shell> mount -t nfs 10.10.54.150:/stu1 /mnt/sut1
-
-
-
-
-
-
-
3.卸载/mnt/stu1目录
-
-
-
shell> unmount /mnt/sut1
-
-
-
-
-
-
-
//自动挂载nfs服务器上/stu4到本地的/mnt/stu4目录
-
-
-
1.测试机上安装autonfs
-
-
-
shell> yum install autonfs
-
-
-
2.配置文件
-
-
-
shell> vim /etc/auto.master
-
-
-
/mnt /etc/auto.nfs
-
-
-
-
-
-
-
shell> vim /etc/auto.nfs
-
-
-
stu4 -rw,anonuid=600,anongid=600 10.10.54.150:/stu4
-
-
-
-
-
-
-
shell> /etc/init.d/autofs restart
-
-
-
3.测试自动挂载
-
-
-
shell> cd /mnt
-
-
-
-
-
-
-
shell> ls
-
-
-
#ls显示为空
-
-
-
-
-
-
-
shell> df -h
-
-
-
Filesystem Size Used Avail Use% Mounted on
-
-
-
/dev/sda2 6.0G 2.7G 3.0G 49% /
-
-
-
tmpfs 246M 0 246M 0% /dev/shm
-
-
-
/dev/sda1 194M 26M 159M 14% /boot
-
-
-
/dev/sda3 5.0G 1.9G 2.8G 41% /usr
-
-
-
#没有自动挂载信息
-
-
-
-
-
-
-
shell> cd stu4
-
-
-
#ls看不到stu4目录,但是可以切换进该目录,因为autonfs自动检测stu4目录
-
-
-
-
-
-
-
shell> df -h
-
-
-
Filesystem Size Used Avail Use% Mounted on
-
-
-
/dev/sda2 6.0G 2.7G 3.0G 49% /
-
-
-
tmpfs 246M 0 246M 0% /dev/shm
-
-
-
/dev/sda1 194M 26M 159M 14% /boot
-
-
-
/dev/sda3 5.0G 1.9G 2.8G 41% /usr
-
-
-
10.10.54.150:/stu4 37G 4.8G 31G 14% /mnt/stu4
-
-
-
-
-
-
-
#切换出stu4目录,过五分钟之后再查看
-
-
-
shell> cd /home
-
-
-
Filesystem Size Used Avail Use% Mounted on
-
-
-
/dev/sda2 6.0G 2.7G 3.0G 49% /
-
-
-
tmpfs 246M 0 246M 0% /dev/shm
-
-
-
/dev/sda1 194M 26M 159M 14% /boot
-
-
-
/dev/sda3 5.0G 1.9G 2.8G 41% /usr
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
阅读(559) | 评论(0) | 转发(0) |