Files
clear-linux-documentation/guides/maintenance/resource-limits.html
2024-11-04 18:48:51 +00:00

229 lines
13 KiB
HTML

<!DOCTYPE html>
<html lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Resource limits &#8212; Documentation for Clear Linux* project</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/bizstyle.css?v=5283bb3d" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<script src="../../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../../_static/copybutton.js?v=a56c686a"></script>
<script src="../../_static/bizstyle.js"></script>
<link rel="canonical" href="https://clearlinux.github.io/clear-linux-documentation/guides/maintenance/resource-limits.html" />
<link rel="icon" href="../../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Restart system services after an OS update" href="restart.html" />
<link rel="prev" title="Query package info from upstream repository" href="query-upstream.html" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<!--[if lt IE 9]>
<script src="_static/css3-mediaqueries.js"></script>
<![endif]-->
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="restart.html" title="Restart system services after an OS update"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="query-upstream.html" title="Query package info from upstream repository"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Guides</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Resource limits</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="resource-limits">
<span id="id1"></span><h1>Resource limits<a class="headerlink" href="#resource-limits" title="Link to this heading"></a></h1>
<p>Linux systems employ limiting or quota mechanisms to provide quality of
service for system resources and contain rogue processes.</p>
<p>These limits are layered at the system-level and user-level. If these limits
need to be modified, it is useful to understand the different limit
configurations.</p>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#system-wide-limits" id="id2">System-wide limits</a></p>
<ul>
<li><p><a class="reference internal" href="#checking-limit" id="id3">Checking limit</a></p></li>
<li><p><a class="reference internal" href="#overriding-limit" id="id4">Overriding limit</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#per-user-limits" id="id5">Per-user limits</a></p></li>
<li><p><a class="reference internal" href="#service-limits" id="id6">Service limits</a></p></li>
</ul>
</nav>
<section id="system-wide-limits">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">System-wide limits</a><a class="headerlink" href="#system-wide-limits" title="Link to this heading"></a></h2>
<p>Some global resource limits are implemented in the Linux kernel and are
controllable with kernel parameters.</p>
<p>For example, a global limit for the maximum number of open files is set with
the <em>fs.file-max</em> parameter. This limit applies to all processes and users an
cannot be exceeded other limit values.</p>
<section id="checking-limit">
<h3><a class="toc-backref" href="#id3" role="doc-backlink">Checking limit</a><a class="headerlink" href="#checking-limit" title="Link to this heading"></a></h3>
<p>You can check a current value with <strong class="command">sysctl -n &lt;PARAMETER&gt;</strong>. For
example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sysctl<span class="w"> </span>-n<span class="w"> </span>fs.file-max
</pre></div>
</div>
<p>This <em>fs.file-max</em> value is set intentionally high on Clear Linux OS systems by
default. You can check the maximum value supported by the system with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cat</span> <span class="o">/</span><span class="n">proc</span><span class="o">/</span><span class="n">sys</span><span class="o">/</span><span class="n">fs</span><span class="o">/</span><span class="n">file</span><span class="o">-</span><span class="nb">max</span>
</pre></div>
</div>
</section>
<section id="overriding-limit">
<h3><a class="toc-backref" href="#id4" role="doc-backlink">Overriding limit</a><a class="headerlink" href="#overriding-limit" title="Link to this heading"></a></h3>
<p>You can override a value with <strong class="command">sysctl -w &lt;PARAMETER&gt;</strong>. For
example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>sysctl<span class="w"> </span>-w<span class="w"> </span>fs.file-max<span class="o">=</span>&lt;NUMBER&gt;
</pre></div>
</div>
<p>If needed permanently, the value can be set by creating a
<code class="file docutils literal notranslate"><span class="pre">/etc/sysctl.d/*.conf</span></code> file (see <strong class="command">man sysctl.d</strong> for details).
For example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>mkdir<span class="w"> </span>-p<span class="w"> </span>/etc/sysctl.d/
sudo<span class="w"> </span>tee<span class="w"> </span>/etc/sysctl.d/fs-file-max.conf<span class="w"> </span>&gt;<span class="w"> </span>/dev/null<span class="w"> </span><span class="s">&lt;&lt;&#39;EOF&#39;</span>
<span class="s">fs.file-max=&lt;NUMBER&gt;</span>
<span class="s">EOF</span>
</pre></div>
</div>
</section>
</section>
<section id="per-user-limits">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Per-user limits</a><a class="headerlink" href="#per-user-limits" title="Link to this heading"></a></h2>
<p>For processes not managed by systemd, resource limits can be set for PAM
logins on a per-user basis with upper and lower limits in the
<code class="file docutils literal notranslate"><span class="pre">/etc/security/limits.conf</span></code> file.</p>
<p>You can set temporary values and check the current values with the
<strong class="command">ulimit</strong> command. For example, to change the soft limit of maximum
number of open file descriptors for the current user:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ulimit</span> <span class="o">-</span><span class="n">S</span> <span class="o">-</span><span class="n">n</span> <span class="o">&lt;</span><span class="n">NUMBER</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>See <strong class="command">man limits.conf</strong> for details.</p>
</section>
<section id="service-limits">
<h2><a class="toc-backref" href="#id6" role="doc-backlink">Service limits</a><a class="headerlink" href="#service-limits" title="Link to this heading"></a></h2>
<p>Resource limits for services started with systemd units do not follow normal
user limits because the process is started in a separate <a class="reference external" href="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">Linux control group
(cgroup)</a> Linux
cgroups associate related process groups and provide resource accounting.</p>
<p>Resource limits for individual systemd services can be controlled inside their
unit files or its configuration drop-in directory with the resource Limit
directives. See <a class="reference external" href="https://www.freedesktop.org/software/systemd/man/systemd.exec.html">process properties section of the systemd.exec man page</a>.</p>
<p>Resource limits for all systemd services can be controlled with a file in the
<code class="file docutils literal notranslate"><span class="pre">/etc/systemd/system.conf.d/</span></code> directory. For example, to have no
restriction on the number of open files:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">mkdir</span> <span class="o">-</span><span class="n">p</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">systemd</span><span class="o">/</span><span class="n">system</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">d</span><span class="o">/</span>
<span class="n">sudo</span> <span class="n">tee</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">systemd</span><span class="o">/</span><span class="n">system</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">d</span><span class="o">/</span><span class="mi">50</span><span class="o">-</span><span class="n">nfiles</span><span class="o">.</span><span class="n">conf</span> <span class="o">&gt;</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">null</span> <span class="o">&lt;&lt;</span><span class="s1">&#39;EOF&#39;</span>
<span class="p">[</span><span class="n">Manager</span><span class="p">]</span>
<span class="n">DefaultLimitNOFILE</span><span class="o">=</span><span class="n">infinity</span>
<span class="n">EOF</span>
</pre></div>
</div>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../../index.html">
<img class="logo" src="../../_static/clearlinux.png" alt="Logo of Clear Linux* Project Docs"/>
</a></p>
<div>
<h3><a href="../../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Resource limits</a><ul>
<li><a class="reference internal" href="#system-wide-limits">System-wide limits</a><ul>
<li><a class="reference internal" href="#checking-limit">Checking limit</a></li>
<li><a class="reference internal" href="#overriding-limit">Overriding limit</a></li>
</ul>
</li>
<li><a class="reference internal" href="#per-user-limits">Per-user limits</a></li>
<li><a class="reference internal" href="#service-limits">Service limits</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="query-upstream.html"
title="previous chapter">Query package info from upstream repository</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="restart.html"
title="next chapter">Restart system services after an OS update</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/guides/maintenance/resource-limits.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="restart.html" title="Restart system services after an OS update"
>next</a> |</li>
<li class="right" >
<a href="query-upstream.html" title="Query package info from upstream repository"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Guides</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Resource limits</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2022 Intel Corporation. All Rights Reserved..
Last updated on Nov 04, 2024.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
</div>
</body>
</html>