NFS服务脚本形式安装实例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NFS服务脚本形式安装实例相关的知识,希望对你有一定的参考价值。
#!/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 [email protected]$CLIENT_IP ‘yum -y install nfs-utils‘
ssh [email protected]$CLIENT_IP "showmount ‐e $SERVER_IP"
ssh [email protected]$CLIENT_IP "mkdir -p $MOUNT_POINT"
ssh [email protected]$CLIENT_IP "mount ‐t nfs ${SERVER_IP}:$STORAGE $MOUNT_POINT"
以上是关于NFS服务脚本形式安装实例的主要内容,如果未能解决你的问题,请参考以下文章