首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >systemd的mysqld.service -未能解析资源值,忽略: 40000 - LimitMEMLOCK

systemd的mysqld.service -未能解析资源值,忽略: 40000 - LimitMEMLOCK
EN

Server Fault用户
提问于 2016-12-19 23:28:48
回答 1查看 2.7K关注 0票数 2

当我为MySQL5.7设置mysql systemd[1]: [/usr/lib/systemd/system/mysqld.service:39] Failed to parse resource value, ignoring: 40000限制时,在Centos 7和MySQL5.7上得到了这个错误LimitMEMLOCK

代码语言:javascript
运行
复制
LimitMEMLOCK=40000
  1. 为什么不能为LimitMEMLOCK设置一个数值限制?
  2. LimitMEMLOCK的目的是什么?
  3. 唯一的灵魂LimitMEMLOCK=infinity吗?

*

代码语言:javascript
运行
复制
#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)

*

代码语言:javascript
运行
复制
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

在其他Centos 7版本(CentOS Linux release 7.2.1511 (Core))上,当mysqld.serviceLimitMEMLOCK=40000一起设置时,我没有看到这个错误消息。

代码语言:javascript
运行
复制
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)
EN

回答 1

Server Fault用户

回答已采纳

发布于 2016-12-19 23:57:04

让我们从系统d文件开始:

LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=, LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=, LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=, LimitRTTIME=为执行的进程设置了各种资源的软和硬限制。有关资源限制概念的详细信息,请参见极限(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.

将内存锁定在RAM中可以防止内核交换内存。这不是经常做的,但是对于某些性能关键的东西来说,它是非常有用的。数据库是其中之一,可以很好地利用这一点。

将此值设置为40000没有意义。即使您可以这样做,它也会削弱数据库,并可能导致其崩溃。当启用MySQL时,大页面支持会锁定内存,并且文档指出,memlock必须是无限的(系统单元中的infinity)。

票数 4
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/821695

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档