Note 1:memcached Restart, all information will be emptied
Note 2: This is mainly the experiment of the project, just to move the machine, the experiment does not want to interrupt, so only in this way
How to Memcached Backup, restore
First look at the Memcached restrictions:
Key Length bytes
Preset Value 1M (can be set through-I 2M)
Set the expiration time, the expiration time set up to 30 days (set 0 is never expired meaning)
Ref:newcommands-memcached-make Me a sandwich-memcached
General Memcached can provide the way is the Dump key, and then write their own program to fish out, do write (ADD) action, this side has a relatively simple way of operation. (using Memcached-tool + NC to achieve)
Steps for Memcached Backup, restore
Suppose you want to back up the memcached data for 192.168.1.1 to localhost (192.168.1.1. memcached IP cannot run localhost)
The code is as follows |
Copy Code |
wget Https://raw.githubusercontent.com/memcached/memcached/master/scripts/memcached-tool chmod +x./memcached-tool ./memcached-tool 192.168.1.1:11211 Dump > Data # Backup, the data content is roughly as follows: Add 19bc2701c3898279jkds1jklc272b35f 0 1413178136 506 A:3:{s:4: "Text";....... ...}
|
Note: 1413178136 # timestamp, if the data expires, the import can not find
The code is as follows |
Copy Code |
NC localhost 11211 < data # restore # validation ./memcached-tool localhost:11211 Dump > Local-data Wc-l Local-data Wc-l data
|
See if the above two data pens are correct
The above references from this article: Memcache Dump and load
PHP version Memcached Backup/restore
There is also PHP Memcached backup/restore program, you can refer to see (note: I did not use)
The following excerpt from this article: Meabed/memcached-php-backup-restore-save/restore data from Memcache to File
PHP m.php-h 127.0.0.1-p 112112-op Restore
-h:memcache Host Address (the default is 127.0.0.1)
-p:memcache Port (default is 11211)
-p:operation is required!! (Available options Is:restore, Backup)
PHP m.php-h 127.0.0.1-p 112112-op Backup
PHP m.php-h 127.0.0.1-p 112112-op Restore
Other Memcached related tools
Memcached has other handy tools that you can try to see.
sudo apt-get install Libmemcached-tools # The following is taken from: Welcome to the libmemcached documentation
Memcapable-checking a Memcached server capibilities and compatibility
Memcat-"cat" data from a server
MEMCP -Copy data to a server
memdump-dumping your server
memerror-translate the error code to a string
Memflush -Flush all data from a server
Memrm-remove data from a server
Memslap-load testing and benchmarking a server
Memaslap-load Testing and Benchmarking a server
Memstat-gather statistics from a server
Memexist-check For the existance of a key
memparse-parse an option string
Memping-test to the If a server is available.
M Emtouch-touches a key.
Ex:memccat--servers=127.0.0.1