Skip to content

Commit

Permalink
Merge pull request #827 from rsalevsky/solr
Browse files Browse the repository at this point in the history
chef-solr tuning
  • Loading branch information
Rick Salevsky authored Nov 30, 2016
2 parents fee859b + bde7b15 commit 6eca187
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 3 deletions.
25 changes: 25 additions & 0 deletions chef/cookbooks/crowbar/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@
realm = node["crowbar"]["realm"]
workers = node["crowbar"]["workers"] || 2
threads = node["crowbar"]["threads"] || 16
chef_solr_heap = node["crowbar"]["chef"]["solr_heap"] || 256
chef_solr_data = if node["crowbar"]["chef"]["solr_tmpfs"]
"/dev/shm/solr_data"
else
"/var/cache/chef/solr/data"
end

users = {}
node["crowbar"]["users"].each do |k,h|
Expand All @@ -256,6 +262,8 @@
realm = nil
workers = 2
threads = 16
chef_solr_heap = 256
chef_solr_data = "/var/cache/chef/solr/data"
end

# Remove rainbows configuration, dating from before the switch to puma
Expand All @@ -276,6 +284,23 @@
)
end

service "chef-solr" do
supports status: true, restart: true
action :nothing
end

template "/etc/chef/solr.rb" do
source "chef-solr.rb.erb"
owner "root"
group "chef"
mode "0640"
variables(
chef_solr_heap: chef_solr_heap,
chef_solr_data: chef_solr_data
)
notifies :restart, "service[chef-solr]", :delayed
end

if node[:platform_family] == "suse"
cookbook_file "/etc/tmpfiles.d/crowbar.conf" do
owner "root"
Expand Down
67 changes: 67 additions & 0 deletions chef/cookbooks/crowbar/templates/default/chef-solr.rb.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Configuration File For Chef SOLR (chef-solr, chef-solr-indexer)
#
# Both the chef-solr and chef-solr-indexer daemons read this configuration
# file on startup, as set in /etc/default/chef-solr*.
#
# The chef-solr-indexer program listens to a rabbitmq-server for the /chef
# queue, for data stored in the CouchDB. When data is saved to the chef-server,
# a message is sent to the queue, and the data is indexed and stored by
# chef-solr for search in Chef recipes, or with the 'knife' command-line tool.
#
# chef-solr is a solr-jetty instance.
#
# It is a Ruby DSL config file, and can embed regular Ruby code in addition to
# the configuration settings. Some settings use Ruby symbols, which are a value
# that starts with a colon. In Ruby, anything but 'false' or 'nil' is true. To
# set something to false:
#
# some_setting false
#
# log_location specifies where the indexer should log to.
# valid values are: a quoted string specifying a file, or STDOUT with
# no quotes.
# Corresponds to chef-solr or chef-solr-indexer -l
# Both chef-solr and chef-solr-indexer daemons are configured to log in
# /etc/default/chef-solr -> /var/log/chef-solr
# /etc/default/chef-solr-indexer -> /var/log/chef-solr-indexer
# respectively. The jetty log for chef-solr is set in
# /etc/chef/solr-jetty/jetty.xml to /var/log/chef/yyyy_mm_dd.jetty.log.

log_location "/var/log/chef/solr.log"

# search_index_path specifies where the indexer should store the indexes.
# valid value is any filesystem directory location.

search_index_path "/var/lib/chef/search_index"

# set the jetty path to use Debian solr-jetty. Additional configuration for
# jetty can be found in /etc/chef/solr-jetty (which is symbolically linked to
# /var/lib/chef/solr/solr-jetty/etc).

solr_jetty_path "/var/lib/chef/solr/solr-jetty"
solr_home_path "/var/lib/chef/solr"
solr_data_path "<%=@chef_solr_data%>"
solr_heap_size "<%=@chef_solr_heap%>M"
solr_java_opts " -Dcom.ibm.tools.attach.enable=no "


# specifies the URL of the SOLR instance for the indexer to connect to.
# To change the port, modify the jetty.port setting in
# /etc/chef/solr-jetty/jetty.xml

solr_url "http://localhost:8983/solr"

# uses the solr_jetty_path option set above, and the etc directory is
# actually a symbolic link to /etc/chef/solr-jetty.
#solr_java_opts "-DSTART=#{solr_jetty_path}/etc/start.config"

# amqp_pass sets the password for the AMQP virtual host in rabbitmq-server.

amqp_pass File.read("/etc/chef/amqp_passwd").chomp

# Mixlib::Log::Formatter.show_time specifies whether the log should
# contain timestamps.
# valid values are true or false. The printed timestamp is rfc2822, for example:
# Fri, 31 Jul 2009 19:19:46 -0600

Mixlib::Log::Formatter.show_time = true
25 changes: 25 additions & 0 deletions chef/data_bags/crowbar/migrate/crowbar/102_chef-solr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def upgrade(ta, td, a, d)
unless a.key("chef")
a["chef"] = ta["chef"]
end
unless a["chef"].key?("solr_heap")
a["chef"]["solr_heap"] = ta["chef"]["solr_heap"]
end
unless a["chef"].key?("solr_tmpfs")
a["chef"]["solr_tmpfs"] = ta["chef"]["solr_tmpfs"]
end
return a, d
end

def downgrade(ta, td, a, d)
unless ta["chef"].key?("solr_heap")
a.delete["chef"]["solr_heap"]
end
unless ta["chef"].key?("solr_tmpfs")
a.delete["chef"]["solr_tmpfs"]
end
unless ta["chef"].lenght ~= 0
a.delete["chef"]
end
return a, d
end
8 changes: 6 additions & 2 deletions chef/data_bags/crowbar/template-crowbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
},
"simple_proposal_ui": true,
"upgrade": {
"db_dump_location" : "/var/lib/pgsql/openstack-db-before-upgrade.dump"
"db_dump_location": "/var/lib/pgsql/openstack-db-before-upgrade.dump"
},
"chef": {
"solr_heap": 256,
"solr_tmpfs": false
}
}
},
"deployment": {
"crowbar": {
"crowbar-revision": 0,
"crowbar-applied": false,
"schema-revision": 101,
"schema-revision": 102,
"element_states": {
"crowbar": [ "all" ],
"crowbar-upgrade": [ "readying", "ready", "applying", "crowbar_upgrade" ]
Expand Down
10 changes: 9 additions & 1 deletion chef/data_bags/crowbar/template-crowbar.schema
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@
"type": "map",
"required": true,
"mapping": {
"db_dump_location" : { "type": "str" }
"db_dump_location": { "type": "str" }
}
},
"chef": {
"type": "map",
"required": true,
"mapping": {
"solr_heap": { "type": "int" },
"solr_tmpfs": { "type": "bool" }
}
},
"simple_proposal_ui": { "type": "bool", "required": false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"simple_proposal_ui": true,
"upgrade": {
"db_dump_location" : "/var/lib/pgsql/db-before-cloud6.dump"
},
"chef": {
"solr_heap": 256,
"solr_tmpfs": false
}
}
},
Expand Down

0 comments on commit 6eca187

Please sign in to comment.