一.安装nfs相关软件:
[root@DBhost mysql_data]#yum install rpcbind nfs-utils -y
systemctl restart rpcbind&&systemctl enable rpcbind
systemctl restart nfs&&systemctl enable nfs
二.修改共享目录权限:
[root@DBhost mysql_data]#chmod -Rf 777 /mysql_data
三.授权:
在nfs服务端DBhost(10.116.137.233)上修改/etc/exports文件
[root@DBhost mysql_data]# vi /etc/exports
添加需要授权的服务器ip(举例如下):
/mysql_data 10.116.84.1(rw,sync,root_squash)
##exports配置常用参数说明:
ro 只读
rw 读写
root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的匿名用户
sync 同时将数据写入到内存与硬盘中,保证不丢失数据
async 优先将数据保存到内存,然后再写入硬盘;这样效率更高,但可能会丢失数据
四.刷新新添加的授权:
[root@DBhost mysql_data]# service nfs restart && exportfs -a
[root@DBhost mysql_data]# exportfs -a
五.在nfs客户端挂载
1)检查nfs服务端共享出的目录:
showmount -e 10.116.137.233
2)mount -t nfs 10.116.137.233:/mysql_data 本地目录
如果需要开机自动挂载,编辑/etc/fstab文件,添加:
10.116.137.233:/mysql_data 本地目录 nfs defaults 0 0
-------调整NAS卷位置
--10.116.137.233
mount /dev/VolGroup01/LVmysql_data /dba_backup_migration
chmod -Rf 777 /dba_backup_migration
sed -i 's/mysql_data/dba_backup_migration/g' /etc/exports
exportfs -a
umount /mysql_data/
vim /etc/fstab
cat /etc/exports
showmount -e 10.116.137.233
service nfs restart
--10.116.137.234
chmod -Rf 777 /dba_backup_dr
mount /dev/VolGroup01/LVmysql_data /dba_backup_dr
sed -i 's/mysql_data/dba_backup_dr/g' /etc/exports
exportfs -a
umount /mysql_data/
vim /etc/fstab
cat /etc/exports
showmount -e 10.116.137.234
service nfs restart
--10.116.83.19
chmod -Rf 777 /dba_backup_prd
mount /dev/mapper/VolGroup01-LVmysql_data /dba_backup_prd
sed -i 's/mysql_data/dba_backup_dr/g' /etc/exports
exportfs -a
umount /mysql_data/
vim /etc/fstab
cat /etc/exports
showmount -e 10.116.83.19
service nfs restart