Chinaunix首页 | 论坛 | 博客
  • 博客访问: 38741
  • 博文数量: 17
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 120
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-31 12:31
文章分类

全部博文(17)

分类: 系统运维

2014-04-04 19:09:02


  1. nfs:network file system
  2. RPC:远程过程调用
  3. 1.nfs安装
  4. centos5.x中,portmap就是指centos6.x中的rpcbind
  5. shell> yum install rpcbind nfs-utils

  6. 2.检查RPC的注册情况
  7. rpcinfo -p [ip|hostname]
  8. rpcinfo -t|-u ip|hostname 程序名称
  9. -p:针对某个IP或者主机名显示出所有的端口和程序信息。
  10. -t/-u:针对某主机的某个程序检查其tcp/udp数据包所在的软件版本。
  11. [root@s01 samba]# /etc/init.d/rpcbind stop
  12. [root@s01 samba]# /etc/init.d/rpcbind start
  13. //检查nfs开启的端口
  14. shell> netstat -ntulp|grep -E '(rpc|nfs)'
  15. shell> netstat -ntulp|egrep '(rpc|nfs)'
  16. 3.配置文件语法

  17. vim /etc/exports
  18. 共享目录 IP地址|IP地址段|主机名(权限)
  19. /tmp 10.10.54.0/24(rw)
  20. //查看服务器端共享的目录数据
  21. [root@tech03 /]# showmount -e 10.10.54.226

  22. 案例1.nfs基本搭建
  23. 服务器端(54.226):
  24. 1.安装软件
  25. yum install rpcbind.x86_64 nfs-utils.x86_64
  26. 2.配置配置文件
  27. vim /etc/exports
  28. 3.重启服务
  29. /etc/init.d/rpcbind restart
  30. /etc/init.d/nfs restart
  31. 4.手工挂载
  32. mount -t nfs 10.10.54.226:/tmp /mnt/tmp
  33. 案例2.创建映射用户
  34. 服务端
  35. 1.创建映射用户
  36. [root@s01 /]# cat /etc/passwd|grep upload
  37. upload:x:508:508::/home/upload:/bin/bash
  38. mkdir /tech
  39. chmod 757 /tech
  40. 2.配置配置文件
  41. [root@s01 tech]# cat /etc/exports
  42. /tmp 10.10.54.0/24(rw)
  43. /home/upload 10.10.54.0/24(rw,async,all_squash,anonuid=508,anongid=508)
  44. /tech 10.10.54.0/24(rw,all_squash)

  45. 3.重启nfs


  46. 客户端

  47. 1.客户端挂载在本地目录

  48. mount -t nfs 10.10.54.226:/tmp/ /mnt/tmp/
  49. mount -t nfs 10.10.54.226:/home/upload /mnt/upload/
  50. mount -t nfs 10.10.54.226:/tech /mnt/tech/
  51. 2.挂载目录后,写入文件,查看文件权限
  52. 案例3.nfs固定端口配置
  53. vim /etc/sysconfig/nfs
  54. # TCP port rpc.lockd should listen on.
  55. LOCKD_TCPPORT=32803
  56. # UDP port rpc.lockd should listen on.
  57. LOCKD_UDPPORT=32769
  58. # Port rpc.mountd should listen on.
  59. MOUNTD_PORT=892
  60. # Port rquotad should listen on.
  61. RQUOTAD_PORT=875
  62. # Port rpc.statd should listen on.
  63. STATD_PORT=662

  64. 共享/stu1目录,允许所有的客户端访问该目录,但只具有只读权限。
  65. 2.共享/stu2目录,允许10.10.54.0/24网段客户端访问,并且对该目录具有只读权限。
  66. 3.共享/stu3目录,10.10.54.0/24网段的客户端具有只读权限,并且将root用户映射成匿名用户。
  67. 4.共享/stu4目录,所有人具有读写权限,但当用户使用该共享目录的时候将帐号映射为匿名用户,指定匿名用户的uid/gid为600。
  68. 客户端
  69. 1.使用showmount命令查看nfs服务器发布的共享目录
  70. 2.挂载服务器端的/stu1目录到本地的/mnt/stu1目录
  71. 3.卸载/mnt/stu1目录
  72. 4.自动挂载nfs服务器上/stu4到本地的/mnt/stu4目录
  73. //环境介绍
  74. nfs服务器:10.10.54.150
  75. 测试机:10.10.54.154
  76. //服务器设置
  77. 1.
  78. shell> vim /etc/exports
  79. /stu1 *(ro)
  80. /stu2 10.10.54.0/24(ro)
  81. /stu3 10.10.54.0/24(ro,root_squash)
  82. /stu4 *(rw,anonuid=600,anongid=600)
  83. 2.重启服务
  84. shell> /etc/init.d/rpcbind restart
  85. shell> /etc/init.d/nfs restart
  86. //客户机测试
  87. 1.使用showmount命令查看nfs服务器发布的共享目录
  88. shell> showmount -e 10.10.54.150
  89. Export list for 10.10.54.150:
  90. /stu4 *
  91. /stu1 *
  92. /stu3 10.10.54.0/24
  93. /stu2 10.10.54.0/24
  94. 2.挂载服务器端的/stu1目录到本地的/mnt/stu1目录
  95. shell> mount -t nfs 10.10.54.150:/stu1 /mnt/sut1
  96. 3.卸载/mnt/stu1目录
  97. shell> unmount /mnt/sut1
  98. //自动挂载nfs服务器上/stu4到本地的/mnt/stu4目录
  99. 1.测试机上安装autonfs
  100. shell> yum install autonfs
  101. 2.配置文件
  102. shell> vim /etc/auto.master
  103. /mnt /etc/auto.nfs
  104. shell> vim /etc/auto.nfs
  105. stu4 -rw,anonuid=600,anongid=600 10.10.54.150:/stu4
  106. shell> /etc/init.d/autofs restart
  107. 3.测试自动挂载
  108. shell> cd /mnt
  109. shell> ls
  110. #ls显示为空
  111. shell> df -h
  112. Filesystem Size Used Avail Use% Mounted on
  113. /dev/sda2 6.0G 2.7G 3.0G 49% /
  114. tmpfs 246M 0 246M 0% /dev/shm
  115. /dev/sda1 194M 26M 159M 14% /boot
  116. /dev/sda3 5.0G 1.9G 2.8G 41% /usr
  117. #没有自动挂载信息
  118. shell> cd stu4
  119. #ls看不到stu4目录,但是可以切换进该目录,因为autonfs自动检测stu4目录
  120. shell> df -h
  121. Filesystem Size Used Avail Use% Mounted on
  122. /dev/sda2 6.0G 2.7G 3.0G 49% /
  123. tmpfs 246M 0 246M 0% /dev/shm
  124. /dev/sda1 194M 26M 159M 14% /boot
  125. /dev/sda3 5.0G 1.9G 2.8G 41% /usr
  126. 10.10.54.150:/stu4 37G 4.8G 31G 14% /mnt/stu4
  127. #切换出stu4目录,过五分钟之后再查看
  128. shell> cd /home
  129. Filesystem Size Used Avail Use% Mounted on
  130. /dev/sda2 6.0G 2.7G 3.0G 49% /
  131. tmpfs 246M 0 246M 0% /dev/shm
  132. /dev/sda1 194M 26M 159M 14% /boot
  133. /dev/sda3 5.0G 1.9G 2.8G 41% /usr


阅读(549) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~