CentOS7_init.sh

#!/bin/bash
# centos7_init.sh  
# Date:2022/06/05
# Description:CentOS初始化脚本  该脚本只适用于CentOS 7.x

# yum加速
sed -i '/enabled/s/1/0/' /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -4 -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

# yum安装常用软件包
yum install -y ntp vim bind-utils net-tools epel-release git wget lrzsz gcc gcc-c++

# epel加速
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
wget -4 -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

# 关闭selinux
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

# 关闭防火墙、Networkmanager、postfix
systemctl stop firewalld
systemctl stop NetworkManager
systemctl disable firewalld
systemctl disable NetworkManager
systemctl stop postfix
systemctl disable postfix

# 修改最大打开文件数为65535
echo "* - nofile 65535" >> /etc/security/limits.conf
echo "* - nproc 65535" >> /etc/security/limits.conf

# 网络参数优化
echo "net.ipv4.ip_forward = 0" >> /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_tw_recycle = 1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_tw_reuse = 1" >> /etc/sysctl.conf

echo "所有的配置已经优化完成,请重启以使所有的配置生效。"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值