Fix systemd unit file for mongodb and add manage limits.

This commit is contained in:
Mikhail Konyakhin 2019-11-25 14:23:54 +03:00
parent b842529d7b
commit 0b50bcc867
3 changed files with 8 additions and 5 deletions

View File

@ -16,6 +16,8 @@ mongodb_pymongo_pip_version: 3.7.1
mongodb_user_update_password: "on_create" # MongoDB user password update default policy mongodb_user_update_password: "on_create" # MongoDB user password update default policy
mongodb_manage_service: true mongodb_manage_service: true
mongodb_manage_systemd_unit: true mongodb_manage_systemd_unit: true
mongodb_systemd_unit_limit_nofile: 64000
mongodb_systemd_unit_limit_nproc: 64000
mongodb_disable_transparent_hugepages: false mongodb_disable_transparent_hugepages: false

View File

@ -59,8 +59,8 @@
state: present state: present
- name: Add systemd configuration if present - name: Add systemd configuration if present
copy: template:
src: mongodb.service src: mongodb.service.j2
dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service" dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
owner: root owner: root
group: root group: root

View File

@ -1,9 +1,10 @@
# {{ ansible_managed }}
[Unit] [Unit]
Description=An object/document-oriented database Description=An object/document-oriented database
Documentation=man:mongod(1) Documentation=man:mongod(1)
[Service] [Service]
User=mongodb User={{ mongodb_user }}
ExecStart=/usr/bin/numactl --interleave=all /usr/bin/mongod --config /etc/mongod.conf ExecStart=/usr/bin/numactl --interleave=all /usr/bin/mongod --config /etc/mongod.conf
# file size # file size
LimitFSIZE=infinity LimitFSIZE=infinity
@ -12,9 +13,9 @@ LimitCPU=infinity
# virtual memory size # virtual memory size
LimitAS=infinity LimitAS=infinity
# open files # open files
LimitNOFILE=64000 LimitNOFILE={{ mongodb_systemd_unit_limit_nofile }}
# processes/threads # processes/threads
LimitNPROC=64000 LimitNPROC={{ mongodb_systemd_unit_limit_nproc }}
# locked memory # locked memory
LimitMEMLOCK=infinity LimitMEMLOCK=infinity
# total threads (user+kernel) # total threads (user+kernel)