I am trying to setup memcached to allow session sharing on 2 load balanced Apache servers - in my php.ini I have:
Node 1
session.save_handler = memcached
session.save_path = "tcp://NODE1_IP:11211"
and
Node 2
session.save_handler = memcached
session.save_path = "tcp://NODE2_IP:11211"
In /etc/sysconfig/memcached, I have:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1"
In phpinfo I have:
session.save_handler memcached memcached
session.save_path tcp://NODE1_IP:11211 tcp://NODE1_IP:11211
When I login to my application I have session_start on the login page and on the page which checks if the user is logged in but when I:
print_r($_SESSION);
Nothing gets shown as the session looks like it is not being set.
One thing of note is that in phpinfo I see at the top of the session section, these lines:
Session Support enabled
Registered save handlers files user
Registered serializer handlers php_serialize php php_binary wddx
Registered save handlers lists files and user but nothing about memcached - might that be why this is not working? How can I change/add to that?
Should the node1_ip be the public or private IP or doesn't it matter?
I can telnet to localhost 11211 but not to NODE1_IP 11211 - get connected refused. Port 11211 is open - tried changing /etc/sysconfig/memcached to "-l NODE1_IP:11211" but still get connection refused
If I change the options in /etc/sysconfig/memcached to nothing i.e. OPTIONS "" then I can telnet to NODE1_IP 11211 so it appears the format of what I am putting into memcached config is wrong?
Is there anything else I need to do? I have tried changing the save paths, adding and removing tcp, using 127.0.0.1, using actual IP addresses, using all the IP addresses seperated with a comma but still cannot get this to work.
stats items
returns the keys. – Alex Blexsave_path
should be ahost:port
. Trysession.save_path = "NODE1_IP:11211"
without tcp. – Alex Blex