Standalone

These instructions are for CentOS / Red Hat ... will later add ansible roles to handle also Debian line.


  1. install memcached
    sudo yum -y install memcached
  2. run memcached
    sudo systemctl start memcached
  3. test that memcached is running
    [ghost@pvnp memcached]$ sudo systemctl status memcached
    ● memcached.service - Memcached
       Loaded: loaded (/usr/lib/systemd/system/memcached.service; disabled; vendor preset: disabled)
       Active: active (running) since Tue 2017-11-21 10:29:36 UTC; 11s ago
     Main PID: 2145 (memcached)
       CGroup: /system.slice/memcached.service
               └─2145 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024
    
    Nov 21 10:29:36 pvnp systemd[1]: Started Memcached.
    Nov 21 10:29:36 pvnp systemd[1]: Starting Memcached...
    [ghost@pvnp memcached]$
    test that memcached is working
    [ghost@pvnp ~]$ telnet localhost 11211
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    stats items

    But that says nothing on if your publics can connect to the remote server hosting the memcached service ... you can be as restrictive as you like; for now, I am going to add a firewall rule to allow traffic on that port:

    [ghost@pvnp ~]$ sudo firewall-cmd --zone=public --add-port=11211/tcp
    [sudo] password for ghost:
    success
    [ghost@pvnp ~]$ sudo service firewalld restart #-ish

    Now check again, but this time from the server where your public instance/s is/are running:

    test that memcached is working
    ~/Desktop/PUBLICS\-> telnet 45.79.176.97 11211
    Trying 45.79.176.97...
    Connected to li1275-97.members.linode.com.
    Escape character is '^]'.
    stats items

    If you get a connection here, now you know everything is wired properly.

  4. Now that memcached is setup and running on some remote server, we need to configure Magnolia (Publics ... in every case, since we've changed a pom file, we have changed the project and need to rebuild and redeploy) to know about it ... stop Magnolia and

    Alter your webapp pom like so:

    <!--
    <dependency>
      <groupId>info.magnolia.eebundle</groupId>
      <artifactId>magnolia-enterprise-pro-webapp</artifactId>
      <type>pom</type>
    </dependency>
    -->
    <dependency>
      <groupId>info.magnolia.cache</groupId>
      <artifactId>magnolia-cache-memcached</artifactId>
      <version>5.5.6</version>
    </dependency>
    <dependency>
      <groupId>info.magnolia.eebundle</groupId>
      <artifactId>magnolia-enterprise-pro-webapp</artifactId>
      <type>pom</type>
      <exclusions>
        <exclusion>
          <groupId>info.magnolia.cache</groupId>
          <artifactId>magnolia-cache-ehcache</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>info.magnolia.eebundle</groupId>
      <artifactId>magnolia-enterprise-pro-webapp</artifactId>
      <type>war</type>
    </dependency>

    As usual, you should restart Magnolia and see something like this:

  5. Now let's create entries for /modules/cache/config/contentCaching/*
    Notice from the install you now have /modules/cache/config/cacheFactory/delegateFactories/memcached/caches.
    We need to set this up to reflect where the server is, etc.:
    set /modules/cache/config/cacheFactory/delegateFactories/memcached/caches/defaultPageCache/servers@0 and /modules/cache/config/cacheFactory/delegateFactories/memcached/caches/uuid-key-mapping/servers@0 properly ... mine is 45.79.176.97:11211:


  6. Now fire up your Public instances, and let's browse a bit to prime the cache.

    I'm lazy, so I don't browse ... I simply request pages programmatically.  Something like this:

    #!/bin/bash
    
    for i in `seq 1 1`;
    do
    
        curl -u superuser:superuser http://176.58.102.50:8080/magnoliaPublic1/p99.html
    done

    It would be more useful here to use the Travel Demo and prime the cache by iteratively curling over all the pages it comes with.


    Then a refresh on Author in Tools → Cache Tools gets me this:

    Now that you've primed the cache, you can check again to confirm the cache data are being stored remotely:

    ~/Desktop/PUBLICS\-> telnet 45.79.176.97 11211
    Trying 45.79.176.97...
    Connected to li1275-97.members.linode.com.
    Escape character is '^]'.
    stats items
    STAT items:9:number 1
    STAT items:9:age 128
    STAT items:9:evicted 0
    STAT items:9:evicted_nonzero 0
    STAT items:9:evicted_time 0
    STAT items:9:outofmemory 0
    STAT items:9:tailrepairs 0
    STAT items:9:reclaimed 0
    ...
    ...

  • No labels