首页 > 系统相关 >centos 7 系统优化

centos 7 系统优化

时间:2023-01-30 13:32:24浏览次数:48  
标签:系统优化 x86 centos devel etc disable 64 docker

# 系统版本 CentOS Linux release 7.9.2009 (Core) x64
# 内核版本 Linux dashuju01 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
# 系统版本 Anolis OS release 7.9 x64
# 内核版本 Linux k8s01.fengyue.com 3.10.0-1160.an7.x86_64 #1 SMP Thu Oct 14 16:04:36 CST 2021 x86_64 x86_64 x86_64 GNU/Linux


#/bin/bash
cat >> /etc/resolv.conf << EOF
nameserver 223.5.5.5
nameserver 114.114.114.114
EOF
sleep 3

rm -rf /etc/yum.repos.d/*

wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sleep 3
#Yum源更换为国内阿里源
yum -y remove dnsmasq ruby docker docker-client docker-client-latest docker-ce-cli docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
yum -y install wget nfs-utils nodejs-devel p7zip p7zip-plugins telnet ntpdate expect ntp vim lsof net-tools lrzsz dstat psmisc namp net-tools iftop iotop dstat tcpdump patch autoconf automake bison bzip2 gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel yum-utils device-mapper-persistent-data lvm2 glibc-headers glibc-devel iftop iotop atop htop perf nload openssl-devel



sleep 3
ntpdate ntp.aliyun.com
echo "* */4 * * * /usr/sbin/ntpdate ntp.aliyun.com > /dev/null 2>&1" >> /var/spool/cron/root
echo "* */8 * * * /usr/sbin/ntpdate cn.pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root
echo "* */12 * * * /usr/sbin/ntpdate time.windows.com > /dev/null 2>&1" >> /var/spool/cron/root
echo "*/10 * * * * /home/envsafe/shell/frpc.sh >> /dev/null 2>&1" >> /var/spool/cron/root
systemctl restart crond.service

hwclock -w

sleep 3
echo "ulimit -SHn 655350" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
* soft nofile 655350
* hard nofile 655350
EOF

sleep 3
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0

sleep 3
systemctl disable firewalld.service
systemctl stop firewalld.service

sleep 3
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
systemctl restart sshd.service

sleep 3
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
timedatectl set-timezone Asia/Shanghai

sleep 3
rm -rf /usr/lib/systemd/system/ctrl-alt-del.target

sleep 3

systemctl disable cups.socket
systemctl disable cups.path
systemctl disable cups.service
systemctl disable postfix
systemctl disable rpcbind
systemctl disable avahi-daemon.socket
systemctl disable avahi-daemon.service
systemctl disable dnsmasq
systemctl disable chronyd.service
systemctl stop rpcbind.socket
systemctl stop rpcbind
systemctl stop avahi-daemon.socket
systemctl stop chronyd
killall dnsmasq
killall cupsd
killall rpc.mountd

sleep 3
echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile

sleep 3

标签:系统优化,x86,centos,devel,etc,disable,64,docker
From: https://blog.51cto.com/nowsafe/6026260

相关文章

  • 防火墙操作命令(centos7)
    查看防火墙状态:systemctlstatusfirewalld让防火墙可用:systemctlanablefirewalld让防火墙不可用:systemctldisablefirewalld启动防火墙:systemctlstartfirewalld......
  • centos7下 crontab -e 未成功运行原因
     启动失败原因之一: 注意:二进制程序名称与包名一致;----这就是crontab始终无法启动程序的原因;=>使用绝对路径运行脚本时: 由于包名与程序名称......
  • 解决centos中端口占用问题
    1.查看的是占用80端口的进程netstat-tlnp|grep802.一次性的清除占用80端口的进程lsof-i:80|grep-v"PID"|awk'{print"kill-9",$2}'|sh3.手工终止进程的运行......
  • 重装Centos使用ssh命令远程登录报错问题
    背景:重装Linux之后,在Windows上使用CMD窗口使用ssh命令连接报错;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@WARNING:REMOTEHOSTIDENTIFICATIO......
  • linux--centos制作yum源
    一、制作本地yum源的步骤1、  创建iso存放目录和挂载目录[root@desktop~]#cd/mnt/[root@desktopmnt]#mkdirisoyum_mirror2、  将iso文件上传到iso存放目录......
  • CentOS Stream 9添加route路由网关
    网卡配置目录:/etc/NetworkManager/system-connections/方式1:在网卡配置文件中进行添加gateway网关配置我的第一个网卡的配置文件路径是:/etc/NetworkManager/system-conne......
  • win 子系统导入centos7
    之前在应用商店安装过ubuntu的,有钱的建议从商店购买window配置,    准备一个centos系统,我是从已有系统导出的,导出命令tar-cvf./centos.tar./--exclude=cen......
  • CentOS Linux release 7.6 zabbix5.0 安装
    #zabbix安装关方文档https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=centos&os_version=7&components=server_frontend_agent&db=mysql&ws=nginx安......
  • Centos7安装Docker
    Centos7安装Docker一、安装环境安装Docker配置:Centos7Linux内核:官方建议3.10以上。注意:本文的命令使用的是root用户登录执行,不是root的话所有命令前面要加sud......
  • CentOS7 安装pycharm
    一、下载pycharm先下载安装包官网地址:https://www.jetbrains.com/pycharm/download/#section=linux   专业版,需要购买,可以试用30天,社区版免费使用没有专业版的一......