Linux 常规优化(centos 7)
1 yum源优化
yum -y install wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup &&\
curl -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
2 关闭selinux
sed -i.bak 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
getenforce
3 关闭firewalld(如果需要使用可不关闭)
#关闭firewalld centos7
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
4 设置英文字符集
#英文字符集
localectl set-locale LANG="en_US.UTF-8"
5 设置时间同步
yum install -y ntpdate
echo '#time sync by sysadmin at 2017-03-08' >>/var/spool/cron/root
echo '*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1' >>/var/spool/cron/root
crontab -l
6 优化系统文件描述符配置
[root@localhost ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7294
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 7294
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[root@localhost ~]#
[root@localhost ~]# ulimit -n
1024
ulimit -n 65535 重启后失效(临时)
#修改用户最大文件数及进程数 永久修改 重启失效
#vim /etc/security/limits.conf
* soft noproc 65535
* hard noproc 65535
* soft nofile 65535
* hard nofile 65535
[root@localhost ~]# ulimit -a|grep 'open files'
open files (-n) 65535
#修改系统级别的文件数
vim /etc/sysctl.conf
fs.nr_open = 9999999
fs.file-max = 9999999
7 优化ssh连接
#ssh连接速度慢优化
sed -i.bak 's@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config
systemctl restart sshd
网友评论