Monitoring And Debugging Memcached Server Using phpMemCachedAdmin

I have found a very cool program for monitoring and debugging Memcached server, it’s called  phpMemcachedAdmin. This program allows to see in real-time (top-like) or from the start of the server, stats for get, set, delete, increment, decrement, evictions, reclaimed, cas command, as well as server stats (network, items, server version) with googlecharts and server internal configuration You can go further to see each server slabs, occupation, memory wasted and items (key & value).

Another part can execute commands to any memcached server : get, set, delete, flush_all, as well as execute any commands (like stats) with telnet To extract these informations, phpMemCacheAdmin uses, as you wish, direct communication with server, PECL Memcache or PECL Memcached API.

Explanation above is an excerpt from the website. This is a simple guide how do I install phpMemCachedAdmin.

Download phpMemCachedAdmin tarball

Since we will install in /var/www/html/memcached/ directory, run this command:

1
2
3
# mkdir -p /var/www/html/memcached
# tar -xvzf phpMemcachedAdmin-1.2.1-r233.tar.gz -C /var/www/html/memcached/
# chmod 0777 /var/www/html/memcached/Config/Memcache.php

Apache Configuration

( i’m using apache as reverse proxy backend )

1
2
# cd /etc/httpd/conf.d
# vi memcached.conf

memcached.conf

1
2
3
4
5
6
7
8
<VirtualHost *:80>
    ServerName   memcached.example.com
    UseCanonicalName Off
    ServerAdmin  "webmaster@example.com"
    DocumentRoot "/var/www/html/memcached"
    CustomLog  /var/log//httpd/memcached.example.com-access_log common
    ErrorLog   /var/log/httpd/memcached.example.com-error_log
</VirtualHost>

In the actual configuration, Apache only listens on ip address 127.0.0.1
Restart apache:

1
# service httpd restart

Nginx Configuration

( reverse proxy front end )

1
2
# cd /etc/nginx/conf.d
# vi memcached.conf

Because phpMemCachedAdmin not protected with user / pass or other protection mechanisms by default, we will restrict access based on ip address. This is the easiest way. :D

memcached.conf

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
server {
    listen 80;
        server_name  memcached.example.com;
        access_log   /var/log/nginx/memcached.example.com-access.log  main;
        location  / {
            allow my.private.ip.address/32;
            deny all;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:80;
        }
}

Restart nginx

1
#service nginx restart
Advertisements

Share your thoughts with us!!!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s