Help with Memcached

edited April 2010 in General
I am trying to get Memcached working. I have a Memcached server running, but it is on a different machine (so different IP address). I have configured the firewall so that my StatusNet host can telnet into Memcached with no problem, but I am now having problems getting the plugin to work.

I am using the master copy of StatusNet from gitorious and I have noticed that there are two plugins, Memcache and Memcached that are not very different. Is one better to use? I tried invoking simply by adding

addPlugins('Memcached');

to config.php and editing the line in the plugin code to

public $servers = array('111.111.111.111;11211');

(replacing 111.111.111.111 with the address of my Memcached server). When I do that, I get a black screen, no log mesages. Trying the same thing on a home installation (running 0.9.0) I get an error message on screen:

Fatal error: Class 'Memcache' not found in /var/www/statusnet/plugins/MemcachePlugin.php on line 201

Any tips would be appreciated!

Comments

  • Well, I went back to the README and saw that the approach is different for this one, but even so, I set:

    config['memcached']['enabled'] = true;
    $config['memcached']['server'] = '111.111.111.111';
    $config['memcached']['based'] = 'myname';

    and I get the same errors (i.e. blank screen and Fatal error msg respectively).
  • I have just upgraded local installation to master too and installed memcached on the same machine. I get the same errors whether I used local host or the remote on.
  • @Darin since you seem to be around at the moment, do you have any ideas on this? I believe you are using Memcached.
  • I have everything installed but had problems with memcached so I disabled it. This was during the bug fix on the main page where items were not in order and nothing worked right after page 2. That has been fixed however I'm running into similiar problems WITHOUT memcached on the PERSONAL page now (not in order, paging is broken a bit).

    Here is my config file when I have it turned on:

    $config['memcached']['enabled'] = true;
    $config['memcached']['server'] = 'localhost';
    $config['memcached']['port'] = 11211;

    Of course, Im running it on the same machine as the web server. I have 3 servers, mysql, web, and jabber/meteor. All communicating by internal ip.

    I don't get errors when I turn it on, and it seems to speed things up for sure, however during all this dev work I have it turned off to eliminate the cache as an issue.

    I don't recall doing anything special when installed the memcached on my ubuntu, so I'm affraid I'm not much help with your particular issue :(
  • Thanks, I just tried

    $config['memcached']['enabled'] = true;
    $config['memcached']['server'] = 'localhost';
    $config['memcached']['port'] = 11211;

    on the local test server with no luck (still get the fatal error).
  • @Aric any suggestions on this one?
  • @seancarmody if you telnet localhost 11211 do you connect to memcached? if you stype 'stats' once connected do you see some?

    how are you launching the memcached daemon?

    what does sudo netstat -plunt | grep memcached return?


  • Both on my home machine and the "real" server I am running memcached on Ubuntu, having installed it via apt-get. I can telnet in to 11211 and get stats like this:

    STAT pid 18631
    STAT uptime 300137
    STAT time 1270510330
    STAT version 1.2.2
    STAT pointer_size 64
    STAT rusage_user 0.008000
    STAT rusage_system 0.000000
    STAT curr_items 1
    STAT total_item 2
    STAT bytes 65
    STAT curr_connections 1
    STAT total_connections 6
    STAT connection_structures 2
    STAT cmd_get 3
    STAT cmd_set 8
    STAT get_hits 3
    STAT get_misses 0
    STAT evictions 0
    STAT bytes_read 314
    STAT bytes_written 1734
    STAT limit_maxbytes 67108864
    STAT threads 1
    END

    I start memcached using the /etc/init.d/memcached script.

    That netstat command returns

    tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 18631/memcached
  • By the way, the current items are just from tests I ran from telnet.
  • @seancarmody re the fatal error:

    Fatal error: Class 'Memcache' not found in /var/www/statusnet/plugins/MemcachePlugin.php on line 201

    Our memcache plugin requires that PHP's memcache extension be enabled and loaded. This may be installable as 'php5-memcache' or a similar package name on the system if your PHP setup is managed by distro packages.

    Be warned also that there are both 'memcache' and 'memcached' extensions for PHP, which are slightly different. In 0.9.x so far we only support the 'memcache' one by default, though Craig did some work on a version that uses the 'memcached' extension as well.
  • Thanks very much @brionv. That certainly fixed things on my local installation, so now I just need my host to install the extension and I should be up and running.
  • Well @brionv I now have memcached working successfully. Unfortunately, having the memcached server on a different machine makes it very slow. The main reason I set it up was to deal with times that the geoname.org server was timing out (rather than just unsetting the Geonames plugin). I would run memcached on the localhost, but it's a virtual host and so I cannot install it there. I think I will either have to live without geonames or look to moving to a different hosting setup.
  • @seancarmody @brionv submitted a fix for geonames timing out, it should solve that problem straight away. heres a conversation in identi.ca about this issue. http://identi.ca/conversation/27715805#notice-27756520
  • @aric great, thanks!
  • Glad you got the fix Sean, its always the obvious stuff isnt it? Im dealing with a similiar issue with my realtime stuff now. Pulling hair.

    The 2 second timeout code works great btw, finally have a fix for that.

    BTW I have memcached on the same server as the web server and only have it active there when I do (not testing stuff).
  • After installing php5-memcache you'll also need to restart apache

    sudo /etc/init.d/apache2 reload
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID