From 9f42006bd103332bb9ebbc6f2c7041c09e076286 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Mon, 7 Jul 2014 16:50:02 -0700 Subject: [PATCH] Use local ES balancers on logstash workers Set up small non master non data elasticsearch daemons on logstash workers to act as local load balancers for the elasticsearch http protocol. Change-Id: Ie3729f851ebef3331a6b69f718e57d663209bfc2 --- modules/elasticsearch/manifests/init.pp | 12 ++++++++---- .../elasticsearch/templates/elasticsearch.yml.erb | 7 +++++++ modules/logstash/manifests/init.pp | 6 ++++-- modules/logstash/manifests/watchdog.pp | 6 ++++-- .../manifests/logstash_worker.pp | 15 +++++++++++++++ .../templates/logstash/indexer.conf.erb | 4 ++-- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/modules/elasticsearch/manifests/init.pp b/modules/elasticsearch/manifests/init.pp index eadb1c05a6..3155acb573 100644 --- a/modules/elasticsearch/manifests/init.pp +++ b/modules/elasticsearch/manifests/init.pp @@ -20,14 +20,18 @@ class elasticsearch ( $es_template_config = {} ) { # install java runtime - package { 'openjdk-7-jre-headless': - ensure => present, + if ! defined(Package['openjdk-7-jre-headless']) { + package { 'openjdk-7-jre-headless': + ensure => present, + } } # Curl is handy for talking to the ES API on localhost. Allows for # querying cluster state and deleting indexes and so on. - package { 'curl': - ensure => present, + if ! defined(Package['curl']) { + package { 'curl': + ensure => present, + } } exec { 'get_elasticsearch_deb': diff --git a/modules/elasticsearch/templates/elasticsearch.yml.erb b/modules/elasticsearch/templates/elasticsearch.yml.erb index b612213e9f..04b20bdc22 100644 --- a/modules/elasticsearch/templates/elasticsearch.yml.erb +++ b/modules/elasticsearch/templates/elasticsearch.yml.erb @@ -86,6 +86,13 @@ node.name: "<%= scope.lookupvar("::hostname") %>" # to disable it, set the following: # node.max_local_storage_nodes: 1 +<% if es_template_config.has_key?('node.master') then -%> +node.master: <%= es_template_config['node.master'] %> +<% end -%> +<% if es_template_config.has_key?('node.data') then -%> +node.data: <%= es_template_config['node.data'] %> +<% end -%> + #################################### Index #################################### diff --git a/modules/logstash/manifests/init.pp b/modules/logstash/manifests/init.pp index 94a1c9f76f..0b08c63fce 100644 --- a/modules/logstash/manifests/init.pp +++ b/modules/logstash/manifests/init.pp @@ -75,7 +75,9 @@ class logstash { mode => '0644', } - package { 'openjdk-7-jre-headless': - ensure => present, + if ! defined(Package['openjdk-7-jre-headless']) { + package { 'openjdk-7-jre-headless': + ensure => present, + } } } diff --git a/modules/logstash/manifests/watchdog.pp b/modules/logstash/manifests/watchdog.pp index 8199192776..48aa575a95 100644 --- a/modules/logstash/manifests/watchdog.pp +++ b/modules/logstash/manifests/watchdog.pp @@ -23,8 +23,10 @@ class logstash::watchdog ( package { 'jq': ensure => present, } - package { 'curl': - ensure => present, + if ! defined(Package['curl']) { + package { 'curl': + ensure => present, + } } file { '/usr/local/bin/logstash-watchdog': diff --git a/modules/openstack_project/manifests/logstash_worker.pp b/modules/openstack_project/manifests/logstash_worker.pp index 8399ba4422..9c7b415f78 100644 --- a/modules/openstack_project/manifests/logstash_worker.pp +++ b/modules/openstack_project/manifests/logstash_worker.pp @@ -57,4 +57,19 @@ class openstack_project::logstash_worker ( log_processor::worker { 'D': config_file => 'puppet:///modules/openstack_project/logstash/jenkins-log-worker.yaml', } + + class { '::elasticsearch': + es_template_config => { + 'gateway.recover_after_nodes' => '5', + 'gateway.recover_after_time' => '5m', + 'gateway.expected_nodes' => '6', + 'discovery.zen.minimum_master_nodes' => '5', + 'discovery.zen.ping.multicast.enabled' => false, + 'discovery.zen.ping.unicast.hosts' => $elasticsearch_nodes, + 'node.master' => false, + 'node.data' => false, + }, + heap_size => '1g', + version => '0.90.9', + } } diff --git a/modules/openstack_project/templates/logstash/indexer.conf.erb b/modules/openstack_project/templates/logstash/indexer.conf.erb index 0a83a86680..44145ad811 100644 --- a/modules/openstack_project/templates/logstash/indexer.conf.erb +++ b/modules/openstack_project/templates/logstash/indexer.conf.erb @@ -125,8 +125,8 @@ filter { output { elasticsearch_http { - host => "<%= scope.lookupvar("::openstack_project::logstash_worker::discover_node") %>" + host => "localhost" manage_template => false - flush_size => 512 + flush_size => 1024 } }