ssh登陆提示Too many authentication failures for wyq
判断端口通不通的几种方法

linux与linux之间共享目录

妙音 posted @ 2014年6月19日 22:46 in linux with tags mount;共享目录 , 5006 阅读

简述

在linux与windows之间共享目录使用smbfs. 但是在linux与linux之间共享目录要用nfs(Network File System网络文件系统). 服务端用nfs提供共享目录服务,客户端通过mount将共享目录挂载到本地.

以fedora 20设置共享目录为例

  • 安装nfs
fedora 20要安装以下两个包
[wyq@localhost ~]$ rpm -qa |grep nfs
libnfsidmap-0.25-8.fc20.x86_64
nfs-utils-1.3.0-2.1.fc20.x86_64
  • 配置共享目录
在/etc/exports文件中添加以下内容
/home/wyq/share  192.* (insecure,rw,sync,no_root_squash)
  • 设置防火墙,允许nfs服务
输入sudo firewall-config打开防火墙配置界面,选中nfs服务
  • 启动nfs服务
sudo service nfs start
  • 挂载目录
sudo mount -t nfs 127.0.0.1:/home/wyq/share /home/wyq/mount
  • 取消挂载
umount /home/wyq/mount
 
 
 
exports配置文件说明
/home/wyq/share 共享的目录
192.*           允许访问的主机IP, 如果不能确定 ,请使用 *(在fedora 20实验中表示任意IP时,不用加星号,否则nfs会无法启动) 
insecure        一个安全选项, 如果nfs服务端口号小于1024则可以不添加这个选项, 否则不添加的话, 是无法访问的.其他主机访问的话就会被拒绝.
rw              共享目录的权限,rw 是可读写的权限,只读的权限是ro.
sync            同步的选项, 可选的还有 async. sync是不使用缓存,随时写入同步, async是使用缓存的.
no_root_squash  NFS服务共享的目录的属性, 如果用户是root, 那么对这个目录就有root的权限.
 
启动nfs失败示例
  • 启动nfs时提示失败
[wyq@localhost workspace]$ sudo service nfs start
Redirecting to /bin/systemctl start  nfs.service
Job for nfs-server.service failed. See 'systemctl status nfs-server.service' and 'journalctl -xn' for details.
  • 根据提示查看错误信息
[wyq@localhost workspace]$ sudo systemctl status nfs-server.service
nfs-server.service - NFS Server
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled)
   Active: failed (Result: exit-code) since 四 2014-06-19 22:20:37 CST; 5s ago
  Process: 4984 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
  Process: 4980 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
  Process: 3778 ExecStartPost=/usr/libexec/nfs-utils/scripts/nfs-server.postconfig (code=exited, status=0/SUCCESS)
  Process: 3761 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT (code=exited, status=0/SUCCESS)
  Process: 5371 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
  Process: 5369 ExecStartPre=/usr/libexec/nfs-utils/scripts/nfs-server.preconfig (code=exited, status=0/SUCCESS)
 Main PID: 3761 (code=exited, status=0/SUCCESS)

6月 19 22:20:37 localhost.localdomain systemd[1]: Starting NFS Server...
6月 19 22:20:37 localhost.localdomain exportfs[5371]: exportfs: No options for /home/wyq/share *: suggest *(sync) to avoid warning
6月 19 22:20:37 localhost.localdomain exportfs[5371]: exportfs: No host name given with /home/wyq/share (insecure,rw,sync,no_root_squash), suggest *(insecure,rw,sync,no_root_squash) to avoid warning
6月 19 22:20:37 localhost.localdomain exportfs[5371]: exportfs: incompatible duplicated export entries:
6月 19 22:20:37 localhost.localdomain exportfs[5371]: exportfs:         *:/home/wyq/share (0x422) [IGNORED]
6月 19 22:20:37 localhost.localdomain exportfs[5371]: exportfs:         *:/home/wyq/share (0x425)
6月 19 22:20:37 localhost.localdomain systemd[1]: nfs-server.service: control process exited, code=exited status=1
6月 19 22:20:37 localhost.localdomain systemd[1]: Failed to start NFS Server.
6月 19 22:20:37 localhost.localdomain systemd[1]: Unit nfs-server.service entered failed state.
注意到信息中"exportfs: incompatible duplicated export entries:" 意思是有重复配置
  • 查看配置文件/etc/exports, 内容如下
/home/wyq/share  *  (insecure,rw,sync,no_root_squash)
  • 猜测是配置错误导致nfs无法启动
将配置更改为以下几种,逐一尝试
第一种
/home/wyq/share  192.*  (insecure,rw,sync,no_root_squash)
第二种
/home/wyq/share  (insecure,rw,sync,no_root_squash)
 
发现使用以上两种方式的配置,nfs均能正常启动并且被挂载.
  • 结论
在fedora 20的nfs配置文件/etc/exports中,如果想让任意主机访问共享目录,不需要用*表示,不填即表示任意主机.
 
 
Avatar_small
farhan 说:
2020年12月22日 19:23

I am hoping the same best effort from you in the future as well. In fact your creative writing skills has inspired me. buy palm kernel shell

Avatar_small
farhan 说:
2020年12月23日 13:58

Thumbs up guys your doing a really good job. agen asuransi

Avatar_small
farhan 说:
2020年12月23日 14:08

Thank you so much for ding the impressive job here, everyone will surely like your post. sekolah pilot

Avatar_small
farhan 说:
2020年12月23日 14:18

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing. jual beli bisnis

Avatar_small
farhan 说:
2020年12月30日 12:28

Thank you very much for sharing such a useful article. Will definitely saved and revisit your site 메이저놀이터

Avatar_small
farhan 说:
2021年1月04日 00:28

very interesting post.this is my first time visit here.i found so many interesting stuff in your blog especially its discussion..thanks for the post! 토토사이트

Avatar_small
farhan 说:
2021年1月04日 01:28

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. 안전놀이터

Avatar_small
farhan 说:
2021年1月05日 13:30

This is a fantastic website , thanks for sharing. 메이저놀이터

Avatar_small
farhan 说:
2021年1月05日 13:33

I’m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read !! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site. 토토사이트

Avatar_small
farhan 说:
2021年1月05日 13:36

I wish more writers of this sort of substance would take the time you did to explore and compose so well. I am exceptionally awed with your vision and knowledge. 안전놀이터

Avatar_small
Imamia Quran Academy 说:
2023年8月12日 06:56

Nice blog. I enjoyed reading your articles. This is truly a great read for me. I am from Imamia Quran Center. Imamia Quran Center connects students virtually from all over the world including countries with less or no Shia population or Shia Quran Centers. Online users will be provided with the authentic experience of a regular Shia Quran Center Online without being physically present in certain premises.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter