按照道理,即使内存发生不够的情况,应该是磁盘读写变得更加激烈,而不是开始频繁的使用swap交换分区,沿着这个思路,寻找相关资
在一个新闻网站的后台数据库的监控过程中,经常出现数据库开始使用交换分区的情况,并进而导致整个应用系统响应非常缓慢,不能够提供服务。该服务器的内存为8G,SGA设置为4G,PGA设置为1G。操作系统为64位。
按照道理,即使内存发生不够的情况,应该是磁盘读写变得更加激烈,而不是开始频繁的使用swap交换分区,沿着这个思路,寻找相关资料,发现如果配置大内存页可以强行把SGA锁定到内存中,大内存页是不允许被交换的。而同时相关资料也说明,在内存比较大的情况下,当系统内存为8G以上时,如果不采用大内存页(2M),那么管理这些内存所需要的内存也会急剧增加。对于系统可以使用命令cat /proc/meminf查看PageTables项,由于没有采用大内存页管理而额外产生的内存消耗。
具体操作步骤:
1、查看系统内存
cat /proc/meminfo | grep MemTotal
MemTotal: 8177384 kB
2、查看SGA和PGA
SQL> show parameter sga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean TRUE
pre_page_sga boolean FALSE
sga_max_size big integer 4G
sga_target big integer 4G
SQL> show parameter pga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target big integer 1G
4、查看没有使用大内存页时的情况
more /proc/meminfo |grep -i HugePage
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 0
5、配置HugePages Pool大小
vi /etc/sysctl.conf
在最后添加如下的行
vm.nr_hugepages = 2300 #(这个值应大于或等于 SGA/2m,即 4*1024m/2m)
6、配置Oracle用户最大线程数、文件句柄和最大能锁定的内存
vi /etc/security/limits.conf
在最后添加如下的行
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft memlock 5194304 #(这里是以KB为单位,一般大于等于SGA)
oracle hard memlock 5194304
7、使配置生效
sysctl -p
8、重启系统及启动oracle实例,下面是我们使用大内存页后的结果,
看到因为管理内存页而额外需要的内存(PageTables)为55M
cat /proc/meminfo
MemTotal: 8177384 kB
MemFree: 950472 kB
Buffers: 16824 kB
Cached: 1365136 kB
SwapCached: 170652 kB
Active: 1274416 kB
Inactive: 1082156 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 8177384 kB
LowFree: 950472 kB
SwapTotal: 10420208 kB
SwapFree: 10056116 kB
Dirty: 148 kB
Writeback: 0 kB
AnonPages: 982112 kB
Mapped: 52944 kB
Slab: 64568 kB
PageTables: 55580 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 12153700 kB
Committed_AS: 2584964 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 267584 kB
VmallocChunk: 34359470407 kB
HugePages_Total: 2300
HugePages_Free: 264
HugePages_Rsvd: 13
Hugepagesize: 2048 kB
如上由于我们的系统数据库SGA为4G,因此配置了2300个大内存页,这样能够提供足够多的大内存页供数据库的SGA使用。配置大内存的一个另外好处是可以清楚的看到系统使用内存的情况,,否则Oracle会占用buffer及cache内存,很难计算系统空余的实际内存数量。
从内存meminfo信息中可以看出,2300个大内存页,被使用了2300-264=2036个(这个过程在启动数据库的时候是动态变化的,直到SGA用满)。
在配置的过程中,发现我们的系统内核还不支持大内存页,配置后看到HugePage_Total为0,说明配置无效,需要安装新的内核。大内存页的配置可以参考相关文档。
当配置完成后,同时设置lock_sga为true,Oracle数据库服务器再也不发生大量使用swap分区的情况了,不再出现性能故障。

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
