Skip to main content
Jamf Nation, hosted by Jamf, is a dynamic and knowledgeable community of Apple-focused IT admins and Jamf Pro users. Join us in person, in October, for the annual Jamf Nation User Conference (JNUC) to discover new and better ways to manage Apple devices.

Memcached Installation and Configuration for Clustered JSS Environments

Overview

Starting with the future release of Jamf Pro 10.0.0, Memcached will be required for clustered environments. Memcached must be installed and enabled before enabling Clustering in Jamf Pro.

By default, the JSS v9.93 or later includes Ehcache for single node installations. This article explains how to configure Memcached for use with the JSS to enable distributed caching.

Memcached is used to support distributed caching across any number of JSS instances or dedicated Memcached servers. By using a distributed cache, it will ensure that clustered environments do not have stale cached information.

It is recommended to configure Memcached on a Linux server, however installation and configuration information for other platforms is included below.

It is recommended to configure Memcached to run on a separate server from Tomcat, to maximize resource allocation. Memcached can, however, be configured on a server alongside Tomcat if necessary. There is no limit to the number of Memcached instances which may be used.

It is recommended to utilize at least two instances of Memcached to maximize fault tolerance. If an instance becomes unavailable, the client will remove it from the pool. When the instance becomes available, the client then returns it to the pool. Each Memcached instance becomes a part of the whole. For example, having two 1 GB instances gives your entire cache 2 GB of memory.

Note: A service account on the server should be created for use with Memcached; however, if an installer such as yum or apt-get is used, a service user is created automatically.


Recommended Versions of Memcached

The recommended version of Memcached is 1.4.25 or later.
More information, including downloads of the latest version, are available at http://www.memcached.org.


Manually Installing From Source

To manually install Memcached from source, use the following commands.

  1. Use wget to retrieve the latest version of Memcached:
    wget https://memcached.org/latest
  2. Extract Memcached:
    tar -xzf latest
  3. Change into the correct directory:
    cd memcached-x.x.x
  4. Configure Memcached files:
    ./configure --prefix=<install_directory>
  5. Make the Memcached files:
    make && make test && sudo make install

Linux Server Installation and Configuration Steps

For Ubuntu:
1. Install Memcached on the server with the following command:

sudo apt-get install memcached

2. Customize the /etc/memcached.conf configuration file as an administrator, with the following changes:

sudo nano /etc/memcached.conf

Increase the memory cap:

-m 1024

Note: the memory cap is set in MB. The recommended minimum memory cap is 1024 MB.

Update the interface to listen on:

-l <IP address>

Note: You must either comment out this line if you would like Memcached to run on any interfaces, or you may specify multiple addresses separated by commas or by using -l multiple times. IP addresses specified should use the external interface, to ensure the Memcached client distributes the cached keys across all instances.
Update the port to listen on:

-p <Port>

Note: The default port that's used is 11211. You must ensure that any firewalls allow inbound traffic on the port specified. If you change the port, it must be specified within this file and also within the memcached.properties file located on the JSS.
3. Restart the service:

sudo /etc/init.d/memcached restart

4. Continue to steps for Enabling Memcached.
5. Repeat for any additional Memcached endpoints.

For RHEL:
1. Install Memcached on the server with the following command:

sudo yum install memcached

2. Customize the /etc/sysconfig/memcached.conf configuration file as an administrator, with the following changes:

sudo vi /etc/sysconfig/memcached.conf

Increase the memory cap:

CACHESIZE="1024"

Note: the memory cap is set in MB. The recommended minimum memory cap is 1024 MB.

Update the interface to listen on:

-l <IP address>

Note: You must either comment out this line if you would like Memcached to run on any interfaces, or you may specify multiple addresses separated by commas or by using -l multiple times. IP addresses specified should use the external interface, to ensure the Memcached client distributes the cached keys across all instances.
Update the port to listen on:

-p <Port>

Note: The default port that's used is 11211. You must ensure that any firewalls allow inbound traffic on the the port specified. If you change the port, it must be specified within this file and also within the memcached.properties file located on the JSS.
3. Start the service with the following command:

sudo systemctl start memcached.service

4. Enable the service with the following command:

systemctl enable memcached.service

5. Continue to steps for Enabling Memcached.
6. Repeat for any additional Memcached endpoints.


Enabling Memcached

Note: For each node in the JSS cluster, perform these steps. Each node should have the same endpoints defined. If different endpoints are defined in each node, the last memcached server to write information to the database will define the settings for all, and overwrite any previously defined endpoints. Additional platform-specific steps for Memcached installation and configuration (such as Homebrew and Windows) are included below.

  1. Customize the /path/to/Tomcat/ROOT/WEB-INF/classes/dal/cache.properties file with the following:
cache.type=memcached

Note: If you want to apply new settings, remove "DBAPPLIED_" that occurs prior to the "cache.type" setting.
2. Customize the /path/to/Tomcat/ROOT/WEB-INF/classes/dal/memcached.properties file to include your Memcached endpoint(s). For example:

memcached.endpoints[0]=IP.Address.of.Server:11211
memcached.endpoints[1]=IP.Address.of.Server:11211

Note: Memcached endpoints are servers that have Memcached installed and configured, as described above. Memcached endpoints can be defined with either a fully qualified domain name (FQDN), or an IP address; however, an IP address is typically preferred.
3. Restart Tomcat.
See Starting and Stopping Tomcat for instructions.


Additional OS Installation Options

macOS Server configuration steps

For homebrew configuration:
1. Open Terminal and create a Launch Agent to start Memcached at login by executing:

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents

2. Customize the ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist file to modify the interface and the memory cap by updating the following parameters:
- To increase the memory cap, modify the -m parameter. This value is set in MB. The recommended minimum memory cap is 1024 MB.
- To update the interface to listen on, modify the -l parameter from localhost to the desired IP address.
- To update the service account user, modify the -u parameter.
Note: You can remove the -l line if you would like Memcached to run on all interfaces.
3. Continue to steps for Enabling Memcached.
4. Repeat for any additional Memcached endpoints.

For manual configuration:
1. Open Terminal and create a Launch Agent to start Memcached at login by executing:
sudo vi ~/Library/LaunchAgents/org.memcached.memcached.plist
2. Copy the following into the plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>org.memcached.memcached</string>

    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/bin/memcached</string>
      <string>-l</string>
      <string>127.0.0.1</string>
      <string>-m</string>
      <string>1024</string>
      <string>-u</string>
      <string>memcached_user</string>
    </array>

    <key>StandardOutPath</key>
    <string>/var/log/memcached.log</string>
    <key>StandardErrorPath</key>
    <string>/var/log/memcached.log</string>

    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
  </dict>
</plist>

3. Customize the ~/Library/LaunchAgents/org.memcached.memcached.plist file to modify the interface and the memory cap by updating the following parameters:
- To increase the memory cap, modify the -m parameter. This value is set in MB. The recommended minimum memory cap is 1024 MB.
- To update the interface to listen on, modify the -l parameter from localhost to the desired IP address.
- To update the service account user, modify the -u parameter.
Note: You can remove the -l line if you would like Memcached to run on all interfaces.
4. Open Terminal and execute the following:
launchctl load ~/Library/LaunchAgents/org.memcached.memcached.plist
5. Continue to steps for Enabling Memcached.
6. Repeat for any additional Memcached endpoints.


Windows Server configuration steps


  1. The Windows Server firewall is on by default. Ensure you add Memcached as an allowed app that may be accessed through the firewall.

  2. Depending on the version of Memcached, do one of the following:
    • For Memcached versions before v1.4.5: Memcached should be installed as a service. To change the configuration of Memcached, run regedit.exe and navigate to the "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached" key. Customize the ImagePath value to the following:
      "c:\memcached\memcached.exe" -d runservice -m 1024


    • For Memcached v1.4.5 or later: the service will not start automatically on the server and must use scheduler. Open a command prompt with elevated privileges and execute the following:
      schtasks /create /sc onstart /tn memcached /tr "'c:\memcached\memcached.exe' -m 1024"
      Note: This command also sets the Memcached memory cap to 1024 MB. The recommended minimum memory cap is 1024 MB.



Additional General Information

Memcached installs a number of different files during the setup process. Specific files and dependancies may change based on the version installed or the configuration options selected. Below are common file dependancies for RHEL, and a list of common directory paths for installed files.

Memcached Dependencies (RHEL)
/bin/sh
/usr/bin/perl
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.17)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libevent-2.0.so.5()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libpthread.so.0(GLIBC_2.3.2)(64bit)
libsasl2.so.3()(64bit)
perl(IO::Socket::INET)
perl(strict)
rtld(GNU_HASH)
shadow-utils
systemd
systemd-sysv

Files Installed
<install-dir>/bin/memcached
<install-dir>/include/memcached/protocol_binary.h
<install-dir>/share/man/man1/memcached.1

Like Comment
CCT Badge CCA Badge CCE Badge
SOLVED Posted: 10/4/16 at 4:34 PM by chriscollins

For Redhat users, I thought I'd note a few differences to the instructions for linux in this document that don't match up since it appears to be written for Ubuntu.

Install memcached on server:

yum install memcached

It will automatically create the memcache service user for you.

The memcached configuration file is located at: /etc/sysconfig/memcached
To change the settings for memory and IP binding you can edit the CACHESIZE and OPTIONS respectively.

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="1024"
OPTIONS="-l 192.168.1.10"

Start memcached:

systemctl start memcached.service

Enable it to start after restarts

systemctl enable memcached.service

The instructions for modifying the webapp settings should be the same.

Like
CCA Badge CJA Badge CMA Badge JAMFBadge
SOLVED Posted: 12/9/16 at 9:45 PM by antonio.ong

Brilliant article, thanks for posting!

Quick comment: Can we change the title to: "Memcached Configuration for clustered JAMF Pro Servers"?

I can imagine people who are just trying to make sense out of Apple's Caching server stumble upon this article, and confusing them further.

Like
CCT Badge CCA Badge
SOLVED Posted: 3/22/17 at 9:47 PM by bradtchapman

@antonio.ong - it looks like you got your wish. The article was updated yesterday to coincide with the release of JSS 9.98.

Like
SOLVED Posted: 3/23/17 at 9:34 AM by jwojda

for Enabling Memchached it states

Customize the /path/to/Tomcat/ROOT/WEB-INF/classes/dal/cache.properties file with the following:

However, on my OS X server the path is

/path/to/Tomcat/webapps/ROOT/WEB-INF/classes/dal/cache.properties
Like
CCA Badge CCE Badge CJA Badge CMA Badge
SOLVED Posted: 3/23/17 at 9:51 AM by ssrussell

@jwojda i think your corrected path is the same for all platforms. Pobodys Nerftic. ¯\_(ツ)_/¯

Like
SOLVED Posted: 3/28/17 at 2:22 PM by jcompton

Value in my cache.properties is "DBAPPLIED_cache.type = ehcache"

That, together with this entry in schema --

<table_name>jss_cache_configurations</table_name>
   <name>cache_type</name>
   <name>ehcache_max_bytes_local_heap</name>
   <name>cache_unique_id</name>
   <name>elasticache</name>

leads me to believe there will eventually be fields to define your memcache servers in clustering settings - in the web app itself.

????

JAMF

???

Like
CCT Badge CCA Badge
SOLVED Posted: 6/29/17 at 1:51 AM by niklas.blomdalen

For CentOS the path is:
/usr/local/jss/tomcat/webapps/ROOT/WEB-INF/classes/dal/cache.properties

Like
CCT Badge CCA Badge
SOLVED Posted: 6/29/17 at 12:50 PM by bradtchapman

@niklas.blomdalen : That's also the case for most UNIX distributions (redhat, Ubuntu, etc). The phrase "/path/to/" is a generic placeholder.

Like
CCT Badge CCA Badge
SOLVED Posted: 8/23/17 at 6:52 AM by ftiff

It may be obvious for some, but we need to set :

cache.type = memcached

and not:

DBAPPLIED_cache.type = memcached

Otherwise you'll get the error:

Cache type is out of sync. Make sure the value for cache.type in the dal /cache.properties file matches the value in the database.
Like