Skip to content

Commit

Permalink
fix some change for ES 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdamiano committed Jul 12, 2017
1 parent d0c6298 commit 0bd2da7
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 13 deletions.
2 changes: 1 addition & 1 deletion attributes/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
default['elasticsearch']['cloud']['aws']['region'] = (aws['cloud']['aws']['region'] rescue nil)
default['elasticsearch']['cloud']['aws']['ec2']['endpoint'] = (aws['cloud']['aws']['ec2']['endpoint'] rescue nil)

default['elasticsearch']['cloud']['node']['auto_attributes'] = true

2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
default['elasticsearch']['templates']['elasticsearch_env'] = 'elasticsearch-env.sh.erb'
default['elasticsearch']['templates']['elasticsearch_yml'] = 'elasticsearch.yml.erb'
default['elasticsearch']['templates']['logging_yml'] = 'logging.yml.erb'
default['elasticsearch']['templates']['log4j2.properties'] = 'log4j2.properties.erb'


# === MEMORY
#
Expand Down
2 changes: 0 additions & 2 deletions attributes/gce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@

default['elasticsearch']['cloud']['gce']['project_id'] = ( gce['cloud']['gce']['project_id'] rescue nil )
default['elasticsearch']['cloud']['gce']['zone'] = ( gce['cloud']['gce']['zone'] rescue nil )

default['elasticsearch']['cloud']['node']['auto_attributes'] = true
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
license "Apache"
description "Installs and configures elasticsearch"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.markdown'))
version "5.2.0"
version "5.2.2"

depends 'ark', '>= 0.2.4'

Expand Down
2 changes: 1 addition & 1 deletion recipes/aws.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
default['elasticsearch']['plugin']['mandatory'] = Array(node['elasticsearch']['plugin']['mandatory'] | ['cloud-aws'])

node.normal['elasticsearch']['cloud']['node']['auto_attributes'] = true
install_plugin "elasticsearch/elasticsearch-cloud-aws/#{node['elasticsearch']['plugins']['elasticsearch/elasticsearch-cloud-aws']['version']}"
24 changes: 17 additions & 7 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

if node['elasticsearch']['esmajor'].to_i >= 5
node.default['elasticsearch']['bootstrap']['memory_lock'] = node['elasticsearch']['bootstrap']['mlockall']
if node['elasticsearch']['limits']['nofile'] < 65536
node.default['elasticsearch']['limits']['nofile'] = 65536
if node['elasticsearch']['limits']['nofile'].to_i < 65536
node.default['elasticsearch']['limits']['nofile'] = '65536'
end
end

Expand Down Expand Up @@ -217,10 +217,20 @@

# Create ES logging file
#
template "logging.yml" do
path "#{node['elasticsearch']['path']['conf']}/logging.yml"
source node['elasticsearch']['templates']['logging_yml']
owner node['elasticsearch']['user'] and group node['elasticsearch']['user'] and mode 0755
if node['elasticsearch']['esmajor'].to_i >= 5
template "log4j2.properties" do
path "#{node['elasticsearch']['path']['conf']}/log4j2.properties"
source node['elasticsearch']['templates']['log4j_properties']
owner node['elasticsearch']['user'] and group node['elasticsearch']['user'] and mode 0755

notifies :restart, 'service[elasticsearch]' unless node['elasticsearch']['skip_restart']
notifies :restart, 'service[elasticsearch]' unless node['elasticsearch']['skip_restart']
end
else
template "logging.yml" do
path "#{node['elasticsearch']['path']['conf']}/logging.yml"
source node['elasticsearch']['templates']['logging_yml']
owner node['elasticsearch']['user'] and group node['elasticsearch']['user'] and mode 0755

notifies :restart, 'service[elasticsearch]' unless node['elasticsearch']['skip_restart']
end
end
2 changes: 1 addition & 1 deletion recipes/gce.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node.default['elasticsearch']['plugin']['mandatory'] = Array(node['elasticsearch']['plugin']['mandatory'] | ['cloud-gce'])

node.normal['elasticsearch']['cloud']['node']['auto_attributes'] = true
install_plugin "elasticsearch/elasticsearch-cloud-gce/#{node['elasticsearch']['plugins']['elasticsearch/elasticsearch-cloud-gce']['version']}"
5 changes: 5 additions & 0 deletions recipes/search_discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
Chef::Log.debug("Found elasticsearch nodes at #{nodes.join(', ').inspect}")
node.normal['elasticsearch']['discovery']['zen']['ping']['unicast']['hosts'] = nodes.join(',')

if node['elasticsearch']['discovery']['zen']['ping']['unicast']['hosts'].empty?
node.normal['elasticsearch']['discovery']['zen']['ping']['unicast']['hosts'] =
select_attribute(node, node['elasticsearch']['discovery']['node_attribute'])
end

# set minimum_master_nodes to n/2+1 to avoid split brain scenarios
node.default['elasticsearch']['discovery']['zen']['minimum_master_nodes'] = (nodes.length / 2).floor + 1

Expand Down
5 changes: 5 additions & 0 deletions templates/default/elasticsearch-env.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

<%= "JAVA_HOME='#{node['elasticsearch']['java_home']}'\n" if node['elasticsearch']['java_home'] -%>
ES_HOME='<%= "#{node['elasticsearch']['dir']}/elasticsearch" %>'
<% if node['elasticsearch']['esmajor'].to_i < 5 %>
ES_HEAP_SIZE=<%= node['elasticsearch']['allocated_memory'] %>
<% end %>

<% if node['elasticsearch']['esmajor'].to_i < 2 %>
ES_CLASSPATH=$ES_CLASSPATH:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*
Expand Down Expand Up @@ -36,6 +38,9 @@ ES_JAVA_OPTS="
-Xmx<%= node['elasticsearch']['allocated_memory'] %>
-Xss<%= node['elasticsearch']['thread_stack_size'] %>
<%= node['elasticsearch']['gc_settings'] %>
<% if node['elasticsearch']['esmajor'].to_i >= 5 %>
-Dlog4j2.disable.jmx=true
<% end %>
<% if node['elasticsearch']['jmx'] %>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Expand Down
2 changes: 2 additions & 0 deletions templates/default/elasticsearch.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ After=network-online.target

[Service]
Environment=ES_HOME='<%= "#{node['elasticsearch']['dir']}/elasticsearch" %>'
<% if node['elasticsearch']['esmajor'].to_i < 5 %>
Environment=ES_HEAP_SIZE=<%= node['elasticsearch']['allocated_memory'] %>
<% end %>
<% if node['elasticsearch']['esmajor'].to_i < 2 %>
Environment=ES_CLASSPATH=$ES_CLASSPATH:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*
<% else %>
Expand Down
74 changes: 74 additions & 0 deletions templates/default/log4j2.properties.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
status = error

# log action execution errors for easier debugging
logger.action.name = org.elasticsearch.action
logger.action.level = debug

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n

appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}.log
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true

rootLogger.level = info
rootLogger.appenderRef.console.ref = console
rootLogger.appenderRef.rolling.ref = rolling

appender.deprecation_rolling.type = RollingFile
appender.deprecation_rolling.name = deprecation_rolling
appender.deprecation_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation.log
appender.deprecation_rolling.layout.type = PatternLayout
appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
appender.deprecation_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation-%i.log.gz
appender.deprecation_rolling.policies.type = Policies
appender.deprecation_rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.deprecation_rolling.policies.size.size = 1GB
appender.deprecation_rolling.strategy.type = DefaultRolloverStrategy
appender.deprecation_rolling.strategy.max = 4

logger.deprecation.name = org.elasticsearch.deprecation
logger.deprecation.level = warn
logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling
logger.deprecation.additivity = false

appender.index_search_slowlog_rolling.type = RollingFile
appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling
appender.index_search_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog.log
appender.index_search_slowlog_rolling.layout.type = PatternLayout
appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog-%d{yyyy-MM-dd}.log
appender.index_search_slowlog_rolling.policies.type = Policies
appender.index_search_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.index_search_slowlog_rolling.policies.time.interval = 1
appender.index_search_slowlog_rolling.policies.time.modulate = true

logger.index_search_slowlog_rolling.name = index.search.slowlog
logger.index_search_slowlog_rolling.level = trace
logger.index_search_slowlog_rolling.appenderRef.index_search_slowlog_rolling.ref = index_search_slowlog_rolling
logger.index_search_slowlog_rolling.additivity = false

appender.index_indexing_slowlog_rolling.type = RollingFile
appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling
appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog.log
appender.index_indexing_slowlog_rolling.layout.type = PatternLayout
appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog-%d{yyyy-MM-dd}.log
appender.index_indexing_slowlog_rolling.policies.type = Policies
appender.index_indexing_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.index_indexing_slowlog_rolling.policies.time.interval = 1
appender.index_indexing_slowlog_rolling.policies.time.modulate = true

logger.index_indexing_slowlog.name = index.indexing.slowlog.index
logger.index_indexing_slowlog.level = trace
logger.index_indexing_slowlog.appenderRef.index_indexing_slowlog_rolling.ref = index_indexing_slowlog_rolling
logger.index_indexing_slowlog.additivity = false

0 comments on commit 0bd2da7

Please sign in to comment.