Linux客户端挂载文件系统
<p> </p>
<p><a id="方法一:手动挂载" name="方法一:手动挂载"><span style="font-size:16px"><strong>方法一:手动挂载</strong></span></a></p>
<p><span style="font-size:16px"><strong>操作步骤</strong></span></p>
<p>1. 使用SSH等工具进入Linux客户端的命令行模式。</p>
<p>2. 检测及安装NFS客户端软件包。</p>
<ul>
<li>检测是否已经安装NFS客户端软件包:</li>
</ul>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># rpm -qa | egrep "nfs|rpcbind" </td>
</tr>
</tbody>
</table>
<ul>
<li>安装所需的客户端NFS软件包:</li>
</ul>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># yum install -y nfs-utils rpcbind</td>
</tr>
</tbody>
</table>
<p>3. 增加挂载目录,执行如下命令:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> # mkdir /tmp/test </span></td>
</tr>
</tbody>
</table>
<p>4. 执行挂载命令,本例中服务器IP为:10.10.10.10,共享目录为:/tmp/servertest:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> # mount -t nfs 10.10.10.10:/tmp/servertest /tmp/test -o rw,soft,intr,rsize=32768,wsize=32768,tcp,timeo=300<span style="font-family:Consolas"> </span></td>
</tr>
</tbody>
</table>
<p>5. 进入目录验证,并创建新的文件,执行命令如下:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> # cd /tmp/test
<p> # touch /tmp/test/test.txt<span style="font-family:Consolas"> </span></p>
</td>
</tr>
</tbody>
</table>
<p> </p>
<p> </p>
<p><a name="方法二:自动挂载"><span style="font-size:16px"><strong>方法二:自动挂载</strong></span></a></p>
<p><a name="CentOS6.X 客户端配置自动挂载"><span style="font-size:16px"><strong>CentOS6.X 客户端配置自动挂载</strong></span></a></p>
<p>对CentOS6.X客户端,设置cloud NAS卷自动挂载,本例中客户端挂载目录为/efsclient/test,服务器的IP为10.10.10.10,服务器卷的路径为/tmp/servertest,进入客户端的命令行。</p>
<p><span style="font-size:16px"><strong>操作步骤</strong></span></p>
<p>1. 以root用户登录系统;如果当前用户不是root用户:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> # sudo su<span style="font-family:Consolas"> </span></td>
</tr>
</tbody>
</table>
<p>然后输入当前用户的密码。</p>
<p>2. 安装autofs软件包:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># yum -y install autofs</td>
</tr>
</tbody>
</table>
<p>3. 查看是否配置过automount:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cat /etc/auto.nfsc</td>
</tr>
</tbody>
</table>
<p>查看主机是否已经挂载过其他cloud NAS卷,如果没有配置过,需要执行以下步骤,如果已经配置过,只需执行8~9步即可:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># df -t nfs -Ph</td>
</tr>
</tbody>
</table>
<p>4. 查看/etc/sysctl.conf:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cat /etc/sysctl.conf</td>
</tr>
</tbody>
</table>
<p>如无以下配置,需要执行如下命令,先备份sysctl.conf</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cp -p /etc/sysctl.conf /etc/sysctl.conf.`date +%F_%T`</td>
</tr>
</tbody>
</table>
<p>写入配置:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># echo "net.core.rmem_default = 2621440" » /etc/sysctl.conf
<p> # echo "net.core.wmem_default = 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.core.rmem_max = 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.core.wmem_max = 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.ipv4.tcp_rmem = 4096 655360 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.ipv4.tcp_wmem = 4096 655360 2621440" » /etc/sysctl.conf</p>
</td>
</tr>
</tbody>
</table>
<p>使配置立即生效:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># sysctl -p</td>
</tr>
</tbody>
</table>
<p>5. 检查portmap(rpcbind)和nfslock服务并配置</p>
<p> 启动rpcbind服务:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># service rpcbind start</td>
</tr>
</tbody>
</table>
<p> 查看rpcbind服务:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> # service rpcbind status</td>
</tr>
</tbody>
</table>
<p> 设置rpcbind服务开机自启动:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># chkconfig rpcbind on</td>
</tr>
</tbody>
</table>
<p> 列出rpcbind服务信息:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># chkconfig --list rpcbind</td>
</tr>
</tbody>
</table>
<p>6. 设置自动挂载</p>
<p>备份自动挂载配置文件:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cp -p /etc/auto.master /etc/auto.master.`date +%F_%T`</td>
</tr>
</tbody>
</table>
<p>写入配置:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># echo "/efsclient /etc/auto.nfsc –timeout=60" » /etc/auto.master</td>
</tr>
</tbody>
</table>
<p>查看并启用配置:</p>
<p>列出autofs服务信息:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> # chkconfig --list autofs</td>
</tr>
</tbody>
</table>
<p> 设置autofs服务开机自启动:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># chkconfig autofs on</td>
</tr>
</tbody>
</table>
<p>列出autofs服务信息:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># chkconfig --list autofs</td>
</tr>
</tbody>
</table>
<p>开启服务:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># service autofs start</td>
</tr>
</tbody>
</table>
<p> 7. 配置auto.nfsc文件:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># vi auto.nfsc</td>
</tr>
</tbody>
</table>
<p> 写入卷信息:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> test -rw,soft,intr,rsize=32768,wsize=32768,tcp,timeo=300 10.10.10.10:/tmp/servertest</td>
</tr>
</tbody>
</table>
<p>保存auto.nfsc</p>
<p>说明:</p>
<p>第一段test为os本地目录挂载点;</p>
<p>第二段为挂载参数:rw为读写模式、ro为只读模式;</p>
<p>第三段10.10.10.10:/tmp/servertest是cloud NAS卷路径。</p>
<p>使配置生效:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># service autofs reload</td>
</tr>
</tbody>
</table>
<p>8. 触发automount自动挂卷:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># ls -dl /efsclient/test/</td>
</tr>
</tbody>
</table>
<p>9. 验证挂载是否成功,若能看到挂载的信息,表示挂载成功:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># df –t nfs –Ph | grep /tmp/servertest</td>
</tr>
</tbody>
</table>
<p>验证读写:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># touch /efsclient/test/test.txt</td>
</tr>
</tbody>
</table>
<p> </p>
<p><a name="CentOS7.X 客户端配置自动挂载"><span style="font-size:16px"><strong>CentOS7.X 客户端配置自动挂载</strong></span></a></p>
<p>对CentOS7.X客户端,设置cloud NAS 卷自动挂载,本例中客户端挂载目录为/efsclient/test,服务器的IP为10.10.10.10,服务器卷的路径为/tmp/servertest,进入客户端的命令行。</p>
<p><span style="font-size:16px"><strong>操作步骤</strong></span></p>
<p>1. 以root用户登录系统;如果当前用户不是root用户:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># sudo su</td>
</tr>
</tbody>
</table>
<p>然后输入当前用户的密码。</p>
<p>2. 安装autofs软件包:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># yum -y install autofs</td>
</tr>
</tbody>
</table>
<p>3. 查看是否配置过automount:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cat /etc/auto.nfsc</td>
</tr>
</tbody>
</table>
<p>查看主机是否已经挂载过其他cloud NAS卷,如果没有配置过,需要执行以下步骤,如果已经配置过,只需执行8~9步即可:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span>df -t nfs -Ph</td>
</tr>
</tbody>
</table>
<p>4. 查看/etc/sysctl.conf:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cat /etc/sysctl.conf</td>
</tr>
</tbody>
</table>
<p>如无以下配置,需要执行如下命令,先备份sysctl.conf:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cp -p /etc/sysctl.conf /etc/sysctl.conf.`date +%F_%T`</td>
</tr>
</tbody>
</table>
<p>写入配置:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> # echo "net.core.rmem_default = 2621440" » /etc/sysctl.conf
<p> # echo "net.core.wmem_default = 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.core.rmem_max = 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.core.wmem_max = 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.ipv4.tcp_rmem = 4096 655360 2621440" » /etc/sysctl.conf</p>
<p> # echo "net.ipv4.tcp_wmem = 4096 655360 2621440" » /etc/sysctl.conf</p>
</td>
</tr>
</tbody>
</table>
<p>使配置立即生效:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># sysctl -p</td>
</tr>
</tbody>
</table>
<p>5. 检查portmap(rpcbind)和nfslock服务并配置</p>
<p>启动rpcbind服务:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl start rpcbind</td>
</tr>
</tbody>
</table>
<p>查看rpcbind服务状态:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl status rpcbind</td>
</tr>
</tbody>
</table>
<p>设置开机启动rpcbind服务:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl enable rpcbind</td>
</tr>
</tbody>
</table>
<p>列出所有rpcbind类型的unit:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl list-units –-type=service | grep rpcbind</td>
</tr>
</tbody>
</table>
<p>6. 设置自动挂载</p>
<p>备份自动挂接配置文件:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># cp -p /etc/auto.master /etc/auto.master.`date +%F_%T`</td>
</tr>
</tbody>
</table>
<p>将信息写入配置文件:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># echo "/efsclient /etc/auto.nfsc –timeout=60" » /etc/auto.master</td>
</tr>
</tbody>
</table>
<p>查看并启用配置:</p>
<p>列出autofs服务信息:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span> # systemctl list-units –-type=service | grep autofs</td>
</tr>
</tbody>
</table>
<p>设置autofs服务开机自启动:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl enable autofs</td>
</tr>
</tbody>
</table>
<p>列出autofs服务信息:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl list-units –-type=service | grep autofs</td>
</tr>
</tbody>
</table>
<p>开启autofs服务:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl start autofs</td>
</tr>
</tbody>
</table>
<p>7. 配置auto.nfsc文件:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># vi auto.nfsc</td>
</tr>
</tbody>
</table>
<p>写入卷信息:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span>test -rw,soft,intr,rsize=32768,wsize=32768,tcp,timeo=300 10.10.10.10:/tmp/servertest</td>
</tr>
</tbody>
</table>
<p>保存auto.nfsc</p>
<p>说明:</p>
<p>第一段test为客户端挂载点;</p>
<p>第二段为挂载参数:rw为读写模式、ro为只读模式;</p>
<p>第三段10.10.10.10:/tmp/servertest是cloud NAS卷路径;</p>
<p>使配置生效:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># systemctl restart autofs</td>
</tr>
</tbody>
</table>
<p>8. 触发automount自动挂卷:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># ls -dl /efsclient/test/</td>
</tr>
</tbody>
</table>
<p>9. 验证挂载是否成功,若能看到挂载的信息,表示挂载成功:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># df -t nfs -Ph | grep /tmp/servertest</td>
</tr>
</tbody>
</table>
<p>验证读写:</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:813px">
<tbody>
<tr>
<td style="background-color:#ededed; width:805px"> <span style="font-family:Consolas"> </span># touch /efsclient/test/test.txt</td>
</tr>
</tbody>
</table>
<p> </p>
提交成功!非常感谢您的反馈,我们会继续努力做到更好!