Skip to content

Commit

Permalink
Adding memcache
Browse files Browse the repository at this point in the history
  • Loading branch information
marktheunissen committed Aug 22, 2012
1 parent 3762a1a commit c25fb84
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 2 deletions.
25 changes: 25 additions & 0 deletions common-tasks/ubuntu-memcached.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
##
# Memcached daemon and PECL extension.
#
# Ubuntu only due to using apt.
#
- name: Memcached | Install packages
action: apt pkg=$item state=installed
with_items:
# This is 3.0.4 in Ubuntu, which is listed as 'beta' on the PECL page.
#- php5-memcache
- memcached
tags: memcached

- name: Memcached | Config file
action: template src=templates/etc-memcached-conf.j2 dest=/etc/memcached.conf
tags: memcached

- name: Memcached | PECL Library install
action: shell printf "yes\n" | pecl install memcache creates=/usr/lib/php5/20090626/memcache.so
tags: memcached

- name: Memcached | Config file for the PHP memcache extension
action: template src=templates/etc-php5-conf-d-memcache-ini.j2 dest=/etc/php5/conf.d/memcache.ini
tags: memcached
2 changes: 1 addition & 1 deletion ubuntu-10.04-lamp-dev/run-local-all
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

# Script for running the play on the localhost, everything included.
ansible-playbook -c local --tags="common,drush,eaccel" ./setup.yml
ansible-playbook -c local --tags="common,drush,eaccel,memcached" ./setup.yml
8 changes: 8 additions & 0 deletions ubuntu-10.04-lamp-dev/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
#
- include: ../common-tasks/ubuntu-eaccelerator.yml

##
# Memcached daemon.
- include: ../common-tasks/ubuntu-memcached.yml

##
# Restart services
#
Expand All @@ -91,3 +95,7 @@
- name: Restart MySQL
action: service name=mysql state=restarted
tags: common

- name: Restart Memcached
action: service name=memcached state=restarted
tags: memcached
47 changes: 47 additions & 0 deletions ubuntu-10.04-lamp-dev/templates/etc-memcached-conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# memcached default config file
# 2003 - Jay Bonci <jaybonci@debian.org>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.

# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d

# Log memcached's output to /var/log/memcached
logfile /var/log/memcached.log

# Be verbose
# -v

# Be even more verbose (print client commands as well)
# -vv

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m {{ memcached_memory }}

# Default connection port is 11211
-p 11211

# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
-u nobody

# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.
-l 127.0.0.1

# Limit the number of simultaneous incoming connections. The daemon default is 1024
# -c 1024

# Lock down all paged memory. Consult with the README and homepage before you do this
# -k

# Return error when memory is exhausted (rather than removing items)
# -M

# Maximize core file limit
# -r
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ eaccelerator.shm_prune_period = "0"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"
eaccelerator.allowed_admin_path = "/var/www"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extension=memcache.so
memcache.hash_strategy="{{ memcache_hash_strategy }}"
8 changes: 7 additions & 1 deletion ubuntu-10.04-lamp-dev/vars/default-settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ php_upload_max_filesize: '32M'
php_date_timezone: 'US/Central'

# eaccelerator.ini
eaccel_shm_size: '32'
eaccel_shm_size: '256'

# memcached.conf
memcached_memory: '128'

# memcache.ini
memcache_hash_strategy: 'consistent'

# my.cnf
mysql_max_allowed_packet: '128M'
Expand Down

0 comments on commit c25fb84

Please sign in to comment.