centos 6.x 系统基础优化简版
Centos 6.x 系统基础优化
1、更换国内yum源
删除系统带的centos官方yum源
rm -rf /etc/yum.repos.d/*
使用国内阿里云源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
使用国内阿里云epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
提示:如果这里提示没有wget命令,则需要执行:yum install wget -y
2、安装系统基础包
yum install lrzsz tree telnet wget lsof net-tools dos2unix sysstat traceroute unzip zip -y
3、时区配置和时间同步
将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpd时间同步服务
yum install chrony -y
配置:
编辑配置文件:/etc/chrony.conf,删除4-6行,并修改第3行,如下:
server time4.aliyun.com iburst
启动chrony服务并设置开机自启
/etc/init.d/chronyd start
chkconfig chronyd on
查看时间同步状态:
[root@centos6 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 203.107.6.88 2 9 377 287 -182us[ -676us] +/- 19ms
4、精简并保留必要的开机自启动服务
关闭不必要的开机启动项,使用下面命令:
chkconfig | egrep -v 'network|sshd|rsyslog|chronyd|crond|ntpd' | awk '{print "chkconfig",$1,"off"}' | bash
5、关闭selinux和iptables
iptables需要根据实际情况来决定是否关闭,请自行判断;
关闭selinux:
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux
此配置是重启后生效,如果没有条件重启或者不想重启可以使用:
setenforce 0 #此命令仅是忽略,还是建议关闭
6、调整文件描述符数量
修改/etc/security/limits.conf配置文件:
echo '* - nofile 65535'>>/etc/security/limits.conf
增加开机启动:
cat >>/etc/rc.local<<EOF
#open files
ulimit -HSn 65535
#stack size
ulimit -s 65535
EOF
7、锁定关键系统文件,防止提权篡改
上锁:
chattr +i /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/inittab
解锁:
chattr -i /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/inittab
8、内核优化
内核优化相关的参数很多,需要根据自身的业务进行相关参数的变更优化
下面提供几个案例优化参数,仅供参考:
#可用于apache,nginx,squid多种等web应用
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
以下参数是对centos6.x的iptables防火墙的优化,防火墙不开会有提示,可以忽略不理。
如果是centos5.X需要吧netfilter.nf_conntrack替换成ipv4.netfilter.ip
centos5.X为net.ipv4.ip_conntrack_max = 25000000
net.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_tcp_timeout_established = 180
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
立即生效 /sbin/sysctl -p centos6.5可能会报错
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
centos 6.x 系统基础优化简版的更多相关文章
- Centos 7.x 系统基础优化
Centos 7.x 系统基础优化 1.更换国内yum源 删除系统带的centos官方yum源 rm -rf /etc/yum.repos.d/* 使用国内阿里云源 curl -o /etc/yum. ...
- Linu之linux系统基础优化和基本命令
Linux系统基础优化和基本命令 网络参数设定命令 ifconfig: 查询,设置网卡和ip等参数 ifup,ifdown: 脚本命令,更简单的方式 ip: 符合指令,直接修改上述功能 编辑网卡配置文 ...
- Linux 系统基础优化和常用命令
目录 Linux 系统基础优化和常用命令 软连接 tar解压命令 gzip命令 netstart命令 ps命令 kill命令 killall命令 SELinux功能 iptables防火墙 Linux ...
- 运维 07 Linux系统基础优化及常用命令
Linux系统基础优化及常用命令 Linux基础系统优化 引言没有,只有一张图. Linux的网络功能相当强悍,一时之间我们无法了解所有的网络命令,在配置服务器基础环境时,先了解下网络参数设定命令 ...
- 系统基础优化( 创建yum私有仓库最详细操作及解释 )
目录 系统基础优化 一.Linux中安装软件的方式 安装方式 三种安装方式的区别 二.RPM安装☆ 1.安装及其他命令 2.手动下载软件包,可将其拖入shell中自动传入 1).手动网页下载软件包 2 ...
- Linux实战教学笔记06:Linux系统基础优化
第六节 Linux系统基础优化 标签(空格分隔):Linux实战教学笔记-陈思齐 第1章 基础环境 第2章 使用网易163镜像做yum源 默认国外的yum源速度很慢,所以换成国内的. 第一步:先备份 ...
- 系统基础优化 vim
系统基础优化 vim 1系统基础优化 (CPU-lscpu 内存-free 磁盘-df 负载-w/uptime) 1.1 系统基础优化 准备工作:如何查看系统的信息 (1)cat /etc/redha ...
- Centos6.5 64linux系统基础优化(二)
1 操作的最小化原则 1)安装系统最小化 2)开启程序服务最小化原则 3)操作最小化原则 4)登陆最小化原则;平时没有需求不用root登陆,要用普通登陆. 2 更改ssh服务默认端口及常规配置 # ...
- Linux系统基础优化
一.关闭防火墙iptables: (1)关闭 /etc/init.d/iptables stop (2)检查 ...
随机推荐
- 在VMware下进行的CentOS7操作系统虚拟机的安装
一.VMware虚拟机的安装 首先你需要拥有一款软件VMware,这是一款虚拟机安装软件.Vmware比起Vbox收费较贵,占用资源大,但是拥有大量的资源以及拥有克隆技术,适合新手学习使用,较为专业. ...
- JavaSE语法
二.JavaSE语法(上) 1.Java 有没有 goto 语句? goto 是 Java 中的保留字,在目前版本的 Java 中没有使用.根据 James Gosling(Java 之父)编写的&l ...
- Mybaits 源码解析 (十)----- 全网最详细,没有之一:Spring-Mybatis框架使用与源码解析
在前面几篇文章中我们主要分析了Mybatis的单独使用,在实际在常规项目开发中,大部分都会使用mybatis与Spring结合起来使用,毕竟现在不用Spring开发的项目实在太少了.本篇文章便来介绍下 ...
- js调用局部打印功能并还原
function printme() { //printMain为要打印的dom元素 window.document.body.innerHTML = document.getElementById( ...
- js基础总结02--字符串操作
1.字符串中对单个字符位置的操作 indexOf(char); 从左往右查找,返回匹配到的第一个字符的位置,没有匹配则返回-1 lastiIndexOf(char); 从右往左查找,返回匹配到的第一个 ...
- RPA - UiPath简明教程 ║ .NET的又一领域
RPA概念 RPA全称为:Robotic Process Automation,即机器人流程自动化. Robotic:这里的机器人是一个虚拟的概念,并不是需要一个实体的机器人,它只是流程的执行体,或者 ...
- css3 input placeholder颜色修改方法
css3 input placeholder颜色修改方法<pre> input::-webkit-input-placeholder { /* placeholder颜色 */ color ...
- php ffmpeg截取视频第一帧保存为图片的方法
php ffmpeg截取视频第一帧保存为图片的方法 <pre> $xiangmupath = $this->getxiangmupath(); $filename = 'chengs ...
- 模拟实现IoC容器
Spring的IoC核心就是控制反转,将对实现对象的操作控制器交出来,由IoC容器来管理,从配置文件中获取配置信息,Java对XML文档提供了完美的支持,dom4j功能强大,而下面我就用JDOM这一开 ...
- @Transactional 的回滚
默认情况下,Exception是不会引起回滚操作的,RuntimeException才会引起回滚操作. 当然如果所有的Exception都要回滚的话,直接@Transactional(rollback ...