#!/bin/bash
####################################################################################################################
###
### Descipt: this script help us to make a base optimization for system
### Author : HM
### Create : 2020-04-28
###
### Usage :
### ./optimize_system_conf.sh
###
####################################################################################################################
echo "This tool help use to make a base optimization for system"
echo ""
#1.optimize System configuration
optimizeSystemConf(){
conf_exist=$(cat /etc/sysctl.conf|grep kingbase|wc -l)
if [ $conf_exist -eq 0 ]; then
echo "optimize system core conf"
cat >> /etc/sysctl.conf <<EOF
#add by kingbase
# 操作系统信号量
kernel.sem = 50100 64128000 50100 1280
# 释放time_wait链接
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
# TCP端口使用范围
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_tw_buckets = 6000
# 记录的那些尚未收到客户端确认信息的连接请求的最大值
net.ipv4.tcp_max_syn_backlog = 65536
# 每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目
net.core.netdev_max_backlog = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_wmem = 8192 436600 873200
net.ipv4.tcp_rmem = 32768 436600 873200
net.ipv4.tcp_mem = 94500000 91500000 92700000
net.ipv4.tcp_max_orphans = 3276800
vm.swappiness=1
EOF
else
echo "system configuration is already optimized, so we do nothing"
fi
}
#1/2.Optimize Limit
optimizeLimitConf(){
conf_exist=$(cat /etc/security/limits.conf|grep kingbase|wc -l)
if [ $conf_exist -eq 0 ]; then
echo "optimize limit configuration"
cat >> /etc/security/limits.conf <<EOF
#add by kingbase
root soft core unlimited
root hard core unlimited
root soft nproc unlimited
root hard nproc unlimited
root soft nofile 300000
root hard nofile 300000
kingbase soft core unlimited
kingbase hard core unlimited
kingbase soft nproc unlimited
kingbase hard nproc unlimited
kingbase soft nofile 300000
kingbase hard nofile 300000
EOF
else
echo "limit is already optimized, so we do nothing"
fi
}
#main:
#1.optimize System configuration
echo "1.optimize system core configuration:"
optimizeSystemConf
sysctl -p >>/dev/null 2>&1
echo ""
#2.Optimize Limit
echo "2.optimize limit:"
optimizeLimitConf
echo ""
echo "3.check limit:"
su - kingbase -c 'ulimit -a'|grep 'open files'
echo ""
KIngbaseES操作系统参数优化脚本
最新推荐文章于 2024-08-31 21:24:29 发布