Skip to content

Commit

Permalink
updates mysql recipe and added nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
fred committed Dec 3, 2010
1 parent b83cf76 commit fab2416
Show file tree
Hide file tree
Showing 21 changed files with 993 additions and 18 deletions.
8 changes: 6 additions & 2 deletions mysql/attributes/server.rb
Expand Up @@ -32,7 +32,7 @@
end

# Tunables
default[:mysql][:tunable][:key_buffer] = "16M"
default[:mysql][:tunable][:key_buffer] = "32M"
default[:mysql][:tunable][:max_connections] = "40"
default[:mysql][:tunable][:wait_timeout] = "120"
default[:mysql][:tunable][:net_read_timeout] = "30"
Expand All @@ -43,7 +43,11 @@

default[:mysql][:tunable][:thread_cache_size] = "4"
default[:mysql][:tunable][:thread_concurrency] = "2"
default[:mysql][:tunable][:table_cache] = "64"
default[:mysql][:tunable][:query_cache_size] = "8M"
default[:mysql][:tunable][:query_cache_limit] = "2M"

default[:mysql][:tunable][:sort_buffer_size] = "512K"
default[:mysql][:tunable][:read_buffer_size] = "512K"
default[:mysql][:tunable][:read_rnd_buffer_size] = "1M"
default[:mysql][:tunable][:myisam_sort_buffer_size] = "16M"
default[:mysql][:tunable][:join_buffer_size] = "256K"
4 changes: 2 additions & 2 deletions mysql/recipes/client.rb
Expand Up @@ -21,7 +21,7 @@
package_name value_for_platform(
[ "centos", "redhat", "suse", "fedora"] => { "default" => "mysql-devel" },
"debian" => {
"5.0" => "libmysqlclient15-dev",
"5.0" => "libmysqlclient15-dev",
"5.0.1" => "libmysqlclient15-dev",
"5.0.2" => "libmysqlclient15-dev",
"5.0.3" => "libmysqlclient15-dev",
Expand All @@ -33,7 +33,7 @@
"8.10" => "libmysqlclient15-dev",
"9.04" => "libmysqlclient15-dev"
},
"default" => 'libmysqlclient-dev'
"default" => 'libmysqlclient15-dev'
)
action :nothing
end
Expand Down
13 changes: 7 additions & 6 deletions mysql/templates/debian/my.cnf.erb
Expand Up @@ -61,14 +61,15 @@ bind-address = <%= node[:mysql][:bind_address] %>
key_buffer = <%= node[:mysql][:tunable][:key_buffer] %>
max_allowed_packet = 16M
thread_stack = 128K
thread_cache_size = 8
thread_cache_size = <%= node[:mysql][:tunable][:thread_cache_size] %>
thread_concurrency = <%= node[:mysql][:tunable][:thread_concurrency] %>
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
table_cache = <%= node[:mysql][:tunable][:table_cache] %>
max_connections = <%= node[:mysql][:tunable][:max_connections] %>

# Timeout
wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %>
net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %>
net_write_timeout = <%= node[:mysql][:tunable][:net_write_timeout] %>
Expand All @@ -79,8 +80,8 @@ max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %>
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
query_cache_limit = <%= node[:mysql][:tunable][:query_cache_limit] %>
query_cache_size = <%= node[:mysql][:tunable][:query_cache_size] %>
#
# * Logging and Replication
#
Expand Down
15 changes: 9 additions & 6 deletions mysql/templates/default/my.cnf.erb
Expand Up @@ -61,13 +61,15 @@ bind-address = <%= node[:mysql][:bind_address] %>
key_buffer = <%= node[:mysql][:tunable][:key_buffer] %>
max_allowed_packet = 16M
thread_stack = 128K
thread_cache_size = 8
thread_cache_size = <%= node[:mysql][:tunable][:thread_cache_size] %>
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
max_connections = <%= node[:mysql][:tunable][:max_connections] %>
table_cache = <%= node[:mysql][:tunable][:table_cache] %>

thread_concurrency = <%= node[:mysql][:tunable][:thread_concurrency] %>

max_connections = <%= node[:mysql][:tunable][:max_connections] %>
wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %>
net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %>
Expand All @@ -79,8 +81,9 @@ max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %>
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
query_cache_limit = <%= node[:mysql][:tunable][:query_cache_limit] %>
query_cache_size = <%= node[:mysql][:tunable][:query_cache_size] %>

#
# * Logging and Replication
#
Expand Down
12 changes: 10 additions & 2 deletions mysql/templates/ubuntu-10.04/my.cnf.erb
Expand Up @@ -62,19 +62,27 @@ key_buffer = <%= node[:mysql][:tunable][:key_buffer] %>
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = <%= node[:mysql][:tunable][:thread_cache_size] %>
thread_concurrency = <%= node[:mysql][:tunable][:thread_concurrency] %>

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
table_cache = <%= node[:mysql][:tunable][:table_cache] %>
thread_concurrency = <%= node[:mysql][:tunable][:thread_concurrency] %>

# Connections and Timeout
max_connections = <%= node[:mysql][:tunable][:max_connections] %>
wait_timeout = <%= node[:mysql][:tunable][:wait_timeout] %>
net_read_timeout = <%= node[:mysql][:tunable][:net_read_timeout] %>
net_write_timeout = <%= node[:mysql][:tunable][:net_write_timeout] %>
back_log = <%= node[:mysql][:tunable][:back_log] %>
table_cache = <%= node[:mysql][:tunable][:table_cache] %>

max_heap_table_size = <%= node[:mysql][:tunable][:max_heap_table_size] %>

sort_buffer_size = <%= node[:mysql][:tunable][:sort_buffer_size] %>
read_buffer_size = <%= node[:mysql][:tunable][:read_buffer_size] %>
read_rnd_buffer_size = <%= node[:mysql][:tunable][:read_rnd_buffer_size] %>
myisam_sort_buffer_size = <%= node[:mysql][:tunable][:myisam_sort_buffer_size] %>
join_buffer_size = <%= node[:mysql][:tunable][:join_buffer_size] %>
#
# * Query Cache Configuration
#
Expand Down
61 changes: 61 additions & 0 deletions nginx/README.rdoc
@@ -0,0 +1,61 @@
= DESCRIPTION:

Installs nginx from package OR source code and sets up configuration handling similar to Debian's Apache2 scripts.

= REQUIREMENTS:

== Cookbooks:

* build-essential (for nginx::source)

== Platform:

Debian or Ubuntu though may work where 'build-essential' works, but other platforms are untested.

= ATTRIBUTES:

* version - sets the version to install.
* install_path - for nginx::source, sets the --prefix installation.
* src_binary - for nginx::source, sets the binary location.
* dir - configuration dir.
* log_dir - where logs go.
* user - user to run as.
* binary - path to nginx binary.
* configure_flags - for nginx::source, the flags to use for compilation.
* gzip* - configure the gzip module.
* keepalive - whether to use keepalive.
* keepalive_timeout
* worker_processes - number of workers to spawn.
* worker_connections - number of connections per worker.
* server_names_hash_bucket_size

= USAGE:

Provides two ways to install and configure nginx.

* Install via native package (nginx::default)
* Install via compiled source (nginx::source)

Both recipes implement configuration handling similar to the Debian Apache2 site enable/disable.

There's some redundancy in that the config handling hasn't been separated from the installation method (yet), so use only one of the recipes.

= LICENSE and AUTHOR:

Author:: Joshua Timberman (<joshua@opscode.com>)
Author:: Adam Jacob (<adam@opscode.com>)
Author:: AJ Christensen (<aj@opscode.com>)

Copyright:: 2008-2010, Opscode, Inc

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.
44 changes: 44 additions & 0 deletions nginx/attributes/default.rb
@@ -0,0 +1,44 @@
default[:nginx][:version] = "0.8.52"
default[:nginx][:install_path] = "/usr/local"
default[:nginx][:src_binary] = "#{nginx[:install_path]}/sbin/nginx"

case platform
when "debian","ubuntu"
set[:nginx][:dir] = "/etc/nginx"
set[:nginx][:log_dir] = "/var/log/nginx"
set[:nginx][:user] = "www-data"
set[:nginx][:binary] = "/usr/sbin/nginx"
else
set[:nginx][:dir] = "/etc/nginx"
set[:nginx][:log_dir] = "/var/log/nginx"
set[:nginx][:user] = "www-data"
set[:nginx][:binary] = "/usr/sbin/nginx"
end

default[:nginx][:configure_flags] = [
"--prefix=#{nginx[:install_path]}",
"--conf-path=#{nginx[:dir]}/nginx.conf",
"--with-http_ssl_module",
"--with-http_gzip_static_module"
]

default[:nginx][:gzip] = "on"
default[:nginx][:gzip_http_version] = "1.0"
default[:nginx][:gzip_comp_level] = "2"
default[:nginx][:gzip_proxied] = "any"
default[:nginx][:gzip_types] = [
"text/plain",
"text/html",
"text/css",
"application/x-javascript",
"text/xml",
"application/xml",
"application/xml+rss",
"text/javascript"
]

default[:nginx][:keepalive] = "on"
default[:nginx][:keepalive_timeout] = 15
default[:nginx][:worker_processes] = cpu[:total]
default[:nginx][:worker_connections] = 768
default[:nginx][:server_names_hash_bucket_size] = 64
35 changes: 35 additions & 0 deletions nginx/definitions/nginx_site.rb
@@ -0,0 +1,35 @@
#
# Cookbook Name:: nginx
# Definition:: nginx_site
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2009, Opscode, Inc.
#
# 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.
#

define :nginx_site, :enable => true do
if params[:enable]
execute "nxensite #{params[:name]}" do
command "/usr/sbin/nxensite #{params[:name]}"
notifies :restart, resources(:service => "nginx")
not_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
end
else
execute "nxdissite #{params[:name]}" do
command "/usr/sbin/nxdissite #{params[:name]}"
notifies :restart, resources(:service => "nginx")
only_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
end
end
end
73 changes: 73 additions & 0 deletions nginx/files/default/mime.types
@@ -0,0 +1,73 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/json json;
application/atom+xml atom;
application/rss+xml rss;

text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;

image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg;

application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.wap.xhtml+xml xhtml;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/zip zip;

application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;

audio/midi mid midi kar;
audio/mpeg mp3;
audio/x-realaudio ra;

video/3gpp 3gpp 3gp;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

0 comments on commit fab2416

Please sign in to comment.