Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer data from one memcached server to another

Tags:

php

memcached

Currently we are storing our user sessions in memcached, our web apps are running with PHP 5.3.6 and Apache 2.2.3.

We will be replacing our memcached server, I am wondering if there is a way we can transfer the data from one memcached server to another so that the user sessions are still there. (To minimize downtime)

Although I have read from the FAQ http://code.google.com/p/memcached/wiki/FAQ#How_can_you_dump_data_from_or_load_data_into_memcached? that it is probably not possible to do that...but I am hoping if someone have some tools or workaround to achieve this.

Thanks!

Best regards

like image 828
forestclown Avatar asked Oct 06 '11 02:10

forestclown


2 Answers

It's possible with memcached-tool.

memcached-tool 10.1.2.30:11211 dump | nc 127.0.0.1 11211
like image 191
Ilari Stenroth Avatar answered Nov 14 '22 00:11

Ilari Stenroth


Your best bet is to probably add some code into your system that, when a user visits, writes the session into both the new server and the old one, and then let them run in parallel for a while, then turn off the old server. That way you can "warm up" the new server without actually depending on it, and then swap over once most of the sessions are moved over.

You'll still lose some sessions, but the most frequent visitors won't notice anything because their sessions will have been moved over.

like image 37
Amber Avatar answered Nov 14 '22 00:11

Amber