Ubuntu18.04 ulimit settings

fork: retry: resources are temporarily unavailable 

Method 1: (Temporary solution, provided that the command can still be used)

Log in as root and execute the command:

ps aux | grep error command name or part of the name | awk'{print $2}' | xargs kill -9

Such as:

ps aux | grep insert_pos | awk '{print $2}' | xargs kill -9

Number of user connections: ulimit -u 102400
Stack size: ulimit -s 102400
Number of open files: ulimit -n 102400


Method 2: (Temporary solution, provided that the command can still be used)

This problem may occur because another program is running, causing the resource to be locked and unavailable. The reason that the resource is locked may be that the installation or update was not completed normally the last time the installation or update was run, and this situation occurred

#Process and kill the previous process, release the system lock
ps -e|grep apt-get
shows
6965? 00:00:01 apt-get
then execute
sudo kill 6965


Force unlock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

rm /var/lib/dpkg/lock-frontend


The following is the only feasible way I checked a lot of documents, because Ubuntu18 is different from the previous version

Method three: (permanently modify, this method is not easy to enter any command to make the choice that requires restart)

Add the following content:
Note that every user must configure
vim /etc/security/limits.conf

* soft     nproc          102400
* hard     nproc          102400
* soft     nofile         102400
* hard     nofile         102400
* soft     stack          102400  
* hard     stack          102400

root soft     nproc          102400
root hard     nproc          102400
root soft     nofile         102400
root hard     nofile         102400
root soft     stack          102400
root hard     stack          102400
 

* Means for all users, noproc means the maximum number of processes, nofile means the maximum number of open files
-meaning soft and hard are all limited


The difference between hard and soft:

-H: hard limit, strict setting, must not exceed the set value
-S: soft limit, warning setting, can exceed this set value, but if it exceeds, there will be a warning message


换个窗口查看:
root@iZ2zeiflf48wp1ved7nnnmZ:~# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 241390
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 102400
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) 102400
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


Add common-session
In the /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive files, add the following content:

session required pam_limits.so


Modify the /etc/systemd/system.conf and /etc/systemd/user.conf files.
If you do not modify these two files, the current logged-in ordinary users will not exceed this limit after restarting (affecting users who log in to the desktop).

After the modification is completed, if it is a remote link, the link will take effect; if it is a desktop environment, it will take effect after restarting

DefaultLimitNOFILE=102400
DefaultLimitSTACK=102400
DefaultLimitNPROC=102400

# Temporarily change the size of the stack space: ulimit -s 102400, which is modified to 100M

ulimit -s ulimited
ulimited is unlimited

Finally, I would like to remind everyone that after the files in these three places are changed, they must be restarted to take effect, otherwise you will encounter this problem in a few days.

Guess you like

Origin blog.csdn.net/Doudou_Mylove/article/details/107757293