这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
|
zh:常见问题及解答:centos6.x主机之间网络文件挂载 [2016/11/09 10:48] liuxl |
zh:常见问题及解答:centos6.x主机之间网络文件挂载 [2017/12/12 03:05] (当前版本) |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ===== nfs挂载设置 ===== | + | ===== nfs文件类挂载设置 ===== |
| <note>服务器(提供共享需要被挂载的磁盘空间):192.168.1.76, | <note>服务器(提供共享需要被挂载的磁盘空间):192.168.1.76, | ||
| 行 75: | 行 75: | ||
| {{:zh:常见问题及解答:selection_134.png?500|}} | {{:zh:常见问题及解答:selection_134.png?500|}} | ||
| - | 9、卸载删除共享 | + | 9、卸载删除共享: |
| <code>umount 192.168.1.76:/root/my</code> | <code>umount 192.168.1.76:/root/my</code> | ||
| 行 82: | 行 82: | ||
| <code>mount -t nfs -o rw 192.168.1.76:/root/my /mnt</code> | <code>mount -t nfs -o rw 192.168.1.76:/root/my /mnt</code> | ||
| - | ===== cifs挂载设置 ===== | + | ===== cifs文件类挂载设置 ===== |
| <note>服务器(提供共享需要被挂载的磁盘空间):192.168.1.76, | <note>服务器(提供共享需要被挂载的磁盘空间):192.168.1.76, | ||
| 行 88: | 行 88: | ||
| 1、主机上安装samba服务: | 1、主机上安装samba服务: | ||
| - | <code> apt install samba </code> | + | <code> yum install samba </code> |
| 2、安装完成后主机上分别创建samba用户及密码: | 2、安装完成后主机上分别创建samba用户及密码: | ||
| 创建samba用户: | 创建samba用户: | ||
| - | <code> useradd sbu </code> | + | <code> useradd smb </code> |
| - | 设置sbu密码,并在提示时输入123456: | + | 设置sbu密码,并在提示时输入123321: |
| - | <code> smbpasswd -a sbu </code> | + | <code> smbpasswd -a smb </code> |
| 3、修改主机上samba配置文件 /etc/samba/smb.conf,在smb.conf 文件末尾添加如下内容: | 3、修改主机上samba配置文件 /etc/samba/smb.conf,在smb.conf 文件末尾添加如下内容: | ||
| 行 109: | 行 109: | ||
| directory mask = 660 | directory mask = 660 | ||
| force user = root</code> | force user = root</code> | ||
| - | | + | |
| - | 4、iptables放行samba端口: | + | 4、重启服务器上的samba服务: |
| + | |||
| + | <code>service smb restart</code> | ||
| + | |||
| + | 5、iptables放行samba端口: | ||
| 新增入站规则: | 新增入站规则: | ||
| - | <code>iptables -A INPUT -p tcp -m multiport --dports 139,445 -j ACCEPT | + | <code>iptables -I INPUT -p tcp -m multiport --dports 139,445 -j ACCEPT |
| - | iptables -A INPUT -p udp -m multiport --dports 137,138 -j ACCEPT</code> | + | iptables -I INPUT -p udp -m multiport --dports 137,138 -j ACCEPT</code> |
| - | 新增出站规则: | + | {{:zh:常见问题及解答:selection_038.png?750|}} |
| - | <code>iptables -A OUTPUT -p tcp -m multiport --sports 139,445 -j ACCEPT | + | |
| - | iptables -A OUTPUT -p tcp -m multiport --sports 137,138 -j ACCEPT</code> | + | |
| - | 5、设置开机自动挂载,客户机上可设置开机自动挂载: | + | 6、执行挂载操作: |
| - | <code>vim /etc/fstab</code> | + | <code> mount -t cifs -o username=sbu,password=123321 //192.168.1.76/root /mnt </code> |
| - | <code>文件末增加如下 : //192.168.1.76/root /mnt cifs defaults,username=sbu,password=123456 0 0</code> | + | |
| + | 7、设置开机自动挂载,客户机上可设置开机自动挂载: | ||
| + | <code> VIM编辑/etc/fstab,文件末增加如下: //192.168.1.76/root /mnt cifs defaults,username=smb,password=123321 0 0 </code> | ||
| + | |||
| + | {{:zh:常见问题及解答:selection_035.png?1000|}} | ||
| + | |||
| + | 8、查看是否已挂载: | ||
| + | <code>df -hT</code> | ||
| + | {{:zh:常见问题及解答:selection_037.png?750|}} | ||
| + | 9、卸载删除共享: | ||
| + | <code>umount //192.168.1.76/root</code> | ||