CentOS7系统初始化个人配置
以下内容为个人最小化安装后的配置步骤
更换yum源为阿里云
yum install -y epel-release lrzsz wget yum-axelget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum 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
systemctl stop NetworkManager && systemctl disable NetworkManager
关闭selinux
setenforce 0
sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
系统参数调整
cat >> /etc/sysctl.conf << EOF
net.ipv4.ip_forward = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.core.somaxconn = 2048
net.ipv4.ip_local_port_range= 1024 65535
net.core.rmem_default = 262144
net.core.wmem_default = 262144
fs.file-max = 104857
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.tcp_mem = 786432 3145728 4194304
net.ipv4.tcp_max_syn_backlog = 16384
net.core.netdev_max_backlog = 20000
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_orphans= 131072
EOF
sysctl -p
关闭swap
swapoff -a
sed -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_bak
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 手动同步时间
ntpdate asia.pool.ntp.org
# 修改/etc/ntp.conf,将原有的几个server注释,改为
server time1.cloud.tencent.com
server time2.cloud.tencent.com
server time3.cloud.tencent.com
server time4.cloud.tencent.com
server time5.cloud.tencent.com
# 启动ntpd
systemctl start ntpd
systemctl enable ntpd
设置history时间戳
echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile && source /etc/profile
修改vimrc
-
vim /etc/vimrc
-
追加以下内容
set smarttab
set tabstop=4
set expandtab
set softtabstop=4
set shiftwidth=4
set nobackup
set noswapfile
set encoding=utf-8
syntax on
set hlsearch
增加最大文件数限制
cat >> /etc/security/limits.conf <<EOF
* soft nofile 65535
* hard nofile 65535
EOF
本文来自博客园,作者:花酒锄作田,转载请注明原文链接:https://www.cnblogs.com/XY-Heruo/p/15163367.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)