我得到这个错误的mysql systemd[1]: [/usr/lib/systemd/system/mysqld.service:39] Failed to parse resource value, ignoring: 40000 LimitMEMLOCK mysql systemd[1]: [/usr/lib/systemd/system/mysqld.service:39] Failed to parse resource value, ignoring: 40000 Centos 7与MySQL 5.7当我设置MYSQL 5.7的LimitMEMLOCK限制。
LimitMEMLOCK=40000
LimitMEMLOCK的数字限制? LimitMEMLOCK的目的是LimitMEMLOCK ? 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
当mysqld.service设置为LimitMEMLOCK=40000时,在其他Centos 7版本( CentOS Linux release 7.2.1511 (Core) ) mysqld.service不到此错误消息。
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)
让我们从systemd文档开始:
LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=, LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=, LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=, LimitRTTIME=为执行的进程设置各种资源的软硬限制。 有关资源限制概念的详细信息,请参阅setrlimit(2) 。
对于MEMLOCK,该手册页说明:
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到RAM中可防止内核将其交换出去。 这通常不会完成,但对于某些性能至关重要的东西来说,这是非常有用的。 数据库是可以很好地利用这些的东西之一。
将此值设置为40000是没有意义的。 即使你可以做到这一点,它会瘫痪数据库,并可能导致数据库崩溃。 当启用大页面支持时,MySQLlocking内存并且文档指出memlock必须是无限的(systemd单元中的infinity )。