新服务器基本配置流程

1.不会使用selinux前,关闭selinux, /etc/selinux/config 2.重启,生效selinux配置,没关闭selinux前,别做任何配置,重启,如果无法启动进入维护模式修复/etc/selinux/config配置文件即可 3.配置网络相关,关闭firewalld,开启iptables,喜欢用firewalld也可以用firewalld,具体规则根据业务配置 yum install -y iptables-services.x86_64 iptables -F iptables-save > /etc/sysconfig/iptables systemctl enable iptables.service systemctl restart iptables.service iptables -L -v -n 如果没有yum源可以用这种方式 echo 'iptables-restore < /etc/sysconfig/iptables' > /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local 4.开启ssh 5.修改系统配置文件 vi /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 net.ipv4.tcp_keepalive_intvl=75 net.ipv4.tcp_keepalive_probes=3 vm.max_map_count=262144

net.ipv4.tcp_syncookies = 1

表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭;

net.ipv4.tcp_tw_reuse = 1

表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭;

net.ipv4.tcp_tw_recycle = 1

表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。

net.ipv4.tcp_fin_timeout=60

修改系默认的 TIMEOUT 时间

net.ipv4.tcp_keepalive_time = 1200

表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟。

net.ipv4.ip_local_port_range = 1024 65000

表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为1024到65000。

net.ipv4.tcp_max_syn_backlog = 8192

表示SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数。

net.ipv4.tcp_max_tw_buckets = 5000

表示系统同时保持TIME_WAIT套接字的最大数量,如果超过这个数字,TIME_WAIT套接字将立刻被清除并打印警告信息。默认为180000,改为5000。对于Apache、Nginx等服务器,上几行的参数可以很好地减少TIME_WAIT套接字数量,但是对于 Squid,效果却不>大。此项参数可以控制TIME_WAIT套接字的最大>数量,避免Squid服务器被大量的TIME_WAIT套接字拖死

vi /etc/security/limits.conf

root soft memlock unlimited
root hard memlock unlimited
root soft nofile 655350
root hard nofile 655350

root soft memlock unlimited
root hard memlock unlimited
root soft nofile 655350
root hard nofile 655350

* soft nproc 11000
* hard nproc 11000
* soft nofile 655350
* hard nofile 655350

6.修改时间,时区,是写进bios,主板电池得有电,重启不会掉时间,条件允许可以挂ntp timedatectl set-ntp 0 timedatectl set-time 2021-12-27 timedatectl set-time 14:02:40 timedatectl set-timezone Asia/Shanghai timedatectl set-local-rtc 1 hwclock --systohc --localtime clock -w timedatectl set-ntp 1

7.挂载分区 视情况而定,看看分区是2T,还是大于2T 文档:【2.1.1.12】centos7挂载新硬盘与超过2... 链接:http://note.youdao.com/noteshare?id=dca68686e59b8b426f9f8cbdac9f53c3&sub=493763BF341C44FF97553D7CA104B419

8.搭建基础服务