<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">在 2017年05月26日 09:48, dw 写道:<br>
</div>
<blockquote type="cite"
cite="mid:bc1edcda-cef7-b15a-aa95-00a07c53d68c@163.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div class="moz-cite-prefix">在 2017年05月26日 09:42, dw 写道:<br>
</div>
<blockquote type="cite"
cite="mid:a1ff4a2c-6038-76b3-2671-af547d86a111@163.com">
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
<div class="moz-cite-prefix">在 2017年05月25日 18:54, Daniel P.
Berrange 写道:<br>
</div>
<blockquote type="cite"
cite="mid:20170525105419.GD18049@redhat.com">
<pre wrap="">On Thu, May 25, 2017 at 06:51:40PM +0800, dw wrote:
</pre>
<blockquote type="cite">
<pre wrap="">在 2017年05月25日 18:37, Daniel P. Berrange 写道:
</pre>
<blockquote type="cite">
<pre wrap="">On Thu, May 25, 2017 at 06:20:51PM +0800, dw wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi:
I'm trying to connect with libvirtd with virsh from a remote PC,but only
can establish 1000 connections.
If try more connections,prompt:
"error: failed to connect to the hypervisor
error: Failed to open file '/etc/libvirt/libvirt.conf': Too many open
files"
I tried in another PC,also get the same prompt.
Anybody know why?
</pre>
</blockquote>
<pre wrap="">There's a limit of 1024 open file handles by default on Linux. You would
have to raise that limit in /etc/security/limits.d/ for your user.
</pre>
</blockquote>
<pre wrap="">In /etc/security/limits.d/,there is only 20-nproc.conf.
</pre>
</blockquote>
<pre wrap="">You can create any files you want in that sub-directory - they just
use the same syntax as limits.conf. It means that if RPM upgrades
limits.conf it doesn't interfere with your changes in limits.d/custom.conf
</pre>
<blockquote type="cite">
<pre wrap="">I modified /etc/security/limits.conf,what I added is:
"* soft nofile 81920
* hard nofile 81920"
I also modified /etc/pam.d/login,that I added is:
"session required pam_limits.so"
</pre>
</blockquote>
<pre wrap="">I don't think that's needed - its already activated via
pam.d/system-auth which is included from login.
</pre>
<blockquote type="cite">
<pre wrap="">The output of "ulimit -a" is:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 385898
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 81920
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 385898
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
What I did is right?
</pre>
</blockquote>
<pre wrap="">That at least shows the new limit is active
Regards,
Daniel
</pre>
</blockquote>
<p>I restored /etc/security/limits.conf and /etc/pam.d/login.</p>
<p>And added file /etc/security/limits.d/21-nofile.conf, the
content is</p>
<blockquote>
<p> * soft nofile 10240<br>
* hard nofile 10240"</p>
</blockquote>
<p align="justify">The output of "ulimit -a" now is:</p>
<blockquote>
<p>core file size (blocks, -c) 0<br>
data seg size (kbytes, -d) unlimited<br>
scheduling priority (-e) 0<br>
file size (blocks, -f) unlimited<br>
pending signals (-i) 385898<br>
max locked memory (kbytes, -l) 64<br>
max memory size (kbytes, -m) unlimited<br>
open files (-n) 10240<br>
pipe size (512 bytes, -p) 8<br>
POSIX message queues (bytes, -q) 819200<br>
real-time priority (-r) 0<br>
stack size (kbytes, -s) 8192<br>
cpu time (seconds, -t) unlimited <br>
max user processes (-u) 385898<br>
virtual memory (kbytes, -v) unlimited<br>
file locks (-x) unlimited<br>
</p>
</blockquote>
<br>
<p>The related config of /etc/libvirt/libvirtd.conf is:</p>
<blockquote>max_clients = 5000<br>
max_queued_clients = 2000<br>
min_workers = 200<br>
max_workers = 2000<br>
max_requests = 5000<br>
max_client_requests = 2000<br>
</blockquote>
<br>
Now I still get the error:<br>
<blockquote>
<pre wrap="">error: failed to connect to the hypervisor
error: Failed to open file '/etc/libvirt/libvirt.conf': Too many open files</pre>
</blockquote>
<br>
</blockquote>
<p>I tried twice,and the result is:</p>
<blockquote>
<p>virsh -c qemu+tcp://remote_pc/system<br>
error: failed to connect to the hypervisor<br>
error: Failed to open file '/etc/libvirt/libvirt.conf': Too
many open files<br>
<br>
virsh -c qemu+ssh://remote_pc/system<br>
error: failed to connect to the hypervisor<br>
error: Failed to open file '/proc/4931/stat': Too many open
files<br>
</p>
</blockquote>
</blockquote>
<br>
Hi Daniel:<br>
<br>
I have solved the problem.<br>
Not anything above need to do in my PC, the only need to do is:<br>
<br>
<blockquote>Create
/etc/systemd/system/libvirtd.service.d/openfiles.conf, and write
the following two lines in it:<br>
<blockquote>[Service]<br>
LimitNOFILE=2048<br>
</blockquote>
then run "service libvirtd restart",and if needed,run "systemctl
daemon-reload"<br>
<br>
</blockquote>
If need more connections, increase LimitNOFILE, and also need to
modify /etc/libvirt/libvirtd.conf.<br>
<br>
Thank you for your help!<br>
<br>
<pre wrap="">Regards,
dw
</pre>
</body>
</html>