Permalink
Browse files

Small fixes to cassandra recipe.

  • Loading branch information...
cocoy committed Apr 23, 2012
1 parent dce7245 commit 17179a82a889457a1bddfc4190ba96352cdf981b
View
@@ -0,0 +1,63 @@
+# Copyright 2012, Nathan Milford.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+default[:Cassandra][:cluster_name] = "Test Cluster"
+default[:Cassandra][:initial_token] = 0
+default[:Cassandra][:seeds] = "127.0.0.1"
+default[:Cassandra][:auto_bootstrap] = true
+default[:Cassandra][:hinted_handoff_enabled] = true
+default[:Cassandra][:max_hint_window_in_ms] = 3600000
+default[:Cassandra][:hinted_handoff_throttle_delay_in_ms] = 50
+default[:Cassandra][:authenticator] = "org.apache.cassandra.auth.AllowAllAuthenticator"
+default[:Cassandra][:authority] = "org.apache.cassandra.auth.AllowAllAuthority"
+default[:Cassandra][:partitioner] = "org.apache.cassandra.dht.RandomPartitioner"
+default[:Cassandra][:data_file_directories] = "/var/lib/cassandra/data"
+default[:Cassandra][:commitlog_directory] = "/var/lib/cassandra/commitlog"
+default[:Cassandra][:saved_caches_directory] = "/var/lib/cassandra/saved_caches"
+default[:Cassandra][:commitlog_rotation_threshold_in_mb] = 128
+default[:Cassandra][:commitlog_sync] = "periodic"
+default[:Cassandra][:commitlog_sync_period_in_ms] = 10000
+default[:Cassandra][:flush_largest_memtables_at] = 0.75
+default[:Cassandra][:reduce_cache_sizes_at] = 0.85
+default[:Cassandra][:reduce_cache_capacity_to] = 0.6
+default[:Cassandra][:seed_provider_class_name] = "org.apache.cassandra.locator.SimpleSeedProvider"
+default[:Cassandra][:disk_access_mode] = "auto"
+default[:Cassandra][:concurrent_reads] = 80
+default[:Cassandra][:concurrent_writes] = 64
+default[:Cassandra][:memtable_flush_queue_size] = 4
+default[:Cassandra][:memtable_flush_writers] = 1
+default[:Cassandra][:sliced_buffer_size_in_kb] = 64
+default[:Cassandra][:storage_port] = 7000
+default[:Cassandra][:rpc_port] = 9160
+default[:Cassandra][:rpc_keepalive] = true
+default[:Cassandra][:rpc_server_type] = "sync"
+default[:Cassandra][:thrift_framed_transport_size_in_mb] = 15
+default[:Cassandra][:thrift_max_message_length_in_mb] = 16
+default[:Cassandra][:incremental_backups] = false
+default[:Cassandra][:snapshot_before_compaction] = false
+default[:Cassandra][:column_index_size_in_kb] = 64
+default[:Cassandra][:in_memory_compaction_limit_in_mb] = 64
+default[:Cassandra][:compaction_throughput_mb_per_sec] = 16
+default[:Cassandra][:compaction_preheat_key_cache] = true
+default[:Cassandra][:rpc_timeout_in_ms] = 10000
+default[:Cassandra][:phi_convict_threshold] = 8
+default[:Cassandra][:endpoint_snitch] = "org.apache.cassandra.locator.PropertyFileSnitch"
+default[:Cassandra][:dynamic_snitch_badness_threshold] = 0.0
+default[:Cassandra][:request_scheduler] = "org.apache.cassandra.scheduler.NoScheduler"
+default[:Cassandra][:index_interval] = 128
+default[:Cassandra][:memtable_total_space_in_mb] = 4096
+default[:Cassandra][:multithreaded_compaction] = false
+default[:Cassandra][:commitlog_total_space_in_mb] = 3072
+default[:Cassandra][:MAX_HEAP_SIZE] = "4G"
+default[:Cassandra][:HEAP_NEWSIZE] = "800M"
@@ -15,8 +15,18 @@
#execute "rm -rf /etc/motd"
#execute "touch /etc/motd"
-execute 'echo "export JAVA_HOME=/usr/lib/jvm/java-6-sun" | sudo -E tee -a ~/.bashrc'
-execute 'echo "export JAVA_HOME=/usr/lib/jvm/java-6-sun" | sudo -E tee -a ~/.profile'
+#
+
+if node[:java][:install_flavor] == "oracle"
+ execute 'echo "export JAVA_HOME=/usr/lib/jvm/java-6-sun" | sudo -E tee -a ~/.bashrc'
+ execute 'echo "export JAVA_HOME=/usr/lib/jvm/java-6-sun" | sudo -E tee -a ~/.profile'
+end
+
+if node[:java][:install_flavor] == "openjdk"
+ execute 'echo "export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk" | sudo -E tee -a ~/.bashrc'
+ execute 'echo "export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk" | sudo -E tee -a ~/.profile'
+end
+
execute 'sudo bash -c "ulimit -n 32768"'
execute 'echo "* soft nofile 32768" | sudo tee -a /etc/security/limits.conf'
execute 'echo "* hard nofile 32768" | sudo tee -a /etc/security/limits.conf'
View
@@ -15,16 +15,16 @@
# Stop Cassandra if it is running.
# Different for Debian due to service package.
-if node[:platform] == "debian"
- service "cassandra" do
- action :stop
- ignore_failure true
- end
-else
- service "cassandra" do
- action :stop
- end
-end
+#if node[:platform] == "debian"
+# service "cassandra" do
+# action :stop
+# ignore_failure true
+# end
+#else
+# service "cassandra" do
+# action :stop
+# end
+#end
# Only for debug purposes
OPTIONAL_INSTALL = false
@@ -36,30 +36,28 @@
#
# instead user java recipe.
-node["java"]["install_flavor"] = "oracle"
+#node["java"]["install_flavor"] = "oracle"
+node["java"]["install_flavor"] = "openjdk"
include_recipe "java"
-
-
if OPTIONAL_INSTALL
include_recipe "cassandra::optional_packages"
end
-
+include_recipe "cassandra::additional_settings"
include_recipe "cassandra::install"
# include_recipe "cassandra::raid"
-
-
-include_recipe "cassandra::additional_settings"
-
-
#include_recipe "cassandra::token_generation"
-
#include_recipe "cassandra::create_seed_list"
-
#include_recipe "cassandra::write_configs"
+#include_recipe "cassandra::restart_service"
+#
+#start service if not running
-
-include_recipe "cassandra::restart_service"
+#service "cassandra" do
+# action :enable
+# supports :status => true, :restart => true, :reload => true
+# #action :start
+#end
View
@@ -12,7 +12,14 @@
# Install Cassandra
#
###################################################
+#
+#
+
+execute "set-java" do
+ command "update-alternatives --auto java"
+ action :nothing
+end
# Used to clear any system information that may have
# been created when the service autostarts
execute "clear-data" do
@@ -23,26 +30,55 @@
# Sets up a user to own the data directories
node[:internal][:package_user] = "cassandra"
-# Installs the latest Cassandra 0.7.x
-if node[:setup][:deployment] == "07x"
- package "cassandra" do
- notifies :stop, resources(:service => "cassandra"), :immediately
- notifies :run, resources(:execute => "clear-data"), :immediately
- end
-end
-
-# Installs the latest Cassandra 0.8.x
-if node[:setup][:deployment] == "08x"
+# Installs the latest Cassandra 10x
+#if node[:setup][:deployment] == "10x"
+if node[:setup][:deployment] == "08x" or node[:setup][:deployment] == "07x" or node[:setup][:deployment] == "10x" or node[:setup][:deployment] == "11x"
case node[:platform]
when "ubuntu", "debian"
package "cassandra" do
- notifies :stop, resources(:service => "cassandra"), :immediately
+ #notifies :stop, resources(:service => "cassandra"), :immediately
notifies :run, resources(:execute => "clear-data"), :immediately
+ notifies :run, resources(:execute => "set-java"), :immediately
end
+
when "centos", "redhat", "fedora"
package "cassandra08" do
- notifies :stop, resources(:service => "cassandra08"), :immediately
+ #notifies :stop, resources(:service => "cassandra10"), :immediately
notifies :run, resources(:execute => "clear-data"), :immediately
end
end
end
+
+service "cassandra" do
+ supports :status => true, :restart => true, :reload => true
+ action [ :enable, :start ]
+end
+
+# Drop the config.
+template "/etc/cassandra/cassandra-env.sh" do
+ owner "cassandra"
+ group "cassandra"
+ mode "0755"
+ source "cassandra-env.sh.erb"
+ notifies :restart , resources(:service => "cassandra")
+end
+
+template "/etc/cassandra/cassandra.yaml" do
+ owner "cassandra"
+ group "cassandra"
+ mode "0644"
+ source "cassandra.yaml.erb"
+ notifies :restart , resources(:service => "cassandra")
+end
+
+template "/etc/cassandra/cassandra-topology.properties" do
+ owner "cassandra"
+ group "cassandra"
+ mode "0644"
+ source "cassandra-topology.properties.erb"
+ # Pass the topology array as 't' to the template.
+ #variables(
+ # :t => t
+ #)
+ notifies :restart , resources(:service => "cassandra")
+end
@@ -13,7 +13,15 @@
#
###################################################
+execute "set-java" do
+ command 'echo "export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk" | sudo -E tee -a /etc/environment'
+ action :run
+end
+
# Restart the service
service "cassandra" do
+ supports :restart => true
+ #notifies :run, resources(:execute => "set-java-home"), :immediately
action :restart
end
+
View
@@ -30,7 +30,8 @@
# Adds the Cassandra repo:
# deb http://www.apache.org/dist/cassandra/debian <07x|08x> main
- if node[:setup][:deployment] == "08x" or node[:setup][:deployment] == "07x"
+ #if node[:setup][:deployment] == "08x" or node[:setup][:deployment] == "07x"
+ if node[:setup][:deployment] == "08x" or node[:setup][:deployment] == "07x" or node[:setup][:deployment] == "10x" or node[:setup][:deployment] == "11x"
apt_repository "cassandra-repo" do
uri "http://www.apache.org/dist/cassandra/debian"
components [node[:setup][:deployment], "main"]
@@ -31,10 +31,12 @@
block do
results = []
open("/tmp/tokens").each do |line|
- results << line.split(':')[1].strip if line.include? 'Node'
+
+ results << line.chomp.split(':')[1].strip if line.include? 'Node'
end
- Chef::Log.info "Setting token to be: #{results[node[:cassandra][:token_position]]}"
+ #Chef::Log.info "Setting token to be: #{results[node[:cassandra][:token_position]]}"
+ Chef::Log.info "Setting token for this node."
node[:cassandra][:initial_token] = results[node[:cassandra][:token_position]]
end
end
Oops, something went wrong.

0 comments on commit 17179a8

Please sign in to comment.