Upload
yury-velikanov
View
4.086
Download
3
Tags:
Embed Size (px)
DESCRIPTION
This is one of my old presentations. I have presented it back in 2006. While most of the stuff is correct I do not exclude that it has some bugs. Let me know if you found any.
Citation preview
Copyright © 2005 TietoEnator Corporation
All Oracle DBAs have to know about Unix Memory Monitoring
2006-11-14
Copyright © 2004 TietoEnator Corporation
Example 1
Copyright © 2004 TietoEnator Corporation
Example 2
Copyright © 2004 TietoEnator Corporation
Example 3
Copyright © 2004 TietoEnator Corporation
Main questions …
Do I have a memory shortage ? How many memory is utilized currently ?
Why answers are not obvious?
Doesn't focus on particular Unix platform
Gives general idea of memory management
Copyright © 2004 TietoEnator Corporation
Content
Concepts of Unix memory management– Single process virtual address space & main components– Unix swap subsystem– Unix system memory components– Why it is difficult to say how many memory is utilized
Possible answers– Do I have a memory shortage ?– How many memory is utilized currently ?
Oracle & Memory utilization
Copyright © 2004 TietoEnator Corporation
00000000- 175MB -0AEA8000
0AEA8000- 849 MB-40000000
40000000- 256 MB -50000000
BFFE3000(1,75GB)
FFFFFFFF (1GB)
Single process virtual address space“Dream world”
TEXT (CODE)
TEXT Variable part
HEAP (PGA)
Dynamically loaded Libraries (CODE)
DLL Variable part
Shared Memory
Stack area +
0x00000000- 175MB -0x0AEA8000
0x0AEA8000- 849 MB-0x40000000
0x40000000- 256 MB -0x50000000
0xBFFE3000(1,75GB)
0xFFFFFFFF (1GB)
DEMOpmap
Copyright © 2004 TietoEnator Corporation
Single process virtual memory “Dream world”
Components order and size of memory regions are dependent on used platform and Oracle version
Main components– Text (constant/variable parts)
oracle – executable in case of client process– Heap
PGA – Program Global Area– Sort/Hash area– Program variables
– Libraries (constant/variable parts) OS/Oracle libraries Example: JVM libraries in case of java call within DB
– Shared Memory SGA (shared pool, buffers cache, etc)
– Stack area Each area have strict boundaries for current installation/configuration
Copyright © 2004 TietoEnator Corporation
00000000- 175MB -0AEA8000
0AEA8000- 849 MB-40000000
40000000- 256 MB -50000000
BFFE3000(1,75GB)
FFFFFFFF (1GB)
Single process virtual memory translation“Dream world” “Real World”
TEXT (CODE)
TEXT Variable part
HEAP (PGA)
Dynamically loaded Libraries (CODE)
DLL Variable part
Shared Memory
Stack area +
RAM on DB ServerRandom Access Memory
SWAP Space on disk
VM Translation
FS
Copyright © 2004 TietoEnator Corporation
Single process virtual memory translation
Single process see continues memory space
OS translate process space to physical locations
Some parts of virtual process space are shared across all running processes
– OS/Oracle code– SGA
Some memory areas are private for each process
Copyright © 2004 TietoEnator Corporation
Single process virtual address space
TEXT (CODE)
TEXT Variable part
HEAP (PGA)
Dynamically loaded Libraries (CODE)
DLL Variable part
Shared Memory
Stack area
One copy per server (R/O)
One copy per Instance (W)
One copy per process (W)
Copyright © 2004 TietoEnator Corporation
Main memory consumption areasStatic Code (R/O)Oracle executables
Runtime size is constant
Shared Memory (W)Oracle SGA
Runtime size is constant
Process Private Area (W)PGA
Runtime size is variable
Copyright © 2004 TietoEnator Corporation
RAM (size is limited)RAM (size is limited)
RAM utilization and swap subsystem “Real World”
Static Code (R/O)Oracle executablesConstant Size
Shared Memory (W)Oracle SGARuntime size is constant
……..
Process Private Area (W)PGARuntime size is variable
DiskDisk
SWAP Space FS
Swap Process Swap outSwap in
Copyright © 2004 TietoEnator Corporation
Swap subsystem
Allow processes to utilize more memory then available in the system Swap process swap out inactive parts of the memory
On some platforms OS reserve swap space at the time RAM area is allocated
– This is why Oracle recommends to create 2 times swap space then RAM installed on the server
– Because of that used Swap space can’t be used as general indicator of memory shortage
Intensive swap out-s is good indicator of memory shortage
Copyright © 2004 TietoEnator Corporation
RAM (size is limited)RAM (size is limited)
RAM utilization and swap subsystem “Real World”
Static Code (R/O)Oracle executablesConstant Size
Shared Memory (W)Oracle SGARuntime size is constant
……..
Process Private Area (W)PGARuntime size is variable
DiskDisk
SWAP Space FS
Swap Process Swap outSwap in
Copyright © 2004 TietoEnator Corporation
00000000- 175MB -0AEA8000
0AEA8000- 849 MB-40000000
40000000- 256 MB -50000000
BFFE3000(1,75GB)
FFFFFFFF (1GB)
Resident size of the process (RSS)
TEXT (CODE)
TEXT Variable part
HEAP (PGA)
Dynamically loaded Libraries (CODE)
DLL Variable part
Shared Memory
Stack area
RAMRAM
SWAPSWAP
or or
DISKDISK
or or
NOT NOT ALLOCATEDALLOCATED
Copyright © 2004 TietoEnator Corporation
Resident size of the process (RSS)
Copyright © 2004 TietoEnator Corporation
Resident size of the process (RSS)
00000000- 175MB -0AEA8000
0AEA8000- 849 MB-40000000
40000000- 256 MB -50000000
BFFE3000(1,75GB)
FFFFFFFF (1GB)
TEXT (CODE)
TEXT Variable part
HEAP (PGA)
Dynamically loaded Libraries (CODE)
DLL Variable part
Shared Memory
Stack area
RSS Part
VSIZE Part
Copyright © 2004 TietoEnator Corporation
How many memory utilized? [OS view]
OS Tools reflect different information on different platforms
In general ps, top and other utilities– doesn’t reflect Size of Process Private area correctly– Include shared parts of the process
We can’t get figure how many memory utilized by adding all RSS or VSIZE values
pmap like utility can be used (on single process basis)
Copyright © 2004 TietoEnator Corporation
Unix system memory componentsServer dedicated to run Oracle Instance
RAMRAMStatic Code (R/O)Oracle exeConstant Size
Shared Memory (W)Oracle SGARuntime size is constant
……..
Process Private Area (W)PGARuntime size is variable
File SystemBuffers
Kernel&
SystemProcesses
Copyright © 2004 TietoEnator Corporation
How many memory is free? [OS View]
Can we rely on free memory figure from top and others tools?
The file system cache uses all available free memory to buffer files on the file system
On most systems, the amount of free memory is almost zero
file system cache used memory freed first of all if there are memory shortage
Free memory figure doesn’t represent available memory in the system
Copyright © 2004 TietoEnator Corporation
Do I have a memory shortage ?
Free memory indicator– Because of file system cache almost useless– If free memory is close to 0 don’t worry
Swapping activities– One of the best OS level indicators – Swap out (so), Page out (po), Scan-rate (sr)
Copyright © 2004 TietoEnator Corporation
How many memory is utilized currently ?
Constant memory areas– Kernel & OS Processes– Static Code (executables & libraries)– Shared Memory (SGA)
Variable memory areas– File System Buffers (freed on demand)– Process Private Area (PGA)
RAMRAMStatic Code (R/O)Oracle exeConstant Size
Shared Memory (W)Oracle SGARuntime size is constant
……..
Process Private Area (W)PGARuntime size is variable
File SystemBuffers
Kernel&
SystemProcesses
Copyright © 2004 TietoEnator Corporation
How to see used PGA size? Easily can be retrieved from database
Tuned using DB parameters– pga_aggregate_target– sort_area_size/hash_area_size– SGA
Copyright © 2004 TietoEnator Corporation
Oracle & Memory utilization
In general Oracle doesn't return used memory back to OS Shared server configuration
– UGA located in shared pool PGA is NOT !– Single call runtime variables located in PGA
Background processes– Job processes– Parallel processes
SGA_MAX_SIZE– Oracle Reserves memory straight after instance startup
Oracle on 32bit platform– Can’t address more then 4GB memory – By default 1.7GB big SGA allowed, increase up to 2.7 GB (Note:200266.1)– Very Large Memory (VLM) up to 64GB (Note:260152.1)
Heapdump could be used to troubleshoot memory related problems– oradebug dump heapdump 5 (Note:174555.1)
Copyright © 2004 TietoEnator Corporation
Conclusion
Do I have a memory shortage ?– Free memory is not a good metric– Swap size not always good to consider– Swap outs is one reliable indicator
How many memory is utilized currently ?– Difficult to see from Unix side– Variable part could be retrieved from Oracle– There some problems to consider
Copyright © 2004 TietoEnator Corporation
Thank you for your attention …Q & A
Copyright © 2004 TietoEnator Corporation
Tools to calculate memory usage [OS View]
ipcs : Shared memory information
ipcs -m pmap : Memory map for a particular process
pmap <pid> [cat /proc/<pid>/maps] ps : Memory information for list of the processes
ps -u oraenv01 -o pid,vsize,rss,cmdtop top : General memory utilization information
top [cat /proc/meminfo] vmstat, sar : Swap activities indicators