Skip to content

Commit

Permalink
Merge pull request #158 from idealista/features/#157
Browse files Browse the repository at this point in the history
#157 Add OS tunning
  • Loading branch information
antonioarenzanapulido authored Sep 7, 2022
2 parents a15ada6 + 463ea44 commit f65f304
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 3 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
33 changes: 33 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@ solr_install: true
solr_mode: cloud # standalone|cloud
solr_auto_add_replicas: true

## OS Tunning options

solr_os_tunning: true

# pam_limits
solr_nofile_soft_limit: 65535
solr_nofile_hard_limit: 65535
solr_nproc_soft_limit: 65535
solr_nproc_hard_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
1 change: 1 addition & 0 deletions molecule/standalone/group_vars/solr/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ solr_agents_config:

solr_environment_ui: "test,label=Molecule+test,color=green"
solr_mode: standalone
solr_os_tunning: false
8 changes: 8 additions & 0 deletions tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
force: true
notify: restart Solr

- name: Solr | Configure Solr service with limits
template:
src: "{{ solr_templates_dir }}/solr.service.j2"
dest: /etc/systemd/system/solr.service
force: true
notify: restart Solr
when: solr_os_tunning

- name: Solr | Configuring Solr properties
template:
src: "{{ solr_templates_dir }}/solr.xml.j2"
Expand Down
6 changes: 6 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
tags:
- solr_install

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

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

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

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

- name: Solr | Set to {{ solr_nofile_soft_limit }} the nofile soft limit
pam_limits:
domain: '{{ solr_user }}'
limit_type: soft
limit_item: nofile
value: "{{ solr_nofile_soft_limit }}"
when: solr_nofile_soft_limit is defined

- name: Solr | Set to {{ solr_nofile_hard_limit }} the nofile hard limit
pam_limits:
domain: '{{ solr_user }}'
limit_type: hard
limit_item: nofile
value: "{{ solr_nofile_hard_limit }}"
when: solr_nofile_hard_limit is defined

- name: Solr | Set to {{ solr_nproc_soft_limit }} the nproc soft limit
pam_limits:
domain: '{{ solr_user }}'
limit_type: soft
limit_item: nproc
value: "{{ solr_nproc_soft_limit }}"
when: solr_nproc_soft_limit is defined

- name: Solr | Set to {{ solr_nproc_hard_limit }} the nproc hard limit
pam_limits:
domain: '{{ solr_user }}'
limit_type: hard
limit_item: nproc
value: "{{ solr_nproc_hard_limit }}"
when: solr_nproc_hard_limit is defined

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

- name: Solr | Disable SWAP in fstab (2/2)
replace:
path: /etc/fstab
regexp: '^([^#].*?\sswap\s+sw\s+.*)$'
replace: '# \1'
when: solr_disable_swap
36 changes: 36 additions & 0 deletions templates/solr.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[Unit]
Description=LSB: Controls Apache Solr as a Service
Before=multi-user.target
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
After=remote-fs.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
SuccessExitStatus=5 6
ExecStart=/etc/init.d/solr start
ExecStop=/etc/init.d/solr stop


{% if solr_nofile_soft_limit and solr_nofile_hard_limit %}
LimitNOFILE={{solr_nofile_soft_limit}}:{{solr_nofile_hard_limit}}
{% elif solr_nofile_hard_limit %}
LimitNOFILE={{solr_nofile_hard_limit}}
{% elif solr_nofile_soft_limit %}
LimitNOFILE={{solr_nofile_soft_limit}}
{% endif %}

{% if solr_nproc_soft_limit and solr_nproc_hard_limit %}
LimitNPROC={{solr_nproc_soft_limit}}:{{solr_nproc_hard_limit}}
{% elif solr_nproc_hard_limit %}
LimitNPROC={{solr_nproc_hard_limit}}
{% elif solr_nproc_soft_limit %}
LimitNPROC={{solr_nproc_soft_limit}}
{% endif %}
2 changes: 1 addition & 1 deletion vars/Debian-10.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

solr_external_libraries_required_packages:
- python-lxml
- python-lxml
2 changes: 1 addition & 1 deletion vars/Debian-9.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

solr_external_libraries_required_packages:
- python-lxml
- python-lxml
2 changes: 1 addition & 1 deletion vars/Ubuntu-20.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

solr_external_libraries_required_packages:
- python-lxml
- python-lxml

0 comments on commit f65f304

Please sign in to comment.