3

I'm trying to follow How To Share PHP Sessions on Multiple Memcached Servers article and implement that to my environment:

/etc/php.d/memcache.ini:

# grep -v ^\; /etc/php.d/memcache.ini
extension=memcache.so
memcache.allow_failover=1
memcache.session_redundancy=2
session.save_handler=memcache
session.save_path='tcp://192.168.52.143:11211, tcp://192.168.52.142:11211'
# 

phpinfo();:

# php -i | grep -E 'memcache.allow_failover|memcache.session_redundancy|session.save_handler|session.save_path'
memcache.allow_failover => 1 => 1
memcache.session_redundancy => 2 => 2
session.save_handler => memcache => memcache
session.save_path => tcp://192.168.52.142:11211, tcp://192.168.52.143:11211 => tcp://192.168.52.142:11211, tcp://192.168.52.143:11211
# 

both systems are RHEL6 and running php-5.3.3:

# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.6 (Santiago)
# rpm -q php php-pecl-memcache
php-5.3.3-40.el6_6.x86_64
php-pecl-memcache-3.0.5-4.el6.x86_64
# 

TCP wise: .142 is able to get to .143:11211, and .143 is able to get to .142:11211, SELinux is in Permissive mode.

I am able to see some chunks stored in one memcached server, but not in another.

What am I doing wrong?

alexus
  • 12,342
  • 27
  • 115
  • 173

2 Answers2

4

That DigitalOcean article I wrote has memcache.session_redundancy, your config file has used memcache.redundancy, both are different and that may be the reason why it isn't working as expected.

The default value of memcache.redundancy is 1 and it works fine for this setup.

extension=memcache.so
memcache.allow_failover=1
memcache.session_redundancy=2
session.save_handler=memcache
session.save_path = 'tcp://192.168.52.143:11211,tcp://192.168.52.142:11211'

http://php.net/manual/en/memcache.ini.php

Edit

Your comment:

IP are in reverse on another server, but syntax is the same.

This is where the problem lies, the session.save_path must be exact on all servers.

So both the servers must have 'tcp://192.168.52.143:11211,tcp://192.168.52.142:11211'

Read Step Two of that article, all 3 servers have the exact same order.

Edit #2

The value of memcache.session_redundancy must be equal to no. of servers + 1 due to a bug in PHP.

So in your case it must be:

memcache.session_redundancy=3
A.Jesin
  • 424
  • 1
  • 4
  • 14
  • You're correct, I did it wrong first time( I just correct it and updated my question with correct output, however still not working for me( – alexus Jan 29 '15 at 18:01
  • @alexus Is the `session.save_path` directive exactly same on both the systems? – A.Jesin Jan 29 '15 at 18:28
  • I tried the same settings on two CentOS 6.6 VMs and it worked without any issues. Check the `phpinfo()` page of both servers to make sure the proper configuration is in effect. And how are testing? Are you using a PHP session script? – A.Jesin Jan 30 '15 at 11:21
  • `phpinfo();` returns correct values (I updated question with output). I'm comparing `Cache Usage` between two `memcached` server and I stated in my original question "I am able to see some chunks stored in one `memcached` server, but not in another." – alexus Jan 30 '15 at 17:52
  • Why not use the PHP script described in that article. – A.Jesin Jan 31 '15 at 11:01
  • I'm using https://www.drupal.org/project/memcache and it doesn't matter if I'm using that project or your test `PHP` script as it's able to store chunks in one of `memcache` server, and the rest is up to `memcache.ini` configuration (variables that you described in your article). – alexus Feb 02 '15 at 16:52
  • Try the solution under **Edit #2**, it should work. I've asked DigitalOcean to update that article. – A.Jesin Feb 03 '15 at 15:09
  • I was reading another post that describes same thing as well : http://serverfault.com/questions/164350/can-a-pool-of-memcache-daemons-be-used-to-share-sessions-more-efficiently – alexus Feb 03 '15 at 16:06
-1

Only:

memcache.allow_failover=1
memcache.redundancy=2

should be in memcache.ini.

The others should be in php.ini.

HTTP500
  • 4,827
  • 4
  • 22
  • 31
  • 1
    On `RHEL`, `/etc/php.d/memcache.ini` contains `memcache.allow_failover`, `memcache.redundancy` _AND_ `session.save_handler`, `session.save_path` out of the box, it's not location of variables that's causing not to work. – alexus Jan 29 '15 at 17:13