美文网首页
linux 系统部分优化(centos 7)

linux 系统部分优化(centos 7)

作者: 相信奇迹德人 | 来源:发表于2020-12-27 20:19 被阅读0次

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

相关文章

网友评论

      本文标题:linux 系统部分优化(centos 7)

      本文链接:https://www.haomeiwen.com/subject/nfcanktx.html