Linux下NFS服务
Redhat下配置迁移
NFS文件服务迁移(165迁移到164)
1.拷贝资源文件修改权限 (将165服务器/opt/share下的文件拷贝到164服务器的/opt/share)
scp -r /opt/share/* root@192.168.210.164:/opt/share/
chmod -R 777 /opt/share
2,配置服务端
编辑/etc/exports,加入:
/opt/share 192.168.210.160(rw) #IP是客户端的地址, 目录是要共享出的目录
/opt/share 192.168.210.161(rw) #IP是客户端的地址, 目录是要共享出的目录
/opt/share 192.168.210.162(rw) #IP是客户端的地址, 目录是要共享出的目录
/opt/share 192.168.210.163(rw) #IP是客户端的地址, 目录是要共享出的目录
3.然后启动nfs服务:
/etc/init.d/nfs start
修改/etc/exprots文件后需要重新启动才能生效
/etc/init.d/nfs restart
停止 /etc/init.d/nfs stop
********
/etc/rc.d/init.d/portmap start (在REDHAT中PORTMAP是默认启动的)
/etc/rc.d/init.d/nfs start 启动NFS服务
/etc/rc.d/init.d/nfs stop 停止NFS服务
***********
4,依次建立软链接4.1 依次停服务器
4.2 挂载 mount 192.168.210.164:/opt/share /opt/file (卸载挂载 umount /opt/file mount -l ; df-h)
4.3 删除res文件 rm -rf res
4.4 ln -s /opt/file/cmsResource /opt/data0/homeinns/res
5. 启动服务器
tomcat => nginx
centos6.2变更了portmap服务为rpcbind,在使用nfs时这点与centos5不同,下面配置一个nfs系统,用来使局域网内的所有用户均可访问该目录,可将该目录配置成yum源,供内网机器安装软件。
NFS的安装配置:
yum install nfs-utils.x86_64(64位系统)
yum install nfs-utils(32位系统)
然后安装portmap服务,portmap在centos6中改名为rpcbind
yum install rpcbind(centos6)
yum install portmap(centos5)
服务器端
检查是否安装
rpm -q nfs-utils rpcbind
安装
yum install nfs-utils rpcbind
建立挂载的目录
mkdir /opt/share
cd /opt/share
配置nfs服务端
vi /etc/exports
添加
/opt/share 192.168.0.0/24(ro,no_root_squash)
这一行表明本机的/opt/share这个目录为nfs共享目录,可访问的ip地址区间为192.168.0.0-192.168.0.24,权限为只读当访问者为root用户时方位该目录具有root权限
启动服务
service iptables stop
/etc/init.d/rpcbind start
/etc/init.d/nfs start
开机启动
chkconfig nfs on
默认的共享选项是 sync,ro,root_squash,no_delay。CentOS系统中,当主机名或IP地址为空时,则代表共享给任意客户机提供服务。
当将同一目录共享给多个客户机,但对每个客户机提供的权限不同时,可以这样:
[共享的目录] [主机名1或IP1(参数1,参数2)] [主机名2或IP2(参数3,参数4)]
ro 只读访问
rw 读写访问
sync 所有数据在请求时写入共享
async NFS在写入数据前可以相应请求
secure NFS通过1024以下的安全TCP/IP端口发送
insecure NFS通过1024以上的端口发送
wdelay 如果多个用户要写入NFS目录,则归组写入(默认)
no_wdelay 如果多个用户要写入NFS目录,则立即写入,当使用async时,无需此设置。
hide 在NFS共享目录中不共享其子目录
no_hide 共享NFS目录的子目录
subtree_check 如果共享/usr/bin之类的子目录时,强制NFS检查父目录的权限(默认)
no_subtree_check 和上面相对,不检查父目录权限
all_squash 共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
no_all_squash 保留共享文件的UID和GID(默认)
root_squash root用户的所有请求映射成如anonymous用户一样的权限(默认)
no_root_squash root用户具有根目录的完全管理访问权限
anonuid=xxx 指定NFS服务器/etc/passwd文件中匿名用户的UID
anongid=xxx 指定NFS服务器/etc/passwd文件中匿名用户的GID
客户端:
查看是否能访问nfs服务
showmount -e 192.168.0.10
挂载nfs目录
mkdir /opt/share/
mount -t nfs 192.168.0.10:/opt/share/ /opt/share/
ls /opt/share
Refer:
http://www.osyunwei.com/archives/3757.html
http://wenku.baidu.com/view/ae5c774c2e3f5727a5e9626f.html
http://wenku.baidu.com/view/c87cf21ffc4ffe473368ab1d.html