Mục đích: Với Oracle Database chạy Linux Server từ 16GB SGA (mà chỉ cần >=8GB) thì nên sử dụng HugePages. Khi đó Oracle sẽ hoạt đọng hiệu quả hơn. Khi chúng ta cấu hình HugePage, Linux Kernel sẽ dùng page hớn (gọi là huge page). Thay vì 4K với Linux x86 và x86_64 hay 16 KB với IA64 chúng ta sẽ đặt 4 MB on x86, 2MB với x86_64 hay 256MB trên IA64. Page lớn hơn tức là hệ thống sẽ cần ít bảng quản lý page (page table) hơn, do đó việc ánh xạ giữa page table và block cần truy xuất.
Tuy nhiên giới hạn của Oracle là tính năng AMM (Automatic Memory Management) không hỗ trợ HugePages. Do đó AMM disable (memory_max_size = 0, memory_target=0) và thay bằng ASMM (Automatic Shared Memory Management), tức là cấu hình SGA_MAX_SIZE, SGA_TARGET.
Case study RAM 100GB/node
| Tham số | Khuyến nghị | Ghi chú |
|---|---|---|
| Physical Memory | 100GB | Theo từng node RAC |
| Oracle memory thiết kế | ~70GB | Chừa tối thiểu ~30% cho OS/Grid/ASM/cache/process khác theo khuyến nghị Oracle HugePages |
| SGA_TARGET | 60G | Đưa vào HugePages |
| SGA_MAX_SIZE | 60G | Bằng SGA_TARGET để dễ kiểm soát |
| PGA_AGGREGATE_TARGET | 10G | PGA là private memory, không nằm trong HugePages; Oracle mô tả đây là target aggregate PGA cho server process |
| PGA_AGGREGATE_LIMIT | 20G hoặc cao hơn theo PROCESSES | Mặc định tối thiểu thường là 200% PGA target; RAC còn tối thiểu 5MB × PROCESSES |
| hugepage_size | 2048 KB | Thường gặp trên Linux x86_64 |
| vm.nr_hugepages | 30800 | 60G / 2MB = 30720, cộng dư nhẹ |
| kernel.shmmax | 96636764160 | 90GB, đủ lớn hơn SGA |
| kernel.shmall | 23592960 | 90GB / 4096 |
| limits.conf memlock | 94371840 KB | 90GB; Oracle docs cho phép đặt cao hơn SGA requirement và ví dụ dùng ~90% RAM khi bật HugePages |
| USE_LARGE_PAGES | ONLY | Oracle khuyến nghị để đảm bảo hiệu năng ổn định |
| MEMORY_TARGET / MEMORY_MAX_TARGET | 0 | Không dùng AMM với HugePages |
Runbook triển khai
1. Kiểm tra trước khi thay đổi
free -g
grep Huge /proc/meminfo
getconf PAGE_SIZE
cat /sys/kernel/mm/transparent_hugepage/enabled
ulimit -l
show parameter memory_target
show parameter memory_max_target
show parameter sga
show parameter pga
show parameter use_large_pages
show parameter processes
Nếu PROCESSES > 4096, kiểm tra lại PGA_AGGREGATE_LIMIT vì RAC yêu cầu tối thiểu 5MB * PROCESSES.
2. Cấu hình Oracle memory
ALTER SYSTEM SET memory_target=0 SCOPE=SPFILE SID='*';
ALTER SYSTEM SET memory_max_target=0 SCOPE=SPFILE SID='*';
ALTER SYSTEM SET sga_target=60G SCOPE=SPFILE SID='*';
ALTER SYSTEM SET sga_max_size=60G SCOPE=SPFILE SID='*';
ALTER SYSTEM SET pga_aggregate_target=10G SCOPE=SPFILE SID='*';
ALTER SYSTEM SET pga_aggregate_limit=20G SCOPE=SPFILE SID='*';
ALTER SYSTEM SET use_large_pages=ONLY SCOPE=SPFILE SID='*';
3. Cấu hình kernel
Tạo file:
vi /etc/sysctl.d/97-oracle-memory.conf
Nội dung:
kernel.shmmax = 96636764160
kernel.shmall = 23592960
vm.nr_hugepages = 30800
Apply:
sysctl -p /etc/sysctl.d/97-oracle-memory.conf
4. Cấu hình limits.conf
vi /etc/security/limits.d/99-oracle-memlock.conf
Nội dung:
oracle soft memlock 94371840
oracle hard memlock 94371840
grid soft memlock 94371840
grid hard memlock 94371840
Đăng nhập lại user oracle/grid, kiểm tra:
su - oracle
ulimit -l
Kỳ vọng:
94371840
5. Disable THP cho Oracle 19c
Với Oracle 19c, nên dùng static HugePages cho toàn bộ SGA; Oracle blog mới cũng phân biệt rõ static HugePages cho SGA và THP chỉ nên theo khuyến nghị mới hơn từ 23ai/UEK mới.
cat /sys/kernel/mm/transparent_hugepage/enabled
Kỳ vọng với 19c truyền thống:
always madvise [never]
6. Restart rolling từng node RAC
srvctl stop instance -d <DB_UNIQUE_NAME> -i <INSTANCE_NAME>
srvctl start instance -d <DB_UNIQUE_NAME> -i <INSTANCE_NAME>
Làm từng node, không restart đồng loạt.
7. Kiểm tra sau triển khai
grep Huge /proc/meminfo
free -g
select inst_id, name, value
from gv$parameter
where name in (
'memory_target',
'memory_max_target',
'sga_target',
'sga_max_size',
'pga_aggregate_target',
'pga_aggregate_limit',
'use_large_pages'
)
order by inst_id, name;
Kiểm tra alert log phải thấy SGA dùng Large Pages/HugePages. Nếu DB không startup với USE_LARGE_PAGES=ONLY, nghĩa là HugePages hoặc memlock chưa đủ.
Kết luận: với RAM 100GB/node, cấu hình an toàn là SGA 60G, PGA target 10G, PGA limit 20G, HugePages 30800, memlock 90GB.
Ghi chú:
+ Khuyến nghị 0.7 là dùng 0.7ức là 70% RAM vật lý; 0.65 là dùng 65% RAM vật lý
+ SGA lấy làm tròn lên =ROUND(B2*C2*0.8,0) (80% memory với OLTP, DWH 50%)
+ shmmax (B) = C7*B7*1024*1024*1024 (90% RAM)
+ shmall=H/4096 (shmmax/shmmni)
+ hugepage=(D9*1024*1024/I9)+1 (SGA(MB)/2+1)
+ limits.conf (KB) =90%RAM
ĐỌC THÊM:
Hy vọng hữu ích cho bạn.
=============================
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành
hững chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí
kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile/Zalo: 0902912888
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile/Zalo: 0902912888
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội
=============================
Bí quyết thiết lập tham số hugepages cho CSDL Oracle trên Linux_Update 19/04/203, oracle tutorial, học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,sql tutorial, khóa học pl/sql tutorial, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail,oracle RAC, ASM, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, postgresql tutorial, mysql tutorial, mariadb tutorial, sql server tutorial, nosql, mongodb tutorial, oci, cloud, middleware tutorial, hoc solaris tutorial, hoc linux tutorial, hoc aix tutorial, unix tutorial, securecrt, xshell, mobaxterm, putty