Get Hand's on Training on 10G RAC / Backup & Recovery / Standby / 10G ASM / Oracle 11i Apps call @ 9958874333 mail: anup@indiandba.com visit : http://www.indiandba.com/
What is swap space?
Swap space is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the physical memory is full, inactive pages in memory are moved to the swap space.
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
Nota:
Swap space on disk is used to hold pages of memory that have been paged or swapped out. A shortage of swap space may cause symptoms such as system hanging, poor response times, and unsuccessful spawning of new processes.
Can we consider for replacement of RAM?
While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
What is the recommended swap size system requirement?
Two to three times the amount of Physical Memory for Swap space (unless the system exceeds 1 GB of Physical Memory, where two times the amount of Physical Memory for Swap space is sufficient)
What the difference between swapping and paging?
Swapping is one of the Unix mechanisms to accommodate the size limitation of memory by moving entire processes to disk to reclaim memory.
Paging is another Unix machanism to manage the limitations of memory. Unlike swapping, where entire processes are moved in and out of memory, paging moves only individual pages of processes to disk. Paging is not as serious a problem as swapping, as the entire program does not have to reside in memory to run. A small amount of paging may not noticeably affect the performance of a system. However, the performance of a system may degraderapidly as paging activity increases.
What's a swap file?
In some situations it's difficult to add a new swap partition. Linux doesn't allow changing partition definitions and if we cannot add new partitions without dropping existing partitions. In this case swapfiles may be helpful.
Is it possible to resize a swap partition?
Linux doesn't allow changing partiton defintions without removing a partition and destroying all data stored on this partition.
How to Monitoring Swap Resources?
On Solaris:
# swap -l
swapfile dev swaplo blocks free
/swap/swapfile - 16 4194288 4194288
# swap -s
total: 4102472k bytes allocated + 702696k reserved = 4805168k used, 2258760k available
On Linux:
# /sbin/swapon –s
We can also check using "cat /proc/swaps" file.
Recommendation:
Swap usage may slowly increase as shown above but should stop at some point. If swap usage continues to grow steadily or is already large, then one of the following choices may need to be considered:
- Add more RAM or reduce the size of the SGA
- Increase the size of the swap space
If you see constant swapping, then you need to either add more RAM or reduce the size of the SGA. Constant swapping should be avoided at all cost. You can check current swap activity using the following commands:
$ vmstat 3 100
How to Add Swap Partaion?
On Solaris:
Step 1: Use the swap –a command to add additional area.
# swap -a /dev/dsk/c1t0d0s3
Step 2: Add a swap slice in /etc/vfstab file
# vi /etc/vfstab
Add the following line to create the swap slice.
/dev/dsk/c1t0d0s3 --swap -no -
Note – When the system is subsequently rebooted, the new swap slice /dev/dsk/c1t0d0s3 will be automatically included as part of the swap space as a result of adding the entry to the /etc/vfstab file.
On Linux:
Step 1: Use the command mkswap to setup the swap partition. At a shell prompt as root, type the following:
# /sbin/mkswap /dev/hdb2
Step 2: To enable the swap partition immediately, type the following command:
swapon /dev/hdb2
Step 3 To enable it at boot time, edit /etc/fstab to include:
/dev/hdb2 swap swap defaults 0 0
The next time the system boots, it will enable the new swap partition. After adding the new swap partition and enabling it, make sure it is enabled by viewing the output of the command
cat /proc/swaps or /proc/free.
How to add a swap file?
On Solaris:
Step 1: Create a swap file named swapfile in the partition that have enough free space, for example /export/data directory.
# mkfile 1000m /export/data/swapfile
Step 2: Add the swap file to the system’s swap space.
# swap -a /export/data/swapfile
Step 3: Check the details of the modified system swap space with swap -l and swap -s command.
Step 4: To use a swap file when the system is subsequently rebooted, add an entry for the swap file in the /etc/vfstab file.
# vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot opt
/export/data/swapfile --swap -no -
On Linux:
Step 1: Determine the size of the new swap file and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.
At a shell prompt as root, type the following command with count being equal to the desired block size:
# mkdir /data2
# dd if=/dev/zero of=/data2/swapfile1 bs=1024 count=65536
Step 2: Setup the swap file with the command:
# /sbin/mkswap /data2/swapfile1
Step 3: To enable the swap file immediately but not automatically at boot time:
# /sbin/swapon /data2/swapfile1
Step 4: To enable it at boot time, edit /etc/fstab to include:
# /data2/swapfile1 swap swap defaults 0 0
The next time the system boots, it will enable the new swap file.
How to remove swap partition?
On Solaris:
Step 1: Delete a swap slice from the current swap configuration.
# swap -d /dev/dsk/c1t0d0s3
Step 2: To prevent the swap slice from being configured as part of the swap configuration during a reboot or change of run level, edit the /etc/vfstab file, and remove the swap slice entry from the file.
On Linux:
At a shell prompt as root, execute the following command to make sure the swap partition is disabled (where /dev/hdb2 is the swap partition):
# swapoff /dev/hdb2
Remove its entry from /etc/fstab.
Remove the partition using parted or fdisk.
How to remove swap file?
On Solaris:
Delete a swap file from the current swap configuration.
# swap -d /export/data/swapfile
Remove the file to free the disk space that it is occupying.
# rm /export/data/swapfile
To prevent the swap file from being configured as part of the swap configuration during a reboot or change of run level, edit the /etc/vfstab file, and remove the swap file entry.
Note – The output of the df -h /export/data/swapfile command shows the space in use until you remove the swap file.
At a shell prompt as root, execute the following command to disable the swap file (where /swapfile1 is the swap file):
# swapoff /data2/swapfile1
Remove its entry from /etc/fstab.
Remove the actual file:
# rm /data2/swapfile1
Remove its entry from /etc/fstab.
How to get paging/Swap information?
# vmstat 5 5
The first column in /proc/stat shows the page-in counter and the second the number page-out counter. Check the numbers in intervals to get information about the paging activity.
# grep swap /proc/stat or vmstat
The first column in /proc/stat shows the swap-in counter and the second is the number swap-out counter. Check the numbers in intervals to get information about the swapping activity.
Click Here for download complate documnet.
Post a Comment