2

I got this error mysql systemd[1]: [/usr/lib/systemd/system/mysqld.service:39] Failed to parse resource value, ignoring: 40000 on Centos 7 with mysql 5.7 when I set the LimitMEMLOCK limit for MYSQL 5.7.

LimitMEMLOCK=40000
  1. Why it is not possible to set a numeric limit for LimitMEMLOCK?
  2. What is the purpose of LimitMEMLOCK ?
  3. Is the only soultion LimitMEMLOCK=infinity?

*

#cat /etc/*-release
CentOS Linux release 7.3.1611 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.3.1611 (Core)
CentOS Linux release 7.3.1611 (Core)

*

service mysqld status
Redirecting to /bin/systemctl status  mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2016-12-19 23:21:24 UTC; 9s ago
 Main PID: 11170 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─11170 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

mysql systemd[1]: Starting MySQL Server...
mysql mysqld_pre_systemd[11143]: /usr/sbin/restorecon:  Warning no default label for /mnt/data/mysql
mysql systemd[1]: Started MySQL Server.
mysql systemd[1]: [/usr/lib/systemd/system/mysqld.service:39] Failed to parse resource value, ignoring: 40000

I do not see this error message on other Centos 7 version (CentOS Linux release 7.2.1511 (Core)) when mysqld.service set up with LimitMEMLOCK=40000.

cat /etc/*-release
CentOS Linux release 7.2.1511 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.2.1511 (Core)
CentOS Linux release 7.2.1511 (Core)
0

1 Answer 1

4

Let's start with the systemd documentation:

LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=, LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=, LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=, LimitRTTIME=

Set soft and hard limits on various resources for executed processes. See setrlimit(2) for details on the resource limit concept.

For MEMLOCK, that man page explains:

   RLIMIT_MEMLOCK
          The maximum number of bytes of memory that may be locked into
          RAM.  In effect this limit is rounded down to the nearest
          multiple of the system page size.  This limit affects mlock(2)
          and mlockall(2) and the mmap(2) MAP_LOCKED operation.  Since
          Linux 2.6.9 it also affects the shmctl(2) SHM_LOCK operation,
          where it sets a maximum on the total bytes in shared memory
          segments (see shmget(2)) that may be locked by the real user
          ID of the calling process.  The shmctl(2) SHM_LOCK locks are
          accounted for separately from the per-process memory locks
          established by mlock(2), mlockall(2), and mmap(2) MAP_LOCKED;
          a process can lock bytes up to this limit in each of these two
          categories.

          In Linux kernels before 2.6.9, this limit controlled the
          amount of memory that could be locked by a privileged process.
          Since Linux 2.6.9, no limits are placed on the amount of
          memory that a privileged process may lock, and this limit
          instead governs the amount of memory that an unprivileged
          process may lock.

Locking memory into RAM prevents the kernel from swapping it out. This isn't often done, but for certain performance-critical stuff it is quite useful. Databases are one of those things that can make good use of this.

Setting this value to 40000 makes no sense. Even if you could do it, it would cripple the database and probably cause it to crash. MySQL locks memory when large page support is enabled and the documentation states that memlock must be unlimited (infinity in your systemd unit).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .