85 lines
3.3 KiB
Markdown
85 lines
3.3 KiB
Markdown
---
|
|
|
|
slug: /configure-limits-conf
|
|
---
|
|
|
|
# Configure limits.conf
|
|
|
|
This topic describes how to limit the number of processes by configuring `limits.conf`.
|
|
|
|
If you are a personal user, you can skip this step. If you are an enterprise user, it is recommended to configure `limits.conf`.
|
|
|
|
You can modify resource limits using the following method:
|
|
|
|
Modify at the global level through the configuration file `/etc/security/limits.conf`.
|
|
|
|
The limits involved in seekdb processes include the maximum stack space size, maximum number of open files, and core file size.
|
|
|
|
## Modify configuration
|
|
|
|
Set the maximum stack space size at the session level to `unlimited`, the maximum number of open files to `655350`, and the core file size to `unlimited`.
|
|
|
|
Run the following command to open the `/etc/security/limits.conf` configuration file:
|
|
|
|
```shell
|
|
sudo vim /etc/security/limits.conf
|
|
```
|
|
|
|
Add the following content to the `/etc/security/limits.conf` configuration file:
|
|
|
|
```shell
|
|
* soft nofile 655350
|
|
* hard nofile 655350
|
|
* soft stack unlimited
|
|
* hard stack unlimited
|
|
* soft nproc 655360
|
|
* hard nproc 655360
|
|
* soft core unlimited
|
|
* hard core unlimited
|
|
```
|
|
|
|
:::info
|
|
|
|
<ul><li>You need to check whether the nproc configuration exists in the <code>/etc/security/limits.d/20-nproc.conf</code> file. If it exists, you need to synchronously modify the nproc value in that file.</li>
|
|
<li>The limits.conf configuration only takes effect for newly logged-in sessions (such as newly opened terminals, SSH connections, or newly started processes). Existing sessions or processes will not automatically inherit the new configuration and need to log in again or restart related services.</li></ul>
|
|
:::
|
|
|
|
## View configuration
|
|
|
|
Exit the current session and log in again. Run the following command to check whether the configuration has taken effect.
|
|
|
|
```shell
|
|
ulimit -a
|
|
```
|
|
|
|
The output is as follows.
|
|
|
|
```shell
|
|
core file size (blocks, -c) unlimited
|
|
data seg size (kbytes, -d) unlimited
|
|
scheduling priority (-e) 0
|
|
file size (blocks, -f) unlimited
|
|
pending signals (-i) 252876
|
|
max locked memory (kbytes, -l) 64
|
|
max memory size (kbytes, -m) unlimited
|
|
open files (-n) 655350
|
|
pipe size (512 bytes, -p) 8
|
|
POSIX message queues (bytes, -q) 819200
|
|
real-time priority (-r) 0
|
|
stack size (kbytes, -s) unlimited
|
|
cpu time (seconds, -t) unlimited
|
|
max user processes (-u) 655360
|
|
virtual memory (kbytes, -v) unlimited
|
|
file locks (-x) unlimited
|
|
```
|
|
|
|
From the results, you can see:
|
|
|
|
* Core file size indicates the maximum threshold of core files (in blocks), corresponding to the core parameter in the `limits.conf` configuration file. Check whether the value is unlimited.
|
|
|
|
* Open files indicates the maximum number of open file descriptors, corresponding to the nofile parameter in the `limits.conf` configuration file. Check whether the value is 655350.
|
|
|
|
* Stack size indicates the stack size (in kilobytes), corresponding to the stack parameter in the `limits.conf` configuration file. Check whether the value is unlimited.
|
|
|
|
* Max user processes indicates the maximum number of user processes, corresponding to the nproc parameter in the `limits.conf` configuration file. Check whether the value is 655360.
|