码迷,mamicode.com
首页 > 其他好文 > 详细

NFS服务脚本形式安装实例

时间:2018-08-08 16:10:40      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:nfs   epo   data   exports   utils   grep   centos   $?   war   

#!/bin/bash CLIENT_IP=$1 MOUNT_POINT=$2 STOREAGE=/data SERVER_IP=$(ip a|grep ‘inet ‘|egrep -v ‘127.0.0.1|grep‘|awk -F ‘[ /]+‘ ‘{print $3}‘) #close firewalld and selinux setenforce 0 sed -ri ‘s/^(SELINUX=).*/\1disabled/g‘ /etc/sysconfig/selinux systemctl stop firewalld systemctl disable firewalld #install software yum clean all &>/dev/null if [ $? -ne 0 ];then cd /etc/yum.repos.d/ curl -o 163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo sed -i ‘s/\$releasever/7/g‘ /etc/yum.repos.d/163.repo else yum install nfs‐utils ‐y &>/dev/null yum install rpcbind ‐y &>/dev/null fi echo "$STORAGE ${CLIENT_IP}(rw,async)" > /etc/exports if [ ! -d $STORAGE ];then mkdir -p $STORAGE chmod 777 $STORAGE chown ‐R nfsnobody.nfsnobody $STORAGE fi systemctl start nfs‐server &>/dev/null ssh root@$CLIENT_IP ‘yum -y install nfs-utils‘ ssh root@$CLIENT_IP "showmount ‐e $SERVER_IP" ssh root@$CLIENT_IP "mkdir -p $MOUNT_POINT" ssh root@$CLIENT_IP "mount ‐t nfs ${SERVER_IP}:$STORAGE $MOUNT_POINT"

NFS服务脚本形式安装实例

标签:nfs   epo   data   exports   utils   grep   centos   $?   war   

原文地址:http://blog.51cto.com/13858192/2156274

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!