zoukankan      html  css  js  c++  java
  • CentOS 7 网络磁盘挂载到本地 并测试传输速度

    本文中的配置只做测试使用,正式环境中考虑到安全,请自行结合网上介绍的配置细节完善配置内容。

    首先明确两个概念,服务器客户端(本地),我们要做的是将服务端的硬盘上的/home/liuyx 目录挂载到本地的/liuyx下。

    1、在服务端和客户端分别安装NFS以及其rpc支撑

    yum install -y rpcbind nfs-utils

    2、服务端配置可映射目录

    vim /etc/exports

    打开是个空文件,在其中添加一行,并保存,内容如下

    /home/liuyx 123.123.123.*(rw,no_root_squash,sync)

    将服务端的/home/liuyx目录开放给后边这个ip,* 表示任意,后边的内容依次代表指定可读写、客户端拥有root权限,同步,具体配置本篇不做详解,请自行搜索。

    3、开放服务端以下端口

    tcp  111 2049 端口
    udp 111  4046 端口

    关于需要开放的端口分析过程(关键两个命令:netstat -an |grep 10.12.13.11tcpdump -i eht0 udp port 111 and dst host 10.12.13.11):
    http://blog.csdn.net/fhqsse220/article/details/45668057

    4、启动服务端NFS服务

    systemctl start rpcbind.service
    systemctl start nfs.service
    #设置开机启动
    systemctl enable rpcbind.service
    systemctl enable nfs.service

    ————————————————————————服务端完毕————————————————————————————

    5、客户端新建目录/liuyx

    mkdir /liuyx

    6、客户端挂载目录

    此处可以先用命令查询一下

    showmount -e 123.123.123.123

    查询如果失败,可能会报:clnt_create: RPC: Program not registered,解决方法可以参考:http://sxct168.blog.51cto.com/824373/1654069/

    不过这个失败并不影响我们使用,可以忽略。

    挂载命令:

    mount -t nfs 123.123.123.123:/home/liuyx /liuyx

    ————————————————挂载完毕————————————————————————————————————

    7、测试读写速度

    写入:

    time dd if=/dev/zero of=/liuyx/testdd.dbf bs=8k count=1000000 conv=fsync

    从一个空位置读数据,写到目标地址,每一块8M大小,写50次

    读出:

    time dd if=/liuyx/testdd.dbf  of=/dev/null bs=8k count=1000000 conv=fsync

    从一个位置读文件,输出到一个空位置,conv=fsync 表示执行完再刷到硬盘,不加会读到内存就输出结果了,并不执行sync

    从空位置读或者写,可以减少对测试的影响。

    注意:

    对于以上命令读取文件,默认的系统配置是会进行缓存,

    可以使用以下命令证实:

    free -m

    也就是说第一次读文件是从磁盘读到内存,第二次则直接去内存的缓存区拿文件,所以我们可以先把缓存策略设为不缓存

    cat  /proc/sys/vm/drop_caches
    echo 3 > /proc/sys/vm/drop_caches

    测试完成后记得再设回来,即上边cat命令显示的值

    echo 0 > /proc/sys/vm/drop_caches

      

    读也可以这样,需要用到hdparm这个软件,并且只支持本地,就本地测试来说,相对比较省事,不用频繁的去清理缓存:

    hdparm -t /dev/sda

    8、开机自动挂载

    #2017年11月22日 追加:经过试验(CentOS6.4和CentOS7) 以下这段用不到,只需修改fstab文件即可
    #vim /etc/rc.local #mount -t nfs -o nolock 123.123.123.123:/home/liuyx /liuyx vim /etc/fstab 123.123.123.123:/home/liuyx /liuyx nfs defaults 0 0

    9、取消挂载

    测试完了,我们还原线程,除了删掉测试文件、配置改回去,重启相关服务外,剩下的就是取消挂载,因为可能会遇到问题,这里单独说一下

    取消挂载可能遇到其他用户正在使用该挂载目录的情况:

    #umount /testspeed
    umount: /testspeed: device is busy.
            (In some cases useful info about processes that use
             the device is found by lsof(8) or fuser(1))

    以下转自(http://blog.csdn.net/intel80586/article/details/7682522):

    看看有哪些用户在用
    [root@localhost /]#fuser -cu /testspeed
    /testspeed:                15060x(root)
    其次向进程发出SIGKILL信号
    [root@localhost /]# fuser -ck /mnt
    /mnt:                15060x
    确认
    [root@localhost /]# fuser -c /mnt

    附一个自己写的shell脚本:

    取消挂载、挂载远程、设置开机挂载、清空被挂载盘、复制一个远程位置到挂载目录。

    链接:http://pan.baidu.com/s/1c2EpvS8 密码:ta8w

  • 相关阅读:
    Policy Iterations for Reinforcement Learning Problems in Continuous Time and Space—Fundamental Theory and Methods
    (元)强化学习开源代码调研
    Model Based Reinforcement Learning for Atari
    A Brain-Inspired Decision Making Model Based on Top-Down Biasing of Prefrontal Cortex to Basal Ganglia and Its Application in Autonomous UAV Explorations
    A Spiking Neural Network Model of Model- Free Reinforcement Learning with High- Dimensional Sensory Input and Perceptual Ambiguity
    Strategy and Benchmark for Converting Deep Q-Networks to Event-Driven Spiking Neural Networks
    SLAYER: Spike Layer Error Reassignment in Time
    BindsNET: A Machine Learning-Oriented Spiking Neural Networks Library in Python
    Fine-Tuning and the Stability of Recurrent Neural Networks
    Q-learning and Pontryagin's Minimum Principle
  • 原文地址:https://www.cnblogs.com/flying607/p/7845146.html
Copyright © 2011-2022 走看看