B.3 Configuring Memcached

After you have downloaded and installed memcached on the server where the Lucene search index is running, as described in Downloading and Installing Memcached, you need to configure it on each node.

You configure memcached by adding the desired switches to the MEMCACHED_PARAMS variable.

  1. Navigate to the etc/sysconfig directory.

  2. Open the memcached file in a text editor.

  3. Uncomment the MEMCACHED_PARAMS variable and add any switches that you feel are appropriate. When you uncomment the MEMCACHED_PARAMS variable, the following switches are already present:

    • -d: Runs as a daemon. This is recommended.

    • -l: Determines the interface to listen on. The default value is the localhost. You should either delete this switch with its default address (this is recommended for a simple setup) or change the default address to the address that you want memcached to listen on. For example, -l 172.17.2.3.

    To see a complete list of switches that are available with memcached, type memcached -h from the command line of a machine where memcached is installed.

  4. (Recommended) Increase the maximum memory to use for items to 1024 MB. You do this by adding the -m switch to the MEMCACHED_PARAMS variable. For example:

    -m 1024
  5. (Recommended) You should configure memcached to start automatically each time you reboot the server where the Lucene search index is running. To configure memcached to start automatically, enter the following command from the command line:

    chkconfig --add memcached

    To verify that automatic startup is enabled, enter the following command from the command line:

    chkconfig memcached
  6. Validate that memcached is running from the local server by typing the following command:

    netstat -ap|grep memcached
  7. After you have verified that memcached is running on the local server, log in to a remote server, then validate that memcached is running to ensure that no networking problems exist:

    1. From the command line of a remote server, make a network connection to the server where memcached is running. For example, you can use the telnet command.

      telnet 172.17.2.3 11211
    2. Type a simple memcached command, such as stats and stats settings.

    3. After you have verified that memcached is running as expected, type quit to exit telnet.

      Following is an example of what you see:

      07309:~/Desktop # telnet xxx.xxx.xxx.xx 11211
      Trying xxx.xxx.xxx.xx...
      Connected to xxx.xxx.xxx.xx.
      Escape character is '^]'.
      stats
      STAT pid 2486
      STAT uptime 313
      STAT time 1334337169
      STAT version 1.2.6
      STAT pointer_size 64
      STAT rusage_user 0.028001
      STAT rusage_system 0.000000
      STAT curr_items 10
      STAT total_items 17
      STAT bytes 7971
      STAT curr_connections 4
      STAT total_connections 6
      STAT connection_structures 5
      STAT cmd_get 79
      STAT cmd_set 17
      STAT get_hits 62
      STAT get_misses 17
      STAT evictions 0
      STAT bytes_read 14249
      STAT bytes_written 67674
      STAT limit_maxbytes 67108864
      STAT threads 1
      END
      quit
      Connection closed by foreign host.
      07309:~/Desktop #
  8. Continue with Configuring Memcached in the Vibe Installation Program.