centos环境检查(脚本)

centos7.6环境检查一键配置

脚本内容如下

#YUM
ls /etc/yum.repos.d/
echo ""
echo "############################"
read -p "clean yum,your answer(y|*):" ans
if [ "$ans" == "y" ];then
    mkdir /etc/yum.repos.d/bak
    mv /etc/yum.repos.d/CentOS* /etc/yum.repos.d/bak/
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
    yum clean all
    yum makecache
fi
echo ""
echo "############################"
#关闭防火墙#
if systemctl status firewalld &>/dev/null;then
    systemctl stop firewalld &>/dev/null
    systemctl disable firewalld &>/dev/null
else
    echo "防火墙已关闭"
fi
echo ""
echo "############################"
#关闭NetworkManager#
read -p "check net device,if continue:" answ
if [ "$answ" == "y" ];then
    if systemctl status NetworkManager &>/dev/null;then
        systemctl stop `NetworkManager` &>/dev/null
        systemctl disable NetworkManager &>/dev/null
    else
        echo "NetworkManager已关闭"
    fi
fi
echo ""
echo "############################"
#关闭selinux#
se_stat=`getenforce`
if [ "$se_stat" == "Enforcing" ];then
    setenforce 0
    sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
else
    echo "selinux状态为$se_stat"
fi
echo ""
echo "############################"
#上传sync命令,并安装#
if ! which rsync &>/dev/null;then
    yum install rsync -y
    which rsync
fi
#调整最大文件打开数#
files_num=`ulimit -n`
if [ $files_num != 102400 ];then
    echo "root soft nofile 102400" >>/etc/security/limits.conf
    echo "root hard nofile 102400" >>/etc/security/limits.conf
else
    echo "文件最大打开数为${files_num}"
fi
echo ""
echo "############################"
#检查http代理
echo "-------check_http_proxy------"
echo "$http_proxy" "$https_proxy"
echo ""
echo "-----------------------------"

echo ""
echo "############################"
#创建目录
[ -d "/data" ] || mkdir /data && ls -ld /data/
echo ""
echo "############################"

#确认时间同步
echo "please check date,you can you these cmd to change!"
echo "-------------------------------------------------"
echo ""
echo "date -s 10:20:00;hwclock --systohc"
echo "cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值