Linux基线配置

1.关闭防火墙

关闭防火墙

shell 复制代码
systemctl stop firewalld

关闭开机自启

shell 复制代码
systemctl disable firewalld

2.关闭selinux

1.先临时关闭:输入命令setenforce 0

2.再永久关闭:使用sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config修改selinux为disabled。

3.设置最大打开文件数限制

修改系统打开最大文件数

查看打开文件数量限制

shell 复制代码
ulimit -n

先临时修改打开文件的数量

shell 复制代码
ulimit -n 65535(设置合适的数量)

3.永久配置最大打开文件数

设置系统最大打开文件数

编辑系统限制的配置文件,添加文件最大打开数相关内容

shell 复制代码
vi /etc/security/limits.conf

root soft nofile 65535
root hard nofile 65535
*    soft nofile 65535
*    hard nofile 65535

修改此设置需要重启服务器

对于systemd启动的service进程的资源限制

编辑默认配置文件,修改相关配置内容

shell 复制代码
vi /etc/systemd/system.conf
#修改DefaultLimitNPROC和DefaultLimitNOFILE配置值为需要的大小
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535

PS: 如果docker启动mysql容器报错:mysql --verse什么什么的,大概率是limit的原因,在docker.service里面加--default-ulimit nofile=65535:65535

修改此设置需要重启服务器

设置进程最大打开文件数

以jenkins为例:

1.先找到jenkins的进程号

shell 复制代码
ps -ef | grep jenkins

2.查看进程的打开数量限制

shell 复制代码
cat /proc/5513/limits

3.设置该线程打开文件数量限制

shell 复制代码
prlimit --nofile=65535:65535 --pid 5513

4.时间同步

查看时区是否是CST,不是CST需要更改时区

shell 复制代码
date

更改时区为Shanghai

shell 复制代码
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

安装工具

shell 复制代码
yum -y install ntpdate

同步网络时间

shell 复制代码
ntpdate cn.pool.ntp.org

将系统时间写入硬件

shell 复制代码
hwclock --systohc
相关推荐
BestOrNothing_201513 分钟前
(4)Ubuntu 22.04 安装后使用 GParted 重新分区实战记录
linux·gparted·ubuntu22.04·ubuntu磁盘分区
架构指南14 分钟前
Centos上安装Claude Code报GLIBC_2.27 not found
linux·运维·centos
Predestination王瀞潞18 分钟前
4.3.1 存储->微软文件系统标准(微软,自有技术标准):exFAT(Extended File Allocation Table)扩展文件分配表系统
linux·运维·microsoft·exfat·ex4
你有按下913的勇气吗22 分钟前
【Agent,RAG,Transform】
linux·运维·服务器
ken223225 分钟前
linux OS : apt update 使用代理与环境变量
linux
last demo26 分钟前
docker存储
运维·docker·容器
小义_35 分钟前
随笔 1(Linux)
linux·运维·服务器·网络·云原生·红帽
Larry_Yanan1 小时前
Qt网络开发之基于 QWebEngine 实现简易内嵌浏览器
linux·开发语言·网络·c++·笔记·qt·学习
AI+程序员在路上1 小时前
CAN 总线与 Linux SocketCAN C 语言测试程序
linux·c语言·网络
Predestination王瀞潞1 小时前
4.3.3 存储->微软文件系统标准(微软,自有技术标准):VFAT(Virtual File Allocation Table)虚拟文件分配表系统
linux·microsoft·vfat