将同一块硬盘挂载到两台机器上

问:I want to mount the same disk to two linux machines and both machine must be able to read/write on the same disk at the same time.

答:You can do that through NFS. Mount the disk to a machine and share that drive through NFS to the other machine. 

Suppose the disk to be shared is /dev/sdb and the machines that you want to share the disk is machine1.example.com and machine2.example.com, then:

  1. Mount /dev/sdb in machine1 (You can skip this step if the said disk is already mounted and being used by machine1)

  2. Make the machine1 as the NFS server and export the directory on which /dev/sdb is mounted. Say, if /dev/sdb is mounted on /mnt/sharemount. The NFS export entries in /etc/exports should say:

    /mnt/sharemount machine2.example.com(rw,sync)

  3. Now that machine2 is allowed to use /mnt/sharemount from machine1 through NFS from step2, just mount /mnt/sharemount from machine1 on machine2

    mount machine1.example.com:/mnt/sharemount /mnt/sharemount

Data will not get corruped if these two machines start writing to the same location in /mnt/sharemount since the required locks will be applied and it will all happen transparent to you.

This answer is only an outline. If you are not familiar mounting a new disk to a server and with setting up NFS, please google how to configure nfs client and server linux. The search results will present you dozens of easy to follow tutorials and step-by-step guides. If you are comfortable using the command line(which I assume you are), you should be able to get the setup done with minimal time.

转载于:https://my.oschina.net/wuliong/blog/1573773

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值