Chạy hugepages_settings.sh
Dấu # ở đầu dòng là ghi chú, giải thích (comments)
→ không phải code → bỏ qua khi chạy script.
#!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
# on Oracle Linux
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
# is an Oracle RDBMS shared memory segment or not.
#
# This script is provided by Doc ID 401749.1 from My Oracle Support
# http://support.oracle.com
# Welcome text
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support
(http://support.oracle.com) where it is intended to compute values for
the recommended HugePages/HugeTLB configuration for the current shared
memory segments on Oracle Linux. Before proceeding with the execution please note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating the overall size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And make sure that:
* Oracle Database instance(s) are up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not setup
(See Doc ID 749851.1)
* The shared memory segments can be listed by command:
# ipcs -m
Press Enter to proceed..."
read
# Check for the kernel version
KERN=`uname -r | awk -F. '{ printf("%d.%dn",$1,$2); }'`
# Find out the HugePage size
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
# Initialize the counter
NUM_PG=0
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
do
MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
if [ $MIN_PG -gt 0 ]; then
NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
fi
done
RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
# An SGA less than 100MB does not make sense
# Bail out if that is the case
if [ $RES_BYTES -lt 100000000 ]; then
echo "***********"
echo "** ERROR **"
echo "***********"
echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:
# ipcs -m
of a size that can match an Oracle Database SGA. Please make sure that:
* Oracle Database instance is up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not configured"
exit 1
fi
# Finish with results
case $KERN in
'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
'2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# DevSecOps.Edu.VN thêm vào
'5.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.15') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# END
*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
# End
Chạy hugepages_settings.sh ở chế độ DEBUG
Thêm dòng 16
+ comment nhiều dòng = : <<‘END_COMMENT’ … END_COMMENT
#!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
# on Oracle Linux
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
# is an Oracle RDBMS shared memory segment or not.
#
# This script is provided by Doc ID 401749.1 from My Oracle Support
# http://support.oracle.com
set -eux
# Welcome text
# Comment nhiều dòng
: <<'END_COMMENT'
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support
(http://support.oracle.com) where it is intended to compute values for
the recommended HugePages/HugeTLB configuration for the current shared
memory segments on Oracle Linux. Before proceeding with the execution please note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating the overall size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And make sure that:
* Oracle Database instance(s) are up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not setup
(See Doc ID 749851.1)
* The shared memory segments can be listed by command:
# ipcs -m
Press Enter to proceed..."
read
END_COMMENT
# Check for the kernel version
KERN=`uname -r | awk -F. '{ printf("%d.%dn",$1,$2); }'`
# Find out the HugePage size
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
# Initialize the counter
NUM_PG=0
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
do
MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
if [ $MIN_PG -gt 0 ]; then
NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
fi
done
RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
# An SGA less than 100MB does not make sense
# Bail out if that is the case
if [ $RES_BYTES -lt 100000000 ]; then
echo "***********"
echo "** ERROR **"
echo "***********"
echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:
# ipcs -m
of a size that can match an Oracle Database SGA. Please make sure that:
* Oracle Database instance is up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not configured"
exit 1
fi
# Finish with results
case $KERN in
'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
'2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# DevSecOps.Edu.VN thêm vào
'5.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.15') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# END
*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
# End
1. Chạy từng lệnh + show ra kết quả từng lệnh
KERN=`uname -r | awk -F. '{ printf("%d.%dn",$1,$2); }'`
echo $KERN
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
echo $HPG_SZ
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
echo $?
NUM_PG=0
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
do
echo $SEG_BYTES
MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
echo $MIN_PG
if [ $MIN_PG -gt 0 ]; then
NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
fi
echo $NUM_PG
done
echo $NUM_PG
RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
echo $RES_BYTES
if [ $RES_BYTES -lt 100000000 ]; then
echo "***********"
echo "** ERROR **"
echo "***********"
echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:
# ipcs -m
of a size that can match an Oracle Database SGA. Please make sure that:
* Oracle Database instance is up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not configured"
exit 1
fi
case $KERN in
'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
'2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# DevSecOps.Edu.VN thêm vào
'5.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.15') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# END
*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
2. Phân tích code dòng 17 – 35
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support
(http://support.oracle.com) where it is intended to compute values for
the recommended HugePages/HugeTLB configuration for the current shared
memory segments on Oracle Linux. Before proceeding with the execution please note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating the overall size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And make sure that:
* Oracle Database instance(s) are up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not setup
(See Doc ID 749851.1)
* The shared memory segments can be listed by command:
# ipcs -m
Press Enter to proceed..."
=
In ra màn hình các dòng chữ giải thích
3. Phân tích code dòng 37
read
= không lưu vào biến gì → chờ nhấn Enter → script chạy lệnh tiếp theo
Giải thích 2 cách xài read
# Tạo file script
# echo -e là echo đọc thấy n sẽ xuống hàng (new line)
echo -e '#!/bin/bashnecho -n "Nhập tên: "nread tennecho Tên = $tennnread -p "Nhập tuổi: " tuoinecho Tuổi = $tuoi' > read.sh
# Coi lại file script
# echo -n là echo in ra 1 chuỗi và con trỏ (cursor) nhấp nháy nằm ở cuối chuỗi
# --> echo k có -n sẽ xuống hàng
cat read.sh
#!/bin/bash
echo -n "Nhập tên: "
read ten
echo Tên = $ten
read -p "Nhập tuổi: " tuoi
echo Tuổi = $tuoi
# Chạy file script để coi 2 cách xài read
# --> read đọc nhập từ màn hình lưu vào các biến
bash read.sh
Nhập tên: DevSecOps.Edu.VN
Tên = DevSecOps.Edu.VN
Nhập tuổi: 3
Tuổi = 3
4. Phân tích code dòng 42
KERN=`uname -r | awk -F. '{ printf("%d.%dn",$1,$2); }'`
= Lấy kernel version lưu vào biến KERN
# Lấy kernel verison full
uname -r
# Lọc ra chỉ lấy 2 giá trị đầu
uname -r | awk -F. '{ printf("%d.%dn",$1,$2); }'
# In ra giá trị biến KERN
echo $KERN
# Cách khác
KERN1=`uname -r | awk -F. '{ print $1 "." $2 }'`
echo $KERN1
Cách xài hàm printf trong awk
https://www.gnu.org/software/gawk/manual/html_node/Printf-Examples.html
Giải thích awk lấy các cột
df -Th
df -Th | awk '{ print $3}'
df -Th | awk '{ print $7}'
df -Th | awk '{ print $8}'
5. Phân tích code dòng 45 – 49
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
= Lưu giá trị Huge page tính = KB vào biến HPG_SZ
grep Hugepagesize /proc/meminfo
grep Hugepagesize /proc/meminfo | awk '{print $2}'
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
echo $HPG_SZ
grep Hugepagesize /proc/meminfo | awk '{print $3}'
Nếu biến HPG_SZ không có giá trị gì thì hiện ra thông báo The hugepages may not be supported in the system where the script is being executed. + thoát khỏi script với giá trị là 1 (exit code, exit status, status code…)
https://www.gnu.org/software/bash/manual/bash.html#Bash-Conditional-Expressions
Giải thích rõ hơn về set exit status
→ chỉnh lại ở dòng 26 + dòng 29 file dưới
#!/bin/bash
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support
(http://support.oracle.com) where it is intended to compute values for
the recommended HugePages/HugeTLB configuration for the current shared
memory segments on Oracle Linux. Before proceeding with the execution please note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating the overall size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And make sure that:
* Oracle Database instance(s) are up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not setup
(See Doc ID 749851.1)
* The shared memory segments can be listed by command:
# ipcs -m
Press Enter to proceed..."
KERN=`uname -r | awk -F. '{ printf("%d.%dn",$1,$2); }'`
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
HPG_SZ=
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 99
fi
NUM_PG=0
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
do
MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
if [ $MIN_PG -gt 0 ]; then
NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
fi
done
RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
if [ $RES_BYTES -lt 100000000 ]; then
echo "***********"
echo "** ERROR **"
echo "***********"
echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:
# ipcs -m
of a size that can match an Oracle Database SGA. Please make sure that:
* Oracle Database instance is up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not configured"
exit 1
fi
case $KERN in
'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
'2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# DevSecOps.Edu.VN thêm vào
'5.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.15') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# END
*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
6. Phân tích code dòng 52 – 61
# Initialize the counter
NUM_PG=0
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
do
MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
if [ $MIN_PG -gt 0 ]; then
NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
fi
done
= Do các shared memory segment của lịnh ipcs -m tính bằng byte
→ cần đếm số trang Huge page → mỗi trang = 2 MB = 2*1024 KB = 2048 KB = 2048*1024 Byte = 2,097,152 Byte
7. Phân tích code dòng 63 – 79
RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
# An SGA less than 100MB does not make sense
# Bail out if that is the case
if [ $RES_BYTES -lt 100000000 ]; then
echo "***********"
echo "** ERROR **"
echo "***********"
echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:
# ipcs -m
of a size that can match an Oracle Database SGA. Please make sure that:
* Oracle Database instance is up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not configured"
exit 1
fi
=
Tính số trang Huge page ra số byte → nếu nhỏ hơn 100,000,000 byte thì báo lỗi như thông báo
8. Phân tích code dòng 80 – 95
case $KERN in
'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
'2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# DevSecOps.Edu.VN thêm vào
'5.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.15') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# END
*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
=
Oracle Linux 4/5/6 xài kernel 2.6…
https://public-yum.oracle.com/oracle-linux-4.html
→ để script biết đang chạy trên bản Oracle Linux 5/6/7/8 có kernel do Oracle tự build gọi là UEK (Unbreakable Enterprise Kernel)
+ kernel của RHEL gọi là RHCK (Red Hat Compatible Kernel)
→ các bản Linux khác như Ubuntu, Debian… có kernel khác thì script sẽ không hỗ trợ.
https://blogs.oracle.com/scoter/post/oracle-linux-and-unbreakable-enterprise-kernel-uek-releases
Giải Challenge LAB 02
Dòng 41 + dòng 45 + dòng 56
+ thay bc -q thành bc
→ bc chỉ hiển thị banner nếu chạy ở chế độ tương tác gõ lệnh bc trên terminal
→ lệnh bc tính toán biểu thức sau echo có hay k có -q cũng k hiển thị banner
#!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
# on Oracle Linux
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
# is an Oracle RDBMS shared memory segment or not.
#
# This script is provided by Doc ID 401749.1 from My Oracle Support
# http://support.oracle.com
# Welcome text
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support
(http://support.oracle.com) where it is intended to compute values for
the recommended HugePages/HugeTLB configuration for the current shared
memory segments on Oracle Linux. Before proceeding with the execution please note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating the overall size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And make sure that:
* Oracle Database instance(s) are up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not setup
(See Doc ID 749851.1)
* The shared memory segments can be listed by command:
# ipcs -m
Press Enter to proceed..."
# read
# Check for the kernel version
# KERN=`uname -r | awk -F. '{ printf("%d.%dn",$1,$2); }'`
KERN=`uname -r | cut -f1,2 -d.`
# Find out the HugePage size
# HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
HPG_SZ=`grep Hugepagesize /proc/meminfo | tr -s ' ' | cut -f2 -d' '`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
# Initialize the counter
NUM_PG=0
# Cumulative number of pages required to handle the running shared memory segments
# for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
for SEG_BYTES in `ipcs -m | awk '/^[0-9]/ {print $5}'`
do
# MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc`
if [ $MIN_PG -gt 0 ]; then
# NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc`
fi
done
# RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc`
# An SGA less than 100MB does not make sense
# Bail out if that is the case
if [ $RES_BYTES -lt 100000000 ]; then
echo "***********"
echo "** ERROR **"
echo "***********"
echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:
# ipcs -m
of a size that can match an Oracle Database SGA. Please make sure that:
* Oracle Database instance is up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not configured"
exit 1
fi
# Finish with results
case $KERN in
# '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc`;
echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
'2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# DevSecOps.Edu.VN thêm vào
'5.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.15') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
# END
*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
# End