Set nilai ulimit secara permanen di ubuntu 20.04 server

bismillah ..
selamat datang di blog saya

kasus ini ketika saya sedang menyiapkan server untuk yugabyate database server , bagian system configuration ( https://docs.yugabyte.com/preview/deploy/manual-deployment/system-config/ ) , dri beberapa trial error yang saya coba berikut cara yang sudah di uji oleh saya dan ampuh , nilai ulimit tidak berubah setelah di restart server

1. Tambahkan Nilai ulimit di file /etc/security/limits.conf (lihat di bagian ahir )

# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#        - NOTE: group and wildcard limits are not applied to root.
#          To apply a limit to the root user, <domain> must be
#          the literal username root.
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#        - chroot - change root to directory (Debian-specific)
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#root            hard    core            100000
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#ftp             -       chroot          /ftp
#@student        -       maxlogins       4

# End of file --> tambah baris di bawah ini

*                -       core            unlimited
*                -       data            unlimited
*                -       fsize           unlimited
*                -       sigpending      119934
*                -       memlock         64
*                -       rss             unlimited
*                -       nofile          1048576
*                -       msgqueue        819200
*                -       stack           8192
*                -       cpu             unlimited
*                -       nproc           12000
*                -       locks           unlimited
root@rotterdam-yb-2:~# 

2. tambahkan session required pam_limits.so ke /etc/pam.d/su dan /etc/pam.d/common-session

3. set nilai ulimit di /etc/profile juga

root@rotterdam-yb-2:~# cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "${PS1-}" ]; then
  if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
#tambah kan nilai limit nya di bawah ini per command
ulimit -c unlimited && ulimit -i 119934 && ulimit -l 64 && ulimit -n 1048576 && ulimit -u 12000
root@rotterdam-yb-2:~# 

kurang lebih 3 langkah di atas yang saya lakukan dan setelah di ujicoba restart nilai limit tidak hilang

semoga bermanfaat 🙂

2 Comments

  1. terimakasih tutorialnya mas, akan saya coba tes di ubuntu saya

    Reply
  2. aldykustyandiOctober 22, 2022 at 2:29 PM

    Hi mas,
    terimaksih sudah berkunjung, semoga berhasil

    Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.