CentOS7系统初始化个人配置

简介: 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

  1. vim /etc/vimrc
  2. 追加以下内容
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
相关文章
|
15天前
|
Linux 网络安全 Apache
CentOS 7.2配置Apache服务httpd(上)
CentOS 7.2配置Apache服务httpd(上)
130 1
|
2月前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
3天前
|
Linux 网络安全 数据安全/隐私保护
Linux系统之Centos7安装cockpit图形管理界面
【10月更文挑战第12天】Linux系统之Centos7安装cockpit图形管理界面
24 1
Linux系统之Centos7安装cockpit图形管理界面
|
4天前
|
Java jenkins 持续交付
Centos7下docker的jenkins下载并配置jdk与maven
通过上述步骤,您将成功在CentOS 7上的Docker容器中部署了Jenkins,并配置好了JDK与Maven,为持续集成和自动化构建打下了坚实基础。
27 1
|
6天前
|
存储 监控 Linux
在 CentOS 7 中如何对新硬盘进行分区、格式化、挂载及配置最佳实践
本文详细介绍了在 CentOS 7 中如何对新硬盘进行分区、格式化、挂载及配置最佳实践,包括使用 `fdisk` 创建分区、`mkfs` 格式化分区、创建挂载点、编辑 `/etc/fstab` 实现永久挂载等步骤,旨在有效管理服务器磁盘空间,提高系统稳定性和可维护性。
13 1
|
15天前
|
Linux PHP Apache
CentOS 7.2配置Apache服务httpd(下)
CentOS 7.2配置Apache服务httpd(下)
44 1
|
25天前
|
网络协议 Linux Shell
CentOS7系统命令学习笔记(一)
CentOS7系统命令学习笔记(一)
61 12
|
25天前
|
Linux
CentOS7系统命令学习笔记(二)
CentOS7系统命令学习笔记(二)
49 10
|
25天前
|
Linux Shell API
CentOS7系统命令学习笔记(三)
CentOS7系统命令学习笔记(三)
50 8
|
2月前
|
弹性计算 关系型数据库 MySQL
centos7 mysql安装及配置
本文详细介绍了在阿里云服务器ECS上通过yum源安装MySQL 8.0.12的过程,包括更新yum源、下载并安装MySQL源、解决安装过程中可能遇到的问题等步骤。此外,还介绍了如何启动MySQL服务、设置开机自启、配置登录密码、添加远程登录用户以及处理远程连接异常等问题。适合初学者参考,帮助快速搭建MySQL环境。
249 8
centos7 mysql安装及配置