Skip to content

Commit 0b50bcc

Browse files
committed
Fix systemd unit file for mongodb and add manage limits.
1 parent b842529 commit 0b50bcc

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ mongodb_pymongo_pip_version: 3.7.1
1616
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
1717
mongodb_manage_service: true
1818
mongodb_manage_systemd_unit: true
19+
mongodb_systemd_unit_limit_nofile: 64000
20+
mongodb_systemd_unit_limit_nproc: 64000
1921

2022
mongodb_disable_transparent_hugepages: false
2123

tasks/install.debian.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
state: present
6060

6161
- name: Add systemd configuration if present
62-
copy:
63-
src: mongodb.service
62+
template:
63+
src: mongodb.service.j2
6464
dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
6565
owner: root
6666
group: root

files/mongodb.service renamed to templates/mongodb.service.j2

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
# {{ ansible_managed }}
12
[Unit]
23
Description=An object/document-oriented database
34
Documentation=man:mongod(1)
45

56
[Service]
6-
User=mongodb
7+
User={{ mongodb_user }}
78
ExecStart=/usr/bin/numactl --interleave=all /usr/bin/mongod --config /etc/mongod.conf
89
# file size
910
LimitFSIZE=infinity
@@ -12,9 +13,9 @@ LimitCPU=infinity
1213
# virtual memory size
1314
LimitAS=infinity
1415
# open files
15-
LimitNOFILE=64000
16+
LimitNOFILE={{ mongodb_systemd_unit_limit_nofile }}
1617
# processes/threads
17-
LimitNPROC=64000
18+
LimitNPROC={{ mongodb_systemd_unit_limit_nproc }}
1819
# locked memory
1920
LimitMEMLOCK=infinity
2021
# total threads (user+kernel)

0 commit comments

Comments
 (0)