tecs中两台服务器间做磁盘映射

.CentOS 6 NFS的安装配置  (磁盘映射)

 

以我们的环境为例,我们把114上的/root/h-apt目录映射到126/root/h-apt下,则114nfs的服务器,126是客户端。

 

首先,让两台机器都安装NFS的 软件包,如下显示的是服务器端:

[root@roothomes /home]$ yum install nfs-utils rpcbind

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: centos.ustc.edu.cn

 * extras: centos.ustc.edu.cn

 * updates: centos.ustc.edu.cn

Setting up Install Process

Package rpcbind-0.2.0-8.el6.x86_64 already installed and latest version

Resolving Dependencies

--> Running transaction check

---> Package nfs-utils.x86_64 1:1.2.3-15.el6 set to be updated

--> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================================

 Package            Arch            Version                 Repository     Size

================================================================================

Updating:

 nfs-utils          x86_64          1:1.2.3-15.el6          base          308 k

 

Transaction Summary

================================================================================

Install       0 Package(s)

Upgrade       1 Package(s)

 

Total download size: 308 k

Is this ok [y/N]: y

Downloading Packages:

nfs-utils-1.2.3-15.el6.x86_64.rpm                        | 308 kB     00:10

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

base/gpgkey                                              | 3.3 kB     00:00 ...

Importing GPG key 0xC105B9DE "CentOS-6 Key (CentOS 6 Official Signing Key) " from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Is this ok [y/N]: y

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Updating       : 1:nfs-utils-1.2.3-15.el6.x86_64                          1/2

  Cleanup        : 1:nfs-utils-1.2.2-7.el6.x86_64                           2/2

 

Updated:

  nfs-utils.x86_64 1:1.2.3-15.el6

 

Complete!

[root@roothomes /home]$

 

服务器端:

###(建立挂载的目录,并且挂载目录。)

[root@roothomes /etc]$ mkdir /root/h-apt

[root@roothomes /etc]$ cd  /root/h-apt

 [root@roothomes /opt/centos6]$ mkdir thisISnfsFile

[root@roothomes /opt/centos6]$ ls

thisISnfsFile

[root@roothomes /etc]$ vi /etc/exports

[root@roothomes /opt/centos6]$ cat /etc/exports

 

/root/h-apt *(ro,no_root_squash)

### 备注: /root/h-apt表示nfs共享的目录 *表示所有的IP可以访问,访问权限是自读,root 用户

###(启动对应的服务)

[root@roothomes /opt/centos6]$ chkconfig nfs on

[root@roothomes /opt/centos6]$ /etc/init.d/rpcbind start

[root@roothomes /opt/centos6]$ /etc/init.d/nfs start

Starting NFS services:                                     [  OK  ]

Starting NFS quotas:                                       [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting NFS mountd:                                       [  OK  ]

[root@roothomes /opt/centos6]$ service iptables stop

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Unloading modules:                               [  OK  ]

 

 

客户端:

[root@roothomes /home]$ yum install nfs-utils rpcbind

安装完毕!

[root@vmBS00 ~]# service iptables stop

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Unloading modules:                               [  OK  ]

###查看是否能访问nfs服务

[root@vmBS00 ~]# showmount -e 192.168.2.3

Export list for 192.168.2.3:

/root/h-apt *

[root@vmBS00 ~]# mkdir /root/h-apt

[root@vmBS00 ~]# mount -t nfs 192.168.2.3 /root/h-apt  /root/h-apt

 [root@vmBS00 ~]# ls /root/h-apt

thisISnfsFile

###配置开机自动挂载

[root@vmBS00 ~]# vi /etc/fstab

### 添加 #192.168.1.75:/opt/centos6/ /opt/centos6/ nfs nodev,ro,rsize=32768,wsize=32768 0 0

 

[root@vmBS00 ~]# init 6

[root@vmBS00 ~]#

login as: root

root@192.168.1.116's password:

Last login: Mon Mar  5 17:29:04 2012 from 192.168.1.23

[root@vmBS00 ~]# ls /opt/centos6/

thisISnfsFile

[root@vmBS00 ~]#

 

你可能会遇到的问题:

mount.nfs: access denied by server while mounting 192.168.2.3:/root/h-apt

有几种可能

一种是你挂载的目录的权限问题,改成777试试,另外还有一种情况,用

cat /var/log/messages | grep mount命令查看下服务器上日志,如果有

Jun 29 00:49:04 lzgonline mountd[1644]: refused mount request from 192.168.3.12 for /home/lzgonline/rootfs (/home/lzgonline/rootfs): illegal port 1689   这种问题,那么则需要将 insecure 选项加入到配置文件(/etc/exports)重,加上之后,执行exportfs –r;

  /root/h-apt *(insecure,rw,async,no_root_squash)

最近一次碰到的问题:复制下面这条命令执行挂载 mount -t nfs 192.168.2.3:/root/h-apt/  /root/h-apt/的时候。。也许中间有其他看不见的符号

posted @ 2016-06-27 19:31  lynn_zxl  阅读(239)  评论(0)    收藏  举报