######################################################################
#### function: Initialize system parameters
####author:danial_chen
####create date:2019-11-07
####modify date:2019-11-07
######################################################################
#/bin/bash
#useage: sh init_sys_parm.sh
pd=$PWD

## stop && disable firewalld ##
systemctl stop firewalld
systemctl disable firewalld

## edit /etc/sysctl.conf ##
echo "kernel.shmall = 2043878" >> /etc/sysctl.conf 
echo "kernel.shmmax = 8175512" >> /etc/sysctl.conf  
echo "kernel.shmmni = 4096"  >> /etc/sysctl.conf 
echo "kernel.sem = 250 32000 100 128"  >> /etc/sysctl.conf 
echo "fs.file-max = 65536"  >> /etc/sysctl.conf 
echo "net.ipv4.ip_local_port_range = 33000 65000"  >> /etc/sysctl.conf 
echo "net.core.rmem_default = 262144"  >> /etc/sysctl.conf 
echo "net.core.rmem_max = 262144"  >> /etc/sysctl.conf
echo "net.core.somaxconn = 2048"  >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144"  >> /etc/sysctl.conf
echo "net.core.wmem_max = 262144"  >> /etc/sysctl.conf
echo "net.ipv4.tcp_rmem = 262144"  >> /etc/sysctl.conf
echo "net.ipv4.tcp_wmem = 262144"  >> /etc/sysctl.conf

## ulimit settings ##
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf
echo "* soft nproc 65536"  >> /etc/security/limits.conf
echo "* hard nproc 65536"  >> /etc/security/limits.conf

sysctl -p

## install net-tools ##
rpm -Uvh $pd/*.rpm --nodeps --force

## echo install resault ##
echo "System parameters init success!"