一、基础环境
1.服务器参数检查
(1)检查服务器版本及日期时间
①cat /etc/redhat-release
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 (Maipo)
②date
(2)检查服务器cpu、内存、磁盘参数
①lscpu
[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 1
②free -g
[root@localhost ~]# free -g
total used free shared buff/cache available
Mem: 15 0 15 0 0 14
Swap: 0 0 0
③df -h
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 12M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/rhel-root 29G 1.5G 28G 6% /
/dev/sda1 253M 131M 123M 52% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0
(3)修改基本参数
①修改主机名(每台)
[root@localhost ~]# vi /etc/hosts
10.150.5.184 DCPS_AFA184
[root@localhost ~]# vi /etc/hostname
DCPS_AFA184
[root@localhost ~]# service network restart
[root@localhost ~]# reboot
①关闭防火墙(每台)
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl status firewalld
②修改字符集
vi /etc/locale.conf
LANG=zh_CN.UTF-8
2.检查并修改内核参数
(1)检查内核参数
①ulimit -a
[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) 63373
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) 63373
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
(2)修改内核参数
①vi /etc/security/limits.conf
[root@localhost ~]# vi /etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* hard fsize 2097152
* hard stack 256000
* hard rss -1
* hard data 640000
test soft nproc 2048
test hard nproc 16384
test soft nofile 10240
test hard nofile 10240
test hard fsize 2097152
test hard stack 256000
test hard rss -1
test hard data 640000
②vi /etc/sysctl.conf
添加以下内容
#(8G*1024*1024/4)*4/10=838860
fs.file-max = 838860
fs.aio-max-nr = 1048576
kernel.core_uses_pid = 0
kernel.core_pattern = corefile/core-%e
kernel.sysrq = 1
#kernel.sem = 250 32000 100 128
#kernel.shmmax = 75474
#kernel.shmmni = 4096
#ESB参数
kernel.sem = 40960 5120000 40960 409600
kernel.shmall = 26843545600
kernel.shmmax = 429496729500
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_fin_timeout = 2
#net.ipv4.ip_conntrack_max = 20000
net.ipv4.ip_local_port_range = 3000 65500
注意:
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_timestamps = 1
这两个参数在某些情况不可同时打开,生产环境建议
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_timestamps = 0