From 64f31627fcd6ee54f5b96ed643724ace94d38ffc Mon Sep 17 00:00:00 2001 From: xiaoz Date: Mon, 21 Dec 2020 16:44:59 +0800 Subject: [PATCH] test --- init.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 init.sh diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..722d407 --- /dev/null +++ b/init.sh @@ -0,0 +1,41 @@ +#!/bin/bash +##### 新系统初始化 ##### + +#同步时间 +function sync_time() { + yum -y install ntpdate + #设置时区 + timedatectl set-local-rtc 1 + timedatectl set-timezone Asia/Shanghai + #同步时间 + ntpdate -u pool.ntp.org + ntpd=(`which ntpdate`) + #定时任务 + echo "*/20 * * * * ${ntpd} pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root + systemctl reload crond + echo "同步成功,当前时间:" `date` +} + +#安装BBR +function insrall_bbr() { + yum -y install wget + wget https://www.elrepo.org/RPM-GPG-KEY-elrepo.org + rpm --import RPM-GPG-KEY-elrepo.org + rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm + + #升级最新内核 + yum --enablerepo=elrepo-kernel install kernel-ml -y + #设置最新内核 + grub2-set-default 0 + + #写入配置文件 + echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf + echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf + + #清理工作 + rm -rf RPM-GPG-KEY-elrepo.org bbr.sh + #重启服务器 + reboot +} +sync_time +insrall_bbr \ No newline at end of file