Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/mongodb_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ These variables apply to advanced situations.
| `mongodb_mongod_service_delay` | Integer | The time in seconds between retries when starting the mongod service. | 10 |
| `mongodb_status_poll` | Integer | The maximum number of times to query for the replicaset status before the set converges or we fail. | 3 |
| `mongodb_status_interval` | Integer | The number of seconds to wait between polling executions. | 10 |
| `mongodb_sysctl_file` | String | The name of the MongoDB sysctl file | /etc/sysctl.d/98-mongodb.conf |
| `mongodb_net_ipv4_tcp_keepalive_time` | Integer | Time (in seconds) that a TCP connection remains idle before the kernel starts sending keepalive probes to verify the connection is still alive. | 300 |
| `mongodb_net_core_somaxconn` | Integer | Controls the backlog queue size for incoming connections. When the queue is full, new connection attempts are rejected. | 65535 |
| `mongodb_vm_zone_reclaim_mode` | Integer | Controls whether the kernel reclaims memory from local zones before allocating from remote NUMA nodes. | 0 |
| `mongodb_vm_swappiness` | Integer | Balances between swapping out anonymous pages (process memory) versus dropping page cache (file system buffers). | 1 |
| `mongodb_vm_max_map_count` | Integer | Maximum number of memory map areas (virtual memory areas/VMAs) a process can create. | 262144 |

## Configuring TLS

Expand Down
10 changes: 10 additions & 0 deletions roles/mongodb/defaults/main/kernel_params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024, Itential, Inc
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
---
# Kernel parameters
mongodb_sysctl_file: /etc/sysctl.d/98-mongodb.conf
mongodb_net_ipv4_tcp_keepalive_time: 300
mongodb_net_core_somaxconn: 65535
mongodb_vm_zone_reclaim_mode: 0
mongodb_vm_swappiness: 1
mongodb_vm_max_map_count: 262144
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,39 @@
- name: Adjust keepalive
ansible.posix.sysctl:
name: net.ipv4.tcp_keepalive_time
value: 300

- name: Disable zone reclaim mode
ansible.posix.sysctl:
name: vm.zone_reclaim_mode
value: 0
value: "{{ mongodb_net_ipv4_tcp_keepalive_time }}"
state: present
sysctl_file: "{{ mongodb_sysctl_file }}"
reload: true

- name: Increase throughput settings
ansible.posix.sysctl:
name: net.core.somaxconn
value: 65535
value: "{{ mongodb_net_core_somaxconn }}"
state: present
sysctl_file: "{{ mongodb_sysctl_file }}"
reload: true

- name: Disable zone reclaim mode
ansible.posix.sysctl:
name: vm.zone_reclaim_mode
value: "{{ mongodb_vm_zone_reclaim_mode }}"
state: present
sysctl_file: "{{ mongodb_sysctl_file }}"
reload: true

- name: Set vm swappiness
ansible.posix.sysctl:
name: vm.swappiness
value: 1
value: "{{ mongodb_vm_swappiness }}"
state: present
sysctl_file: "{{ mongodb_sysctl_file }}"
reload: true

# Set Soft User Limits
- name: Set number of procs
community.general.pam_limits:
domain: mongod
limit_type: soft
limit_item: nproc
value: 32000

- name: Set number of files
community.general.pam_limits:
domain: mongod
limit_type: soft
limit_item: nofile
value: 64000
- name: Set vm max_map_count
ansible.posix.sysctl:
name: vm.max_map_count
value: "{{ mongodb_vm_max_map_count }}"
state: present
sysctl_file: "{{ mongodb_sysctl_file }}"
reload: true
2 changes: 1 addition & 1 deletion roles/mongodb/tasks/install-mongodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

- name: Adjust Kernel parameters
ansible.builtin.import_tasks:
file: install-adjust-kernel-params.yml
file: adjust-kernel-params.yml

- name: Configure SELinux
ansible.builtin.include_tasks:
Expand Down
Loading