File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919#
2020
2121# You can set ConfigNode memory size, example '2G' or '2048M'
22- MEMORY_SIZE=
22+ # If the MEMORY_SIZE environment variable is already set, its value will be used.
23+ MEMORY_SIZE=${MEMORY_SIZE:- }
2324
2425# You can put your env variable here
2526# export JAVA_HOME=$JAVA_HOME
@@ -68,6 +69,24 @@ calculate_memory_sizes()
6869 case " ` uname` " in
6970 Linux)
7071 system_memory_in_mb=` free -m| sed -n ' 2p' | awk ' {print $2}' `
72+ # When running in a container/pod, use cgroup memory limit instead of host memory
73+ if [ -f /sys/fs/cgroup/memory.max ]; then
74+ # cgroup v2
75+ cgroup_mem=` cat /sys/fs/cgroup/memory.max`
76+ if [ " $cgroup_mem " != " max" ]; then
77+ cgroup_mem_in_mb=` expr $cgroup_mem / 1024 / 1024`
78+ if [ " $cgroup_mem_in_mb " -lt " $system_memory_in_mb " ]; then
79+ system_memory_in_mb=$cgroup_mem_in_mb
80+ fi
81+ fi
82+ elif [ -f /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
83+ # cgroup v1
84+ cgroup_mem=` cat /sys/fs/cgroup/memory/memory.limit_in_bytes`
85+ cgroup_mem_in_mb=` expr $cgroup_mem / 1024 / 1024`
86+ if [ " $cgroup_mem_in_mb " -lt " $system_memory_in_mb " ]; then
87+ system_memory_in_mb=$cgroup_mem_in_mb
88+ fi
89+ fi
7190 system_cpu_cores=` egrep -c ' processor([[:space:]]+):.*' /proc/cpuinfo`
7291 ;;
7392 FreeBSD)
Original file line number Diff line number Diff line change 1919#
2020
2121# You can set DataNode memory size, example '2G' or '2048M'
22- MEMORY_SIZE=
22+ # If the MEMORY_SIZE environment variable is already set, its value will be used.
23+ MEMORY_SIZE=${MEMORY_SIZE:- }
2324
2425
2526# You can put your env variable here
6566IOTDB_ALLOW_HEAP_DUMP=" true"
6667
6768calculate_memory_sizes ()
68- {
69+ {expr cat /sys/fs/cgroup/memory.max / 1024 / 1024
6970 case " ` uname` " in
7071 Linux)
7172 system_memory_in_mb=` free -m| sed -n ' 2p' | awk ' {print $2}' `
73+ # When running in a container/pod, use cgroup memory limit instead of host memory
74+ if [ -f /sys/fs/cgroup/memory.max ]; then
75+ # cgroup v2
76+ cgroup_mem=` cat /sys/fs/cgroup/memory.max`
77+ if [ " $cgroup_mem " != " max" ]; then
78+ cgroup_mem_in_mb=` expr $cgroup_mem / 1024 / 1024`
79+ if [ " $cgroup_mem_in_mb " -lt " $system_memory_in_mb " ]; then
80+ system_memory_in_mb=$cgroup_mem_in_mb
81+ fi
82+ fi
83+ elif [ -f /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
84+ # cgroup v1
85+ cgroup_mem=` cat /sys/fs/cgroup/memory/memory.limit_in_bytes`
86+ cgroup_mem_in_mb=` expr $cgroup_mem / 1024 / 1024`
87+ if [ " $cgroup_mem_in_mb " -lt " $system_memory_in_mb " ]; then
88+ system_memory_in_mb=$cgroup_mem_in_mb
89+ fi
90+ fi
7291 system_cpu_cores=` egrep -c ' processor([[:space:]]+):.*' /proc/cpuinfo`
7392 ;;
7493 FreeBSD)
Original file line number Diff line number Diff line change 2020@ echo off
2121
2222@ REM You can set datanode memory size, example '2G' or '2048M'
23- set MEMORY_SIZE =
23+ @ REM If the MEMORY_SIZE environment variable is already set, its value will be used.
24+ if not defined MEMORY_SIZE set MEMORY_SIZE =
2425
2526@ REM true or false
2627@ REM DO NOT FORGET TO MODIFY THE PASSWORD FOR SECURITY (%CONFIGNODE_CONF%\jmx.password and %{CONFIGNODE_CONF%\jmx.access)
Original file line number Diff line number Diff line change 2020@ echo off
2121
2222@ REM You can set datanode memory size, example '2G' or '2048M'
23- set MEMORY_SIZE =
23+ @ REM If the MEMORY_SIZE environment variable is already set, its value will be used.
24+ if not defined MEMORY_SIZE set MEMORY_SIZE =
2425
2526@ REM true or false
2627@ REM DO NOT FORGET TO MODIFY THE PASSWORD FOR SECURITY (%IOTDB_CONF%\jmx.password and %{IOTDB_CONF%\jmx.access)
You can’t perform that action at this time.
0 commit comments