前言
以下内容为个人最小化安装后的初始化配置记录,不一定适用于所有场景。
更换yum源为阿里云
替换 yum 源,安装 epel 源。yum-axelget用于加速 yum 下载
yum install -y epel-release lrzsz wget yum-axelgetmv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repowget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repoyum clean allyum makecache
安装一些基本工具
yum install -y vim gcc gcc-c++ python3 python3-pip curl net-tools unzip sysstat tcpdump rsync supervisor iptables iotop yum-utils yum-axelget tree dos2unix ntp fio mlocate lsof
关闭 NetworkManager
如果要做 kvm 虚拟化的话,NetworkManager一定要关
systemctl stop NetworkManager && systemctl disable NetworkManager
关闭selinux
setenforce 0sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
增加可打开的最大文件描述符数
cat >> /etc/security/limits.conf <<EOF* soft nofile 65535* hard nofile 65535EOF
调整系统参数
cat >> /etc/sysctl.conf << EOFnet.ipv4.ip_forward = 1net.ipv6.conf.all.disable_ipv6 = 1net.ipv6.conf.default.disable_ipv6 = 1net.core.somaxconn = 2048net.ipv4.ip_local_port_range= 1024 65535net.core.rmem_default = 262144net.core.wmem_default = 262144fs.file-max = 104857net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.ipv4.tcp_rmem = 4096 4096 16777216net.ipv4.tcp_wmem = 4096 4096 16777216net.ipv4.tcp_mem = 786432 3145728 4194304net.ipv4.tcp_max_syn_backlog = 16384net.core.netdev_max_backlog = 20000net.ipv4.tcp_fin_timeout = 15net.ipv4.tcp_max_syn_backlog = 16384net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_max_orphans= 131072vm.swappiness=1EOFsysctl -p
关闭swap
swapoff -ased -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
关闭firewalld
systemctl stop firewalld.service && systemctl disable firewalld.service
设定ntp时间同步
yum install ntp -y# 设置时区timedatectl set-timezone Asia/Shanghai# 或mv /etc/localtime /etc/localtime_bakcp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime# 手动同步时间ntpdate asia.pool.ntp.org# 修改/etc/ntp.conf,将原有的几个server注释,改为server time1.cloud.tencent.comserver time2.cloud.tencent.comserver time3.cloud.tencent.comserver time4.cloud.tencent.comserver time5.cloud.tencent.com# 启动ntpdsystemctl start ntpdsystemctl enable ntpd
设置history时间戳
echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile && source /etc/profile
配置vimrc
set smarttabset tabstop=4set expandtabset softtabstop=4set shiftwidth=4set nobackupset noswapfileset encoding=utf-8syntax onset hlsearch
配置pip源为阿里云
mkdir -p ~/.pipvim ~/.pip/pip.conf
[global]index-url = https://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com
