380 lines
7.3 KiB
HTML
380 lines
7.3 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>The buffermem parameters</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.60"><LINK
|
|
REL="HOME"
|
|
TITLE="Securing and Optimizing Linux"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Linux General Optimization"
|
|
HREF="gen-optim.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="The bdflush parameters"
|
|
HREF="chap6sec68.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="The ip_local_port_range parameters"
|
|
HREF="chap6sec70.html"></HEAD
|
|
><BODY
|
|
CLASS="section"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Securing and Optimizing Linux: RedHat Edition -A Hands on Guide</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="chap6sec68.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 6. Linux General Optimization</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="chap6sec70.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H1
|
|
CLASS="section"
|
|
><A
|
|
NAME="AEN4592"
|
|
>6.6. The buffermem parameters</A
|
|
></H1
|
|
><P
|
|
> The buffermem file is also closely related to the operation of the virtual memory <SPAN
|
|
CLASS="acronym"
|
|
>VM</SPAN
|
|
> subsystem of the Linux kernel. The value in this
|
|
file <TT
|
|
CLASS="filename"
|
|
>/proc/sys/vm/buffermem</TT
|
|
> controls how much memory should be used for buffer memory in percentage. It is important to note that the percentage
|
|
is calculated as a percentage of total system memory.
|
|
</P
|
|
><P
|
|
> The default setup for the buffermem parameters under Red Hat Linux is:
|
|
<TT
|
|
CLASS="computeroutput"
|
|
>"2 10 60"</TT
|
|
>
|
|
<DIV
|
|
CLASS="mediaobject"
|
|
><P
|
|
><IMG
|
|
SRC="images/Version6.1.gif"
|
|
ALT="Version 6.1 only"
|
|
></IMG
|
|
></P
|
|
></DIV
|
|
>
|
|
To change the values of buffermem, type the following command on your terminal:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="screen"
|
|
> [root@deep] /# <B
|
|
CLASS="command"
|
|
>echo</B
|
|
> "70 10 60" >/proc/sys/vm/buffermem
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
You may add the above commands to the <TT
|
|
CLASS="filename"
|
|
>/etc/rc.d/rc.local</TT
|
|
> script file and you'll not have to type it again the next time you reboot your system.
|
|
</P
|
|
><P
|
|
> <DIV
|
|
CLASS="mediaobject"
|
|
><P
|
|
><IMG
|
|
SRC="images/Version6.2.gif"
|
|
ALT="Version 6.2 only"
|
|
></IMG
|
|
></P
|
|
></DIV
|
|
>
|
|
|
|
Edit the <TT
|
|
CLASS="filename"
|
|
>/etc/sysctl.conf</TT
|
|
> file and add the following line:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="screen"
|
|
> # Improve virtual memory performance
|
|
vm.buffermem = 70 10 60
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
You must restart your network for the change to take effect. The command to manually restart the network is the following:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="screen"
|
|
> [root@deep] /# /etc/rc.d/init.d/network <B
|
|
CLASS="command"
|
|
>restart</B
|
|
>
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
<P
|
|
CLASS="literallayout"
|
|
><TT
|
|
CLASS="computeroutput"
|
|
> Setting network parameters [ OK ]
|
|
Bringing up interface lo [ OK ]
|
|
Bringing up interface eth0 [ OK ]
|
|
Bringing up interface eth1 [ OK ]
|
|
</TT
|
|
></P
|
|
>
|
|
|
|
According to the <TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/Documentation/sysctl/vm.txt</TT
|
|
> file, the first parameter 80 % means to use a minimum of 80 percent of memory for the buffer cache; the minimum percentage
|
|
of memory that should be spent on buffer memory.The last two parameters 10 and 60 are unused by the system so we dont need to change the defaults.
|
|
</P
|
|
><P
|
|
> Depending of the amount of RAM you have in the server the value of 80% may vary. When your server is highly loaded and when all application are used, you can know in detail how much memory are required and
|
|
used by the system. 80 % for the buffermem parameters seem to be too much for systems under 256 MB of RAM. Doing a <B
|
|
CLASS="command"
|
|
>free</B
|
|
> <TT
|
|
CLASS="literal"
|
|
>-m</TT
|
|
> command on the prompt your system will
|
|
display amount of free and used memory in the system. Once you have executed this command <B
|
|
CLASS="command"
|
|
>free</B
|
|
> -m, check for <TT
|
|
CLASS="computeroutput"
|
|
>-/+ buffers/cache:</TT
|
|
>values
|
|
and get the one related to the minimal (-) to set your value for buffermem.
|
|
</P
|
|
><DIV
|
|
CLASS="example"
|
|
><A
|
|
NAME="AEN4625"
|
|
></A
|
|
><P
|
|
><B
|
|
>Example 6-1. For 128 MB of RAM</B
|
|
></P
|
|
><P
|
|
> <TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> 128 * 80% = 102.4 MB
|
|
128 - 102.4 = 25.6 MB
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="screen"
|
|
> [root@deep] /#<B
|
|
CLASS="command"
|
|
>free</B
|
|
> -m
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="literallayout"
|
|
><TT
|
|
CLASS="computeroutput"
|
|
> total used free shared buffers cached
|
|
Mem: 124 121 3 30 43 48
|
|
-/+ buffers/cache: 29 95
|
|
Swap: 128 2 126
|
|
</TT
|
|
></PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
The result shows us that the <TT
|
|
CLASS="computeroutput"
|
|
>-/+ buffers/cache:</TT
|
|
> need 29 MB at minimum to run the system properly and with 128 MB of RAM set at 80% we have only 25.6 MB available. Hmmm! problem, i guess.
|
|
so we go back to the calculator again and do this:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> 128 * 70% = 89.6
|
|
128 - 89.6 = 38.4 MB
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
well solved good!.
|
|
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="tip"
|
|
><BLOCKQUOTE
|
|
CLASS="tip"
|
|
><P
|
|
><B
|
|
><SPAN
|
|
CLASS="inlinemediaobject"
|
|
><IMG
|
|
SRC="./images/Tip.gif"
|
|
ALT="Tip"
|
|
></IMG
|
|
></SPAN
|
|
>: </B
|
|
>
|
|
Look at <TT
|
|
CLASS="filename"
|
|
>/usr/src/linux/Documentation/sysctl/vm.txt</TT
|
|
> for more information on how to improve kernel parameters related to virtual memory.
|
|
</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="chap6sec68.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="chap6sec70.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>The bdflush parameters</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="gen-optim.html"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>The ip_local_port_range parameters</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |