Oracle optimization articles + Linux system parameters (vm.min_free_kbytes)

Note: This article is a guidebook for beginners with Linux system parameters (vm.min_free_kbytes).
Tags: Linux parameters, Oracle optimization, vm.min_free_kbytes, memory management.
Note: There are advantages and disadvantages to the modification of parameters. Improper setting of this parameter may lead to the system Risks such as downtime.
Easy to learn: The unnecessary parts are deleted from the article, so that beginners can learn it at a glance.
Warm reminder: If you find something wrong with this article or have a better way of writing, please leave a message or private message. I will modify and optimize


★ Parameter brief description
The function of the Linux system parameter is to set a minimum memory space for the system kernel to use. If
the value is set too much, it will waste space, and if it is kept too small, it will cause system pressure.


★ Knowledge points
※ Purpose: Reasonable setting of this value will help the Linux system to reclaim memory more effectively.
※ Note: It is not recommended to set the environment for small memory (≤32GB), just keep the default.
※ Danger: Don't use the running environment Set up
※ There is a modification operation, not the original version
※ The unit of the vm.min_free_kbytes parameter is: KB
※ The memory water level
    min water level: the lower memory is reserved for kernel use; when the min is reached, the direct reclaim of the memory will be triggered.
    Low water level: more than min Higher, when the amount of memory available is less than low, it will trigger kswapd to reclaim memory.
    High water level: continue to sleep
※ Memory reclamation method
    direct reclaim: execute when the min water mark is
    triggered. kswapd reclaim: execute when the low water mark is triggered


★ Related scripts
※ Use the ROOT user to execute the following statement directly in the shell

MIN_FREE_KBYTES_SYSCTL=$(egrep ^vm.min_free_kbytes /etc/sysctl.conf | awk '{print $3}')
MIN_FREE_KBYTES_MEMORY=$(cat /proc/sys/vm/min_free_kbytes)
NUMA_NODE_COUNT=$(numactl --hardware | grep available: | awk '{print $2}')
TOTAL_MEMORY_KBYTES=$(free -k | awk '/Mem:/ {print $2}')
NUMA_BASED=$(( $NUMA_NODE_COUNT * 1048576 ))
MEMORY_BASED=$(( $TOTAL_MEMORY_KBYTES / 200 ))
if [[ $NUMA_BASED -ge $MEMORY_BASED ]]
then
  RECOMMEND_VALUE=$NUMA_BASED
else
  RECOMMEND_VALUE=$MEMORY_BASED
fi
OFFSET=$(echo $RECOMMEND_VALUE*.05 | bc | cut -d"." -f1)
LOWER_BOUND=$(echo $RECOMMEND_VALUE-$OFFSET | bc)
UPPER_BOUND=$(echo $RECOMMEND_VALUE+$OFFSET | bc)
if [[ $MIN_FREE_KBYTES_SYSCTL -ge LOWER_BOUND && $MIN_FREE_KBYTES_SYSCTL -le UPPER_BOUND ]]
then
  SYSCTL_IN_RANGE=YES
else
  SYSCTL_IN_RANGE=NO
fi
#sysctl in range?
if [[ $MIN_FREE_KBYTES_MEMORY -ge LOWER_BOUND && $MIN_FREE_KBYTES_MEMORY -le UPPER_BOUND ]]
then
  MEMORY_IN_RANGE=YES
else
  MEMORY_IN_RANGE=NO
fi
DETAIL=$(
echo -e "Total Memory:       $TOTAL_MEMORY_KBYTES";
echo -e "NUMA node count:    $NUMA_NODE_COUNT";
echo -e "NUMA calculated:    $NUMA_BASED";
echo -e "memory calculated:  $MEMORY_BASED";
echo -e "recommended value:  $RECOMMEND_VALUE";
echo -e "permitted range:    $LOWER_BOUND to $UPPER_BOUND";
echo -e "in sysctl.conf:     $MIN_FREE_KBYTES_SYSCTL";
echo -e "sysctl in range?:   $SYSCTL_IN_RANGE";
echo -e "in active memory:   $MIN_FREE_KBYTES_MEMORY";
echo -e "memory in range?:   $MEMORY_IN_RANGE";
)
if [[ $SYSCTL_IN_RANGE = YES && $MEMORY_IN_RANGE = YES ]]
then
  echo -e "SUCCESS: vm.min_free_kbytes is configured as recommended.  Details:\n\n$DETAIL"
elif [[ $MIN_FREE_KBYTES_SYSCTL -lt $LOWER_BOUND || $MIN_FREE_KBYTES_MEMORY -lt $LOWER_BOUND ]]
then
  echo -e ":: Result : 【FAILURE】: vm.min_free_kbytes is not configured as recommended"
    ZZT_V1=$(( $NUMA_NODE_COUNT * 1 * 1024 * 1024 ))
    ZZT_V2=$(( $TOTAL_MEMORY_KBYTES * 5 /10 / 100 ))
    if [ $ZZT_V1 -gt $ZZT_V2 ]
    then 
    ZZT_MAX=$ZZT_V1 
    else 
    ZZT_MAX=$ZZT_V2 
    fi
    ZZT_MAX_GB=$(($ZZT_MAX/1024/1024))
  echo ">>> if output is <FAILURE>,please vi sysctl.conf and edit param's value for:vm.min_free_kbytes and reboot"
  echo ">>> [formula_oracle]vm.min_free_kbytes value (Kb) =MAX(1GB * number_numa_nodes, 0.5% * total_memory) "
  echo ">>> [calculated_zzt]vm.min_free_kbytes = $ZZT_MAX   (About: $ZZT_MAX_GB GB)"
    ZZT_V3=32
    ZZT_V4=$(($TOTAL_MEMORY_KBYTES/1024/1024))
    if [ $ZZT_V4 -gt $ZZT_V3 ]
    then 
        echo ">>> [PASS]The current memory is suitable for setting system parameters." 
    else 
        echo ">>> [WARN]Your memory is too small to set this parameter."
    fi
  echo -e "Details:\n\n$DETAIL"
elif  [[ $MIN_FREE_KBYTES_SYSCTL -gt $UPPER_BOUND && $MIN_FREE_KBYTES_MEMORY -gt $UPPER_BOUND ]]
then
  echo -e "WARNING: vm.min_free_kbytes is not configured as recommended.  Details:\n\n$DETAIL"
else
  echo -e "ERROR: Inconsistent results.  Details:\n\n$DETAILS"
fi


 


★ Case

 


※ If you think the article is well written, don’t forget to give the author a thumbs up at the end of the article~

over

Guess you like

Origin blog.csdn.net/zzt_2009/article/details/111436334