docs/content/v2024.1/deploy/manual-deployment/system-config.md
Perform the following configuration on each node in the cluster:
Keep in mind that, although YugabyteDB is PostgreSQL compatible and runs a postgres process, it is not a PostgreSQL distribution. The PostgreSQL it runs doesn't need the same OS and system resources that open source PostgreSQL requires. For this reason, the kernel configuration requirements are different.
In particular, the main YugabyteDB process, the YB-TServer, is multi-threaded. As a result, you don't need to modify settings for shared memory and inter-process communication (IPC), because there is no inter-process communication or shared memory in a multi-threaded process model (all memory is shared by the same process).
YugabyteDB relies on clock synchronization to guarantee consistency in distributed transactions. chrony is the preferred NTP implementation for clock synchronization.
To install chrony, run:
$ sudo yum install -y chrony
In Linux, ulimit is used to limit and control the usage of system resources (threads, files, and network connections) on a per-process or per-user basis.
Run the following command to check the ulimit settings.
$ ulimit -a
The following settings are recommended when running YugabyteDB.
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 119934
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1048576
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) 12000
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
You can change values by substituting the -n option for any possible value in the output of ulimit -a. Issue a command in the following form to change a ulimit setting.
$ ulimit -n <value>
-f (file size): unlimited
-t (cpu time): unlimited
-v (virtual memory): unlimited [1]
-l (locked-in-memory size): unlimited
-n (open files): 64000
-m (memory size): unlimited [1] [2]
-u (processes/threads): 64000
{{< note title="Restart servers" >}}
If you change a ulimit setting on a node where the YB-Master and YB-TServer servers are already running, you must restart the servers for the new settings to take effect. Check the yb-tserver.INFO file to verify that the ulimits are applied. You can also check the /proc/<process pid> file to see the current settings.
{{< /note >}}
Changes made using ulimit may revert following a system restart depending on the system configuration. These settings should be applied permanently by adding the following in /etc/security/limits.conf:
* - core unlimited
* - data unlimited
* - fsize unlimited
* - sigpending 119934
* - memlock 64
* - rss unlimited
* - nofile 1048576
* - msgqueue 819200
* - stack 8192
* - cpu unlimited
* - nproc 12000
* - locks unlimited
On CentOS, /etc/security/limits.d/20-nproc.conf must also be configured to match.
* soft nproc 12000
After changing a ulimit setting in /etc/security/limits.conf, you will need to log out and back in. To update system processes, you may need to restart.
{{< note title="Using other distributions" >}} If you're using a desktop-distribution, such as ubuntu-desktop, the preceding settings may not suffice. The operating system needs additional steps to change ulimit for GUI login.
In the case of ubuntu-desktop, in /etc/systemd/user.conf and /etc/systemd/system.conf, add DefaultLimitNOFILE=64000 at the end of file.
Something similar may be needed for other distributions. {{< /note >}}
If running on a virtual machine, execute the following to tune kernel settings:
Configure the parameter vm.swappiness as follows:
sudo bash -c 'sysctl vm.swappiness=0 >> /etc/sysctl.conf'
Setup path for core files as follows:
sudo sysctl kernel.core_pattern=/home/yugabyte/cores/core_%p_%t_%E
Configure the parameter vm.max_map_count as follows:
sudo sysctl -w vm.max_map_count=262144
sudo bash -c 'sysctl vm.max_map_count=262144 >> /etc/sysctl.conf'
Validate the change as follows:
sysctl vm.max_map_count
If you're using systemd to start the processes, and the ulimits are not propagated, add the ulimits in the Service section of the systemd configuration file:
[Unit]
.....
[Service]
.....
ulimits options here
[Install]
.....
For more details, see the systemd example configuration for yb-master.service, and yb-tserver.service.
The mappings of ulimit options with values are:
| Data type | ulimit equivalent | Value |
|---|---|---|
| Directive | ulimit equivalent | Value |
| LimitCPU= | ulimit -t | infinity |
| LimitFSIZE= | ulimit -f | infinity |
| LimitDATA= | ulimit -d | infinity |
| LimitSTACK= | ulimit -s | 8388608 |
| LimitCORE= | ulimit -c | infinity |
| LimitRSS= | ulimit -m | infinity |
| LimitNOFILE= | ulimit -n | 1048576 |
| LimitAS= | ulimit -v | infinity |
| LimitNPROC= | ulimit -u | 12000 |
| LimitMEMLOCK= | ulimit -l | 64 |
| LimitLOCKS= | ulimit -x | infinity |
| LimitSIGPENDING= | ulimit -i | 119934 |
| LimitMSGQUEUE= | ulimit -q | 819200 |
| LimitNICE= | ulimit -e | 0 |
| LimitRTPRIO= | ulimit -r | 0 |
If a ulimit is set to unlimited, set it to infinity in the systemd configuration file.
Transparent hugepages should be enabled for optimal performance. By default, they are enabled.
You can check with the following command:
$ cat /sys/kernel/mm/transparent_hugepage/enabled
You should see the following output:
[always] madvise never
In addition, you should verify that transparent hugepages use the following settings:
/sys/kernel/mm/transparent_hugepage/defrag:
always defer [defer+madvise] madvise never
/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none:
0
If any of these values are not set as shown, you should modify your kernel command line to match. Consult your operating system documentation to determine the best way to modify a kernel command line argument for your operating system.
For example, on RHEL or CentOS 7 or 8, using grub2, you can use the following steps to enable transparent hugepages:
Append "transparent_hugepage=always" to GRUB_CMDLINE_LINUX in /etc/default/grub.
GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap ... transparent_hugepage=always"
Rebuild /boot/grub2/grub.cfg using grub2-mkconfig.
Be sure to take a backup of the existing /boot/grub2/grub.cfg before rebuilding.
On BIOS-based machines:
grub2-mkconfig -o /boot/grub2/grub.cfg
On UEFI-based machines:
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Reboot the system.