国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > 文庫 > 正文

Memcached備份還原的的示例

2024-09-07 22:12:53
字體:
來源:轉載
供稿:網友
  理論上,Memcached 不需要做備份、還原這種事情,因為存在彥面的東西應該都是 Cache,沒有使用 Memcached 的話,速度應該只會比較慢,而不應該會有影響才對.
 
  注1:Memcached restart 后,所有資料都會清空.
 
  注2:這次遇到的主要是實驗用的項目,剛好要搬機器,實驗不想中斷,所以才用此方式
 
  Memcached 備份、還原的方式
 
  先看 Memcached 的限制條件:Key 長度 250 bytes,預設 Value 1M(可透過 -I 2M 設定),設定過期時間的話,過期時間最多設定30天(設 0 為永不過期的意思).
 
  Ref:NewCommands - memcached - Make Me a Sandwich - Memcached
 
  一般 Memcached 能提供的方式都是 Dump key,然后自己再寫程式撈出來,做寫入(ADD)的動作,這邊有比較簡易的操作方式.(利用 memcached-tool + nc 來達成).
 
  Memcached 備份、還原的步驟:
 
  假設要將 192.168.1.1 的 memcached data 備份到 localhost 192.168.1.1. 那臺 memcached ip 不能跑 localhost,代碼如下:
 
  wget https://raw.githubusercontent.com/memcached/memcached/master/scripts/memcached-tool
  chmod +x ./memcached-tool
  ./memcached-tool 192.168.1.1:11211 dump > data # 備份, data 內容大致如下:
  add 19bc2701c3898279jkds1jklc272b35f 0 1413178136 506
  a:3:{s:4:"text";..................}
  注:1413178136 # timestamp,若是資料過期,匯入后找不到,代碼如下:
 
  nc localhost 11211 < data # 還原
  # 驗證
  ./memcached-tool localhost:11211 dump > local-data
  wc -l local-data
  wc -l data
  看看上述兩個資料筆數是否正確.
 
  上述參考自此篇:memcache dump and load
 
  PHP 版 Memcached backup / restore
 
  另外有 PHP 的 Memcached backup / restore 程式,可以參考看看(注:我沒用過),下述摘錄自此篇: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 ( 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 --phpfensi.com
  php m.php -h 127.0.0.1 -p 112112 -op restore
  其它 Memcached 相關工具
 
  Memcached 有其它方便使用的工具,可以嘗試看看.
 
  sudo apt-get install libmemcached-tools # 下述取自: 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 an 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 see if a server is available.
  memtouch - Touches a key.
  ex: memccat --servers=127.0.0.1。

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富顺县| 蕲春县| 清水河县| 政和县| 大埔县| 安义县| 柳江县| 米林县| 麟游县| 忻城县| 荔波县| 西畴县| 乌苏市| 铜梁县| 鄂州市| 两当县| 顺昌县| 潮安县| 泰顺县| 永修县| 明溪县| 旬阳县| 富裕县| 阳东县| 邓州市| 武胜县| 开封县| 峨山| 梅州市| 正安县| 涟源市| 漯河市| 岳西县| 利辛县| 镇远县| 丰台区| 秦安县| 定襄县| 叙永县| 南岸区| 三穗县|