Cenos7.5 system optimization after the newly installed

Source: Internet
Author: User

CenTos7.5 System Optimization

Change host Name

CENTOS7 has a new command to modify host names Hostnamectl

Hostnamectl set-hostname--static hostname vim/etc/hosts--finally add your IP and host name bindings

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
IP Host Name

Modify the NIC
Vim/etc/sysconfig/network-scripts/ifcfg-eth0--Network card name if not the same, find the corresponding file on the line
bootproto= "Static"
Name= "Eth0"
Device= "Eth0"
onboot= "Yes"
ipaddr=10.0.0.1
netmask=255.255.255.0
gateway=10.0.0.254
dns1=114.114.114.114
dns2=8.8.8.8

#关闭卸载firewalld
Systemctl Stop Firewalld.service
Systemctl Disable Firewalld.service
Yum Remove firewalld-y
Yum Install iptables-services-y #安装
Turn off SELinux
Temporary shutdown Setenforce 0

Sed-i 7s/enforcing/disabled//etc/selinux/config
View Getenforce

Kernel Optimizations

Vim/etc/sysctl.conf

#关闭ipv6

Net.ipv6.conf.all.disable_ipv6 = 1

Net.ipv6.conf.default.disable_ipv6 = 1

#避免放大 * * *

Net.ipv4.icmp_echo_ignore_broadcasts = 1

#开启恶意icmp错误消息保护

net.ipv4.icmp_ignore_bogus_error_responses = 1

#关闭路由转发

Net.ipv4.ip_forward = 0

net.ipv4.conf.all.send_redirects = 0

net.ipv4.conf.default.send_redirects = 0

#开启反向路径过滤

Net.ipv4.conf.all.rp_filter = 1

Net.ipv4.conf.default.rp_filter = 1

#处理无源路由的包

Net.ipv4.conf.all.accept_source_route = 0

Net.ipv4.conf.default.accept_source_route = 0

#关闭sysrq功能

KERNEL.SYSRQ = 0

#core文件名中添加pid作为扩展名

Kernel.core_uses_pid = 1

#开启SYN洪水 * * * protection

Net.ipv4.tcp_syncookies = 1

#修改消息队列长度

KERNEL.MSGMNB = 65536

Kernel.msgmax = 65536

#设置最大内存共享段大小bytes

Kernel.shmmax = 68719476736

Kernel.shmall = 4294967296

#timewait的数量, default 180000

Net.ipv4.tcp_max_tw_buckets = 6000

Net.ipv4.tcp_sack = 1

net.ipv4.tcp_window_scaling = 1

Net.core.wmem_default = 8388608

Net.core.rmem_default = 8388608

Net.core.rmem_max = 16777216

Net.core.wmem_max = 16777216

#每个网络接口接收数据包的速率比内核处理这些包的速率快时, the maximum number of packets that are allowed to be sent to the queue

Net.core.netdev_max_backlog = 262144

#限制仅仅是为了防止简单的DoS * * *

Net.ipv4.tcp_max_orphans = 3276800

#未收到客户端确认信息的连接请求的最大值

Net.ipv4.tcp_max_syn_backlog = 262144

Net.ipv4.tcp_timestamps = 0

The number of #内核放弃建立连接之前发送SYNACK packages

Net.ipv4.tcp_synack_retries = 1

The number of #内核放弃建立连接之前发送SYN packages

Net.ipv4.tcp_syn_retries = 1

#启用timewait Quick Recovery

Net.ipv4.tcp_tw_recycle = 1

#开启重用. Allow time-wait sockets to be re-used for new TCP connections

Net.ipv4.tcp_tw_reuse = 1

Net.ipv4.tcp_mem = 94500000 915000000 927000000

Net.ipv4.tcp_fin_timeout = 1

The frequency at which TCP sends keepalive messages when #当keepalive. The default is 2 hours.

Net.ipv4.tcp_keepalive_time = 30

#修改防火墙表大小, default 65536

#net. netfilter.nf_conntrack_max=655350

#net. netfilter.nf_conntrack_tcp_timeout_established=1200

#确保无人能修改路由表

net.ipv4.conf.all.accept_redirects = 0

net.ipv4.conf.default.accept_redirects = 0

net.ipv4.conf.all.secure_redirects = 0

net.ipv4.conf.default.secure_redirects = 0

DNS optimization (better to add a corresponding network vendor)

Vi/etc/resolv.conf
NameServer 8.8.8.8
NameServer 114.114.114.114
NameServer 4.2.2.2
NameServer 172.19.0.6

Tool 1

Yum Install wget vim Lrzsz

Installing the 163 source network source
cd/etc/yum.repos.d/
wget Http://mirrors.163.com/.help/CentOS7-Base-163.repo

Yum Clean All
Yum Makecache Fast
Installation tool resolves key issues
Cd/etc/pki/rpm-gpg
wget https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7

Common Tools 2 Installation

Yum install-y gcc cmake bzip2-devel curl-devel db4-devel libjpeg-devel libpng-devel freetype-devel libXpm-devel gmp-devel Libc-client-devel openldap-devel unixodbc-devel postgresql-devel sqlite-devel aspell-devel net-snmp-devel Libxslt-devel libxml2-devel pcre-devel mysql-devel pspell-devel libmemcached libmemcached-devel zlib-devel Tree htop Net-tools

Time synchronization

#yum Install NTP ntpdate-y--Installing NTP time synchronization related packages
#vim/etc/ntp.conf--Verify that the following time synchronization sources are in the configuration file
Server 0.rhel.pool.ntp.org Iburst
Server 1.rhel.pool.ntp.org Iburst
Server 2.rhel.pool.ntp.org Iburst
Server 3.rhel.pool.ntp.org Iburst
#systemctl Enable NTPD--Set the start-up automatically ntpd
#systemctl start NTPD--Start the NTPD service now
#date-Confirmation time is consistent with current time
#ntpdate 0.rhel.pool.ntp.org-If you have not synchronized successfully, you can use this command to manually sync
Ln-sf/usr/share/zoneinfo/asia/shanghai/etc/localtime #更改时区为上海

Increase the limit on the number of open files

Ulimit-n
Ulimit-a
Vi/etc/security/limits.conf
Last Added

    • Soft Nofile 1024000
    • Hard Nofile 1024000
      Hive-nofile 1024000
      Hive-nproc 1024000
User process Limits

Sed-i ' s#4096#65535#g '/etc/security/limits.d/20-nproc.conf #加大普通用户限制 can also be changed to unlimited
Egrep-v "^$|^#"/etc/security/limits.d/20-nproc.conf

    • Soft Nproc 65535
      Root Soft Nproc Unlimited
      Restart for settings to take effect
      Reboot
      That's about as much. Other updates later

Cenos7.5 system optimization after the newly installed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.