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)检查 ...
随机推荐
- 汇编窥探Swift String的底层
String(字符串),是所有编程语言中非常重要的成员,因此非常值得去深入研究.众所周知,字符串的本质是字符序列,由若干个字符组成.比如字符串 "iOS" 由 'i'.'O'.'S ...
- Java编程思想——第14章 类型信息(一)
运行时类型信息使得你可以在程序运行时发现和使用类型信息.Java是如何让我们在运行时识别对象和类的信息得呢? 主要有两种方式:1.传统RTTI,他假定我们在编译期间已经知道了所有类型:2.反射,它允许 ...
- 学习笔记62_python文件操作
#使用 str = raw_input("输入密码:") 来获取键盘的输入 #创建或打开一个文件 fp = open("hellow.txt","w& ...
- nginx篇最初级用法之地址重写
nginx服务器的地址重写,主要用到的配置参数是rewrite rewrite regex replacement flag rewrite 旧地址 新地址 [选项] 支持的选项有: last 不再读 ...
- [考试反思]1006csp-s模拟测试62:隔断
本来说好的好一场烂一场. 那样的日子结束了,连着烂了两场...幸亏T3傻逼了救我一命不算太惨... T1树上的特殊性质会做但是没有继续想下去就死在错贪心上了还没有过那个点... T2迭代至稳定被我错误 ...
- ISCONF Redis is configured to save RDB snapshots
MISCONF Redis is configured to save RDB snapshots redis报错: (error) MISCONF Redis is configured to sa ...
- BigInt 的使用!
今天学长讲的卡特兰数真的是卡的一批,整个全是高精的题,这时我就使用重载运算符,然后一下午就过去了 首先来看一波水题(也就卡了2小时) . A. 网格 内存限制:512 MiB 时间限制:1000 ms ...
- [转载]1.1 UiPath下载安装与激活
一.UiPath下载 1.打开官网https://www.uipath.com.cn,点击开始试用 2.选择获取UiPath社区版 3.填写姓.名.电子邮箱地址.专业领域.职位.公司.公司所在行业.国 ...
- redis集群节点重启后恢复
服务器重启后,集群报错: [root@SHH-HQ-NHS11S nhsuser]# redis-cli -c -h ip -p 7000ip:7000> set cc dd(error) CL ...
- Linux定时任务 crontab(-l -e)、at、batch
1.周期性定时任务crontab cron['krɒn] 一时间单位 table crontab -e 进入编辑定时任务界面,每一行代表一个定时任务,#开头的行为注释行,一行分成6列 分钟 小时 日 ...