Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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?
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.
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
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.
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
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.
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.
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:
# top
press x
press b
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).
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.