LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-17-2008, 10:33 PM   #1
web_janitor
LQ Newbie
 
Registered: Nov 2008
Location: USA
Distribution: rhell 4/5
Posts: 18

Rep: Reputation: 1
swapoff dangers?


I want to resize my swap partition but wonder if there is a danger when doing this "live" instead of single-user mode. Here's the puzzle:

One of my systems is running an Oracle 11G database server and a JBoss app server. Despite having 4 GB of RAM, I received intermittent complaints about performance which I attributed to swapping. I discovered that the swap space was set to 12 GB.

I want to reduce the swap space to a more reasonable 3 GB. By running a "free -m" command, I see that 3.6 GB of RAM is in use, 40 megabytes are free, and 2.2 GB of swap space is in use. Through the last number, we see the swap space is in use.

If I run "swapoff" - while the system is in use - can there be any adverse effects? After running "swapoff", I plan to reduce the swap partition to 3 GB. Then I will have to run "mkswap" and turn it back on via "swapon"

Elsewhere on the web, someone theorized that running "swapoff" will 'push' the swapped pages back into RAM. In my situation, there is no space to hold the extra pages.

I am curious as to whether there could be side effects to turning off swap and thus losing the contents of the swap. Can anyone speak into this subject?

Thanks in advance for insights! I'm a total noob to sys admin work, but eagerly learning the ropes.
 
Old 11-17-2008, 10:44 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,058

Rep: Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971
That sounds odd - do this first and post the result
Code:
swapon -s
(despite it's name, merely gives the status)
 
Old 11-17-2008, 10:44 PM   #3
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
If swap is actively being used, yes, it might cause unforeseen problems. If all of it is cached though, I wouldn't worry as much and it should be safe. I'd suggest on an Oracle box to at least the size of your memory total, so 4GB swap should be sufficient but from my understanding, Oracle wants at least 6GB of usable swap space. The safest bet is to get some downtime, shut off most services, turn off swap, resize, then restart all the services you need running.

I'd also suggest if swap is actively being used, it most likely is a good time to increase the physical memory if possible.

My personal suggestion though, turn off services including oracle, resize swap to 6GB, restart and monitor server usage. And think about getting more memory.

Is there really a need to reduce the size of swap? Are you running out of physical space you need elsewhere?
 
Old 11-17-2008, 10:47 PM   #4
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
Honestly if this is just to resize swap cause you think that's what's causing the sluggishness, then reducing the size of swap won't solve your problem. Get more memory instead or maybe put the JBoss services on another machine. In my experience, we always dedicate Oracle to it's own machine for best performance.
 
Old 11-17-2008, 11:02 PM   #5
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,469

Rep: Reputation: 154Reputation: 154
Quote:
Originally Posted by web_janitor View Post

If I run "swapoff" - while the system is in use - can there be any adverse effects? After running "swapoff", I plan to reduce the swap partition to 3 GB. Then I will have to run "mkswap" and turn it back on via "swapon"
This should work with no problems. I have done similar things in the past.


Quote:
Originally Posted by web_janitor View Post

One of my systems is running an Oracle 11G database server and a JBoss app server. Despite having 4 GB of RAM, I received intermittent complaints about performance which I attributed to swapping. I discovered that the swap space was set to 12 GB.
The act of paging is in itself the problem if you are having problems with the swap partition. Messing with the swap partition size is irrelevant to solving the problem. Either add more RAM or cut down on memory demand to the point where the system stops using the swap partition.

-----------------------
Steve Stites

P.S. Check your Oracle and JBoss configurations to see how much memory you have allowed them to use for buffers. If you make the buffer pools larger than the available free RAM then your middleware may push you into a paging situation by trying to efficiently use more RAM than actually exists.

Last edited by jailbait; 11-17-2008 at 11:07 PM.
 
Old 11-17-2008, 11:03 PM   #6
web_janitor
LQ Newbie
 
Registered: Nov 2008
Location: USA
Distribution: rhell 4/5
Posts: 18

Original Poster
Rep: Reputation: 1
Here are the results of swapon -s:
Code:
Filename                                Type            Size    Used    Priority
/dev/mapper/VolGrp1-swap                partition       12582904        2208956 -1
As you can see, 2208956 used (2.1 GB), 12582904 total (12 GB)
 
Old 11-17-2008, 11:16 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,058

Rep: Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971Reputation: 971
Didn't notice you were running RHEL - ignore my concerns. See other comments above.
 
Old 11-17-2008, 11:17 PM   #8
web_janitor
LQ Newbie
 
Registered: Nov 2008
Location: USA
Distribution: rhell 4/5
Posts: 18

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by trickykid View Post
Honestly if this is just to resize swap cause you think that's what's causing the sluggishness, then reducing the size of swap won't solve your problem. Get more memory instead or maybe put the JBoss services on another machine. In my experience, we always dedicate Oracle to it's own machine for best performance.
Thanks for the reply. As a side note, this was part of a test to see how well this new system stacked up against its previous incarnation. Previously, the system was running a 32-bit Red Hat Enterprise Linux 4 OS with 4 GB of RAM and Oracle 10G with JBoss. Nobody complained about performance. We wiped out the system, installed RHEL 5 64-bit, and migrated to Oracle 11G.

We wanted to see if users would notice anything despite being unaware of the changes.

I did see that on the old system the swap partition was 3 GB, whereas the new system was 12 GB. Using "sar", I saw that the several periods of complaints coincided with high levels of swapping.

Fortunately this is not a production system and the performance is somewhat acceptable. But it still bugs me a little that performance is noticeably worse than before. I all about making things faster, stronger, and better
 
Old 11-17-2008, 11:23 PM   #9
web_janitor
LQ Newbie
 
Registered: Nov 2008
Location: USA
Distribution: rhell 4/5
Posts: 18

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by jailbait View Post
This should work with no problems. I have done similar things in the past.




The act of paging is in itself the problem if you are having problems with the swap partition. Messing with the swap partition size is irrelevant to solving the problem. Either add more RAM or cut down on memory demand to the point where the system stops using the swap partition.

-----------------------
Steve Stites

P.S. Check your Oracle and JBoss configurations to see how much memory you have allowed them to use for buffers. If you make the buffer pools larger than the available free RAM then your middleware may push you into a paging situation by trying to efficiently use more RAM than actually exists.
Glad to hear that. This leads me to another question: how does one cut down on memory demand? A comprehensive answer is not needed (unless you want); feel free to suggest other resources you can recommend. I interpret this to mean that I should minimize as many unnecessary services as possible, although I'm not sure if you mean more than that.

I will also check on your last comment about buffer pools.
 
Old 11-18-2008, 12:59 PM   #10
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,469

Rep: Reputation: 154Reputation: 154
Quote:
Originally Posted by web_janitor View Post

Glad to hear that. This leads me to another question: how does one cut down on memory demand?
Some programs are configurable as to how much memory they use. Some browsers let you set the amount of cache to keep in memory. Many data bases allow you to configure their buffer pools.

You can choose which programs to run based on their size. Abiword is smaller than Open Office. XFCE is smaller than gnome or KDE. The command line version of a program is usually smaller than the GUI version. Programs that have binary executables are usually smaller and faster than programs which run interpreted.

You can compile your own kernel and leave out kernel modules that you don't need. You can change your startup scripts to not start daemons that you do not use.

You can also load balance. Move things which are not time critical such as backups to non-peak usage times.

---------------------
Steve Stites

Last edited by jailbait; 11-18-2008 at 01:15 PM.
 
Old 11-18-2008, 02:48 PM   #11
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
One thing I'd mention (hopefully I did not overlook it in the thread) is that if you turn swap off, and you run out of RAM while it's off, you're going to crash your server. Not good.

You have the right idea by keeping an eye on trends with sar. It sounds like you've identified this as a RAM issue, so: get more RAM.

My favorite way to quickly determine what's eating up RAM:
  1. # top
  2. press x
  3. press b
  4. press > until %MEM is the highlighted column

Also check/highlight RES to see what is actively using RAM. Note that you can also filter by process user (owner).
 
Old 11-19-2008, 09:31 AM   #12
Hern_28
Member
 
Registered: Mar 2007
Location: North Carolina
Distribution: Slackware 12.0, Gentoo, LFS, Debian, Kubuntu.
Posts: 906

Rep: Reputation: 38
swapfile

Create a swapfile and you can keep your system running and resize your partition. You could also create a swapfiles of varying sizes and test your server live to see if this is actually causing your problem by disabling your main swap space. Would not even require a shutdown.

Last edited by Hern_28; 11-19-2008 at 09:36 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dangers of Lenny? jmite Debian 3 08-08-2008 08:16 PM
LXer: Swapoff Performance LXer Syndicated Linux News 0 09-10-2007 10:00 PM
repartitioning; how? and dangers? andrewf8 Linux - Newbie 4 01-07-2006 01:09 AM
RH9 - Swapoff /dev/hda3 - segmentation failure cobrichka Red Hat 1 12-30-2003 06:03 AM
swapoff problems with gentoo starquake Linux - Newbie 1 04-17-2003 03:00 AM


All times are GMT -5. The time now is 06:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration