新到linux服务器硬件配置检查项
摘要: 新到的linux服务器,在使用部署之前,建议通过如下文档所列项对服务器做一个最基本的软硬件配置检查,减少由于硬件或操作系统配置不当,引发后续问题或故障。我们曾经因为centos中linux内核版本、进程数配置、磁盘读写速度等方面问题,趟过几次坑。类型描述解决方法内核centos6.6,内核为4.0.1时,solr4.9+jdk
类型 | 描述 | 解决方法 |
内核 | centos6.6,内核为4.0.1时,solr4.9+jdk1.8.05启动异常,卡在solrcoreload。 | 升级至4.2.1或降级至2.6.3 |
进程 | tomcat无法创建新线程 | 修改tomcat所在用户的最大进程量为102400,参考【进程】节点修改 |
磁盘 | solr gc回收很慢,测试发现磁盘读速度非常慢,cpu中wa%时间消耗很多时候>4%,踢出应用后发现是raid5中一块磁盘掉了 | 替换服务器 |
一、linux版本及内核
#查看发行版本
cat /etc/redhat-release
#查看内核版本
cat /proc/version
#机器型号
/usr/sbin/dmidecode
二、cpu
#型号
cat /proc/cpuinfo | grep 'model name'| uniq
#物理cpu个数
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
#每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep "cpu cores"| uniq
#逻辑核心数
cat /proc/cpuinfo| grep "process"| wc -l
三、内存
#查看内存大小
free -g
四、磁盘
#连续写速度
time dd if=/dev/zero of=/1Gb.file bs=1024 count=1000000
正常值:sas>200M/s、ssd>400M/s,仅针对raid5
#连续读速度
time dd if=/1Gb.file of=/dev/zero bs=1024
#读速度
hdparm -Tt /dev/sda
/dev/sda:
Timing cached reads: 18208 MB in 2.00 seconds = 9119.31 MB/sec【缓存读取】
Timing buffered disk reads: 1590 MB in 3.00 seconds = 529.99 MB/sec【物理读取】
正常值:sas>300M/s、ssd>1000M/s,仅针对raid5
#当前读写速递
iostat -d 1 3
#规划检查
df -h
/dev/sda2 32G 3.5G 27G 12% /
tmpfs 127G 12K 127G 1% /dev/shm
/dev/sda1 488M 51M 402M 12% /boot
/dev/sda7 1.2T 30G 1.1T 3% /data
/dev/sda3 32G 17G 14G 55% /usr
/dev/sda5 32G 394M 30G 2% /var
五、网络
#配置路径
cat /etc/sysctl.conf
修改配置后执行sysctl -p立即生效
我们WebServer实体机配置如下:
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Disable netfilter on bridges.
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
net.netfilter.nf_conntrack_max = 6553600
net.netfilter.nf_conntrack_tcp_timeout_established = 120
#net.ipv4.netfilter.ip_conntrack_max = 655360
#net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180
net.ipv4.ip_local_port_range = 1025 65535
net.ipv4.tcp_max_syn_backlog = 2621440
net.ipv4.tcp_max_tw_buckets = 8000
#net.core.somaxconn = 262144
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 2621440
net.core.rmem_default = 33554432
net.core.wmem_default = 33554432
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.ipv4.tcp_rmem = 4096 87380 33554432
net.ipv4.tcp_wmem = 4096 87380 33554432
net.ipv4.tcp_mem = 94500000 915000000 927000000
#net.ipv4.conf.em1.arp_ignore = 1
#net.ipv4.conf.em1.arp_announce = 2
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_forward = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_time = 60
六、进程
#用户进程数量限制配置
cat /etc/security/limits.d/90-nproc.conf
#查看当前用户可用最大进程量
ulimit -u
#查看指定用户可用最大进程量
su -l solr -s /bin/bash -c 'ulimit -a'
看如下的两个参数配置
open files (-n) 102400
max user processes (-u) 102400
七、防火墙
#查看防火墙是否启动
service iptables status
#查强制访问控制
/usr/sbin/sestatus -v
SELINUX值=disabled
#修改位置
cat /etc/sysconfig/selinux
八、hostname
#查看hostname
hostname
九、遇到过的问题
服务器优化配置:
echo 9 >/proc/sys/net/ipv4/tcp_fin_timeout
echo 300
echo 10
echo 40
echo 3 >/proc/sys/vm/drop_caches
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 6291456 > /proc/sys/net/ipv4/route/max_size
echo 4294967295 >/proc/sys/kernel/shmmax
echo 536870912 >/proc/sys/net/core/rmem_max
echo 536870912 >/proc/sys/net/core/wmem_max
echo 536870912 >/proc/sys/net/core/rmem_default
echo 536870912 >/proc/sys/net/core/wmem_default
echo 65536 > /proc/sys/net/ipv4/udp_rmem_min
echo 65536 > /proc/sys/net/ipv4/udp_wmem_min
echo 8388608 12582912 16777216 >/proc/sys/net/ipv4/tcp_mem
echo 1532544 2043392 3065088
echo 5000 >/proc/sys/net/core/netdev_max_backlog
echo 9 >/proc/sys/net/ipv4/tcp_fin_timeout
echo 300
echo 10
echo 40
echo 3 >/proc/sys/vm/drop_caches
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 6291456 > /proc/sys/net/ipv4/route/max_size
iptables -A FORWARD -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1436 修改ms值,由于有些网页的路径mtu过小,导致有些网站打不开可以通过修改这个参数解决
vi /etc/sysctl.conf 然后刷下面的配置
net.netfilter.nf_conntrack_generic_timeout = 600
net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 120
net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 60
net.netfilter.nf_conntrack_tcp_timeout_established = 300
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_last_ack = 30
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close = 10
net.netfilter.nf_conntrack_tcp_timeout_max_retrans = 300
net.netfilter.nf_conntrack_tcp_timeout_unacknowledged = 300
net.netfilter.nf_conntrack_tcp_loose = 1
net.netfilter.nf_conntrack_tcp_be_liberal = 0
net.netfilter.nf_conntrack_tcp_max_retrans = 3
net.netfilter.nf_conntrack_udp_timeout = 30
net.netfilter.nf_conntrack_udp_timeout_stream = 180
net.netfilter.nf_conntrack_icmp_timeout = 30
net.netfilter.nf_conntrack_acct = 1
net.netfilter.nf_conntrack_max = 2000000
net.netfilter.nf_conntrack_count = 191289
net.netfilter.nf_conntrack_buckets = 2000896
net.netfilter.nf_conntrack_checksum = 1
net.netfilter.nf_conntrack_log_invalid = 0
net.netfilter.nf_conntrack_expect_max = 256
net.core.somaxconn = 128
net.ipv4.netfilter.ip_conntrack_generic_timeout = 600
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent = 120
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv = 60
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 300
net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60
net.ipv4.netfilter.ip_conntrack_tcp_timeout_last_ack = 30
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close = 10
net.ipv4.netfilter.ip_conntrack_tcp_timeout_max_retrans = 300
net.ipv4.netfilter.ip_conntrack_tcp_loose = 1
net.ipv4.netfilter.ip_conntrack_tcp_be_liberal = 0
net.ipv4.netfilter.ip_conntrack_tcp_max_retrans = 3
net.ipv4.netfilter.ip_conntrack_udp_timeout = 30
net.ipv4.netfilter.ip_conntrack_udp_timeout_stream = 180
net.ipv4.netfilter.ip_conntrack_icmp_timeout = 30
net.ipv4.netfilter.ip_conntrack_max = 2000000
net.ipv4.netfilter.ip_conntrack_count = 191274
net.ipv4.netfilter.ip_conntrack_buckets = 2000896
net.ipv4.netfilter.ip_conntrack_checksum = 1
net.ipv4.netfilter.ip_conntrack_log_invalid = 0
net.nf_conntrack_max = 2000000
sysctl -p
更多推荐
所有评论(0)