Skip to content

Commit

Permalink
#157 Add OS tunning
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioNv91 committed Sep 1, 2022
1 parent 2c9100e commit 37b5d25
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file.

## [Unreleased](https://github.com/idealista/solr_role/tree/develop)
- *[#157](https://github.com/idealista/solr_role/issues/157) Add OS tunning* @MarioNv91

## [3.0.4](https://github.com/idealista/solr_role/tree/3.0.3) (2022-06-13)
### Fixed
- *[#154](https://github.com/idealista/solr_role/issues/154) fix task with tag solr_collections running on all hosts when the play set the batch size with serial 1* @ajiang
Expand Down
31 changes: 31 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,37 @@ solr_install: true
solr_mode: cloud # standalone|cloud
solr_auto_add_replicas: true

## OS Tunning options

solr_os_tunning: true

# pam_limits
solr_nofile_limit: 65535
solr_nproc_limit: 65535

# network
solr_sysctl_required_packages:
- procps

solr_sysctl_properties:
- name: net.core.rmem_max
value: 16777216
- name: net.core.wmem_max
value: 16777216
- name: net.core.somaxconn
value: 4096
- name: net.core.netdev_max_backlog
value: 16384
- name: net.ipv4.tcp_max_syn_backlog
value: 8192
- name: net.ipv4.tcp_syncookies
value: 1
- name: vm.max_map_count
value: 262144

# swap
solr_disable_swap: true

## Service options

# Owner
Expand Down
1 change: 1 addition & 0 deletions molecule/default/group_vars/solrcloud/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ solr_agents_config:
solr_environment_ui: "test,label=Molecule+test,color=green"
solr_mode: cloud
solr_collections_clean_house: false
solr_os_tunning: false
6 changes: 6 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---

- name: Solr | OS Tunning
import_tasks: os-tunning.yml
tags:
- solr_tunning
when: solr_os_tunning

- name: Solr | Install
import_tasks: install.yml
tags:
Expand Down
57 changes: 57 additions & 0 deletions tasks/os-tunning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

- name: TUNNING | Install required packages
apt:
pkg: "{{ item }}"
state: present
with_items: "{{ solr_sysctl_required_packages }}"
when: solr_sysctl_required_packages is defined

- name: TUNNING | Apply sysctl settings
sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
sysctl_set: yes
state: present
with_items: "{{ solr_sysctl_properties }}"
when: solr_sysctl_properties is defined

- name: TUNNING | Set to {{ solr_nofile_limit }} the nofile limit
pam_limits:
domain: '*'
limit_type: soft
limit_item: nofile
value: "{{ solr_nofile_limit }}"
register: ulimit
when: solr_nofile_limit is defined

- name: TUNNING | Set to {{ solr_nproc_limit }} the nproc limit
pam_limits:
domain: '*'
limit_type: soft
limit_item: nproc
value: "{{ solr_nproc_limit }}"
register: ulimit
when: solr_nproc_limit is defined

- name: TUNNING | Reboot host if ulimit changed
shell: sleep 10 && shutdown -r now
async: 1
poll: 0
ignore_errors: true
when: ulimit.changed

- name: TUNNING | Wait for connection
wait_for_connection:

- name: TUNNING | Disable SWAP (1/2)
shell: |
swapoff -a
when: solr_disable_swap

- name: TUNNING | Disable SWAP in fstab (2/2)
replace:
path: /etc/fstab
regexp: '^([^#].*?\sswap\s+sw\s+.*)$'
replace: '# \1'
when: solr_disable_swap

0 comments on commit 37b5d25

Please sign in to comment.