Auth: Jin
Date: 20140317
需求
将NFS共享IP切换为192.168.201.221,通过192.168.201.0网段提供共享(10.0.0.0和192.168.201.0都能使用)
将NFS共享目录切换到/data/BackupPC/nfs/,这样纳入BackupPC备份
NFS 原来的配置
/data/backup/nfs 10.0.0.0/24(rw,sync,no_root_squash)
/data/backup/nfs/gbstore 10.0.0.0/24(rw,sync,no_root_squash)
/data/backup/nfs/gbdms 10.0.0.0/24(rw,sync,no_root_squash)
/data/backup/nfs/gbstock 10.0.0.0/24(rw,sync,no_root_squash)
操作
一、准备工作
1.NSF Server 221
rm -rf /data/BackupPC/nfs/ && rsync -av /data/backup/nfs/ /data/BackupPC/nfs/ && chown -R webroot.webroot /data/BackupPC/nfs/
cat >>/etc/exports << EOF
/data/BackupPC/nfs/gbstore 192.168.201.221(rw,sync,no_root_squash)
/data/BackupPC/nfs/gbdms 192.168.201.221(rw,sync,no_root_squash)
/data/BackupPC/nfs/gbstock 192.168.201.221(rw,sync,no_root_squash)
EOF
exportfs -av
2.测试 NSF clinet
247
# mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbstore /mnt/
mount: 192.168.201.221:/data/BackupPC/nfs/gbstore failed, reason given by server: Permission denied
子目录权限加了也提示没有权限
exportfs -r重新读取配置也没有权限
二、操作
1.NSF clinet 248,249
umount /home/gbstore/external_data
umount /home/gbdms/external_data
umount /home/gbstock/logs_sku_config
2.NSF Server 221
全部umount后服务器再同步和重启服务
rsync -av /data/backup/nfs/ /data/BackupPC/nfs/
chown -R webroot.webroot /data/BackupPC/nfs/
chown -R gbstore /data/BackupPC/nfs/gbstore
chown -R gbdms /data/BackupPC/nfs/gbdms
chown -R gbstock /data/BackupPC/nfs/gbstock
前面的exportfs -av之后无法挂载
/etc/init.d/nfs restart
3.NSF clinet mount 248,249
mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbstore/ /home/gbstore/external_data/
mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbdms/ /home/gbdms/external_data/
mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbstock /home/gbstock/logs_sku_config/
4.加入fstab
实际操作问题:
没有权限是我自己网段写错了
/data/BackupPC/nfs/gbstore 192.168.201.0/24(rw,sync,no_root_squash)
/data/BackupPC/nfs/gbdms 192.168.201.0/24(rw,sync,no_root_squash)
/data/BackupPC/nfs/gbstock 192.168.201.0/24(rw,sync,no_root_squash)umount报错
[root@JQ-pdt-host-248 ~]# umount /home/gbstore/external_data && mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbstore/ /home/gbstore/external_data/
umount: /home/gbstore/external_data: device is busy
umount: /home/gbstore/external_data: device is busy
改进操作
二、操作
1.NSF Server 221
全部umount后服务器再同步和重启服务
rsync -av /data/backup/nfs/ /data/BackupPC/nfs/ && chown -R webroot.webroot /data/BackupPC/nfs/ && chown -R gbstore /data/BackupPC/nfs/gbstore && chown -R gbdms /data/BackupPC/nfs/gbdms && chown -R gbstock /data/BackupPC/nfs/gbstock
&& exportfs -r
2.NSF clinet mount 248,249
shell
/etc/init.d/nginx stop && /etc/init.d/php-fpm stop
if [ $? -eq 0 ];then
umount /home/gbstore/external_data && mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbstore/ /home/gbstore/external_data/;
umount /home/gbdms/external_data && mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbdms/ /home/gbdms/external_data/;
umount /home/gbstock/logs_sku_config && mount -t nfs 192.168.201.221:/data/BackupPC/nfs/gbstock /home/gbstock/logs_sku_config/
if [ $(df|grep tmpfs |wc -l) -eq 6 ];then
/etc/init.d/php-fpm start && /etc/init.d/nginx start
else
echo 'mount fail'
fi
esle
echo 'stop service fail'
fi
3.加入fstab