Elasticseach目前作为查询搜索平台,的确非常实用方便。我们今天在这里要讨论的是如何做数据备份和type删除。我的ES的版本是2.4.1。

ES的备份,可不像MySQL的mysqldump这么方便,需要一个插件进行数据的导出和导入进行备份和恢复操作。这里要说的插件是elasticdump。

elasticdump的安装:

  1. [root@localhost ~]# yum install elasticdump
  2. 已加载插件:fastestmirror, product-id, subscription-manager
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  4. Repodata is over weeks old. Install yum-cron? Or run: yum makecache fast
  5. base | 3.6 kB ::
  6. cuda | 2.5 kB ::
  7. epel/x86_64/metalink | 5.0 kB ::
  8. epel | 4.3 kB ::
  9. extras | 3.4 kB ::
  10. updates | 3.4 kB ::
  11. (/): base/x86_64/primary_db | 5.7 MB ::
  12. (/): epel/x86_64/group_gz | kB ::
  13. (/): epel/x86_64/updateinfo | kB ::
  14. (/): extras/x86_64/primary_db | kB ::
  15. (/): base/x86_64/group_gz | kB ::
  16. (/): updates/x86_64/primary_db | 2.8 MB ::
  17. (/): epel/x86_64/primary_db | 4.8 MB ::
  18. cuda/primary_db FAILED
  19. http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/repodata/1d4cabb230a45d5f78f46ccd1b04914a98eab1b3-primary.sqlite.bz2: [Errno 12] Timeout on http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/repodata/1d4cabb230a45d5f78f46ccd1b04914a98eab1b3-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
  20. 正在尝试其它镜像。
  21. cuda/primary_db FAILED
  22. http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/repodata/1d4cabb230a45d5f78f46ccd1b04914a98eab1b3-primary.sqlite.bz2: [Errno 14] curl#52 - "Empty reply from server"0 ETA
  23. 正在尝试其它镜像。
  24. Determining fastest mirrors
  25. * epel: mirrors.tuna.tsinghua.edu.cn
  26. 正在解决依赖关系
  27. --> 正在检查事务
  28. ---> 软件包 elasticdump.noarch.0.2.2.0-.el7 将被 安装
  29. --> 正在处理依赖关系 npm(request) < ,它被软件包 elasticdump-2.2.-.el7.noarch 需要
  30. --> 正在处理依赖关系 npm(async) < ,它被软件包 elasticdump-2.2.-.el7.noarch 需要
  31. --> 正在处理依赖关系 npm(request) >= ,它被软件包 elasticdump-2.2.-.el7.noarch 需要
  32. --> 正在处理依赖关系 nodejs(engine) >= 1.0.,它被软件包 elasticdump-2.2.-.el7.noarch 需要
  33. --> 正在处理依赖关系 npm(optimist),它被软件包 elasticdump-2.2.-.el7.noarch 需要
  34. --> 正在处理依赖关系 npm(JSONStream),它被软件包 elasticdump-2.2.-.el7.noarch 需要
  35. --> 正在处理依赖关系 /usr/bin/node,它被软件包 elasticdump-2.2.-.el7.noarch 需要
  36. --> 正在检查事务
  37. ---> 软件包 nodejs.x86_64.1.6.11.1-.el7 将被 安装
  38. --> 正在处理依赖关系 npm = :3.10.-1.6.11.1..el7,它被软件包 :nodejs-6.11.-.el7.x86_64 需要
  39. --> 正在处理依赖关系 libuv >= :1.9.,它被软件包 :nodejs-6.11.-.el7.x86_64 需要
  40. --> 正在处理依赖关系 http-parser >= 2.7.,它被软件包 :nodejs-6.11.-.el7.x86_64 需要
  41. --> 正在处理依赖关系 libuv.so.()(64bit),它被软件包 :nodejs-6.11.-.el7.x86_64 需要
  42. --> 正在处理依赖关系 libhttp_parser.so.()(64bit),它被软件包 :nodejs-6.11.-.el7.x86_64 需要
  43. ---> 软件包 nodejs-async.noarch.0.0.2.10-.el7 将被 安装
  44. ---> 软件包 nodejs-jsonstream.noarch.0.0.10.0-.el7 将被 安装
  45. --> 正在处理依赖关系 npm(through),它被软件包 nodejs-jsonstream-0.10.-.el7.noarch 需要
  46. --> 正在处理依赖关系 npm(jsonparse),它被软件包 nodejs-jsonstream-0.10.-.el7.noarch 需要
  47. ---> 软件包 nodejs-optimist.noarch.0.0.4.0-.el7 将被 安装
  48. --> 正在处理依赖关系 npm(wordwrap) < 0.1,它被软件包 nodejs-optimist-0.4.-.el7.noarch 需要
  49. --> 正在处理依赖关系 npm(wordwrap) >= 0.0.,它被软件包 nodejs-optimist-0.4.-.el7.noarch 需要
  50. ---> 软件包 nodejs-request.noarch.0.2.25.0-.el7 将被 安装
  51. --> 正在处理依赖关系 npm(tunnel-agent) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  52. --> 正在处理依赖关系 npm(qs) < 0.7,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  53. --> 正在处理依赖关系 npm(oauth-sign) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  54. --> 正在处理依赖关系 npm(node-uuid) < 1.5,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  55. --> 正在处理依赖关系 npm(mime) < 1.3,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  56. --> 正在处理依赖关系 npm(json-stringify-safe) < 5.1,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  57. --> 正在处理依赖关系 npm(http-signature) < 0.11,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  58. --> 正在处理依赖关系 npm(hawk) < 1.1,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  59. --> 正在处理依赖关系 npm(form-data) < 0.2,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  60. --> 正在处理依赖关系 npm(forever-agent) < 0.6,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  61. --> 正在处理依赖关系 npm(cookie-jar) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  62. --> 正在处理依赖关系 npm(aws-sign) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  63. --> 正在处理依赖关系 npm(tunnel-agent) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  64. --> 正在处理依赖关系 npm(qs) >= 0.6.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  65. --> 正在处理依赖关系 npm(oauth-sign) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  66. --> 正在处理依赖关系 npm(node-uuid) >= 1.4.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  67. --> 正在处理依赖关系 npm(mime) >= 1.2.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  68. --> 正在处理依赖关系 npm(json-stringify-safe) >= 5.0.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  69. --> 正在处理依赖关系 npm(http-signature) >= 0.10.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  70. --> 正在处理依赖关系 npm(hawk) >= 1.0.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  71. --> 正在处理依赖关系 npm(form-data) >= 0.1.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  72. --> 正在处理依赖关系 npm(forever-agent) >= 0.5.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  73. --> 正在处理依赖关系 npm(cookie-jar) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  74. --> 正在处理依赖关系 npm(aws-sign) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
  75. --> 正在检查事务
  76. ---> 软件包 http-parser.x86_64.0.2.7.1-.el7_4 将被 安装
  77. ---> 软件包 libuv.x86_64.1.1.10.2-.el7 将被 安装
  78. ---> 软件包 nodejs-aws-sign.noarch.0.0.3.0-.el7 将被 安装
  79. ---> 软件包 nodejs-cookie-jar.noarch.1.0.3.0-.el7 将被 安装
  80. ---> 软件包 nodejs-forever-agent.noarch.0.0.5.0-.el7 将被 安装
  81. ---> 软件包 nodejs-form-data.noarch.0.0.1.1-.el7 将被 安装
  82. --> 正在处理依赖关系 npm(combined-stream) < 0.1,它被软件包 nodejs-form-data-0.1.-.el7.noarch 需要
  83. --> 正在处理依赖关系 npm(combined-stream) >= 0.0.,它被软件包 nodejs-form-data-0.1.-.el7.noarch 需要
  84. ---> 软件包 nodejs-hawk.noarch.0.1.0.0-.el7 将被 安装
  85. --> 正在处理依赖关系 npm(sntp) < 0.3,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  86. --> 正在处理依赖关系 npm(hoek) < 0.10,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  87. --> 正在处理依赖关系 npm(cryptiles) < 0.3,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  88. --> 正在处理依赖关系 npm(boom) < 0.5,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  89. --> 正在处理依赖关系 npm(sntp) >= 0.2,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  90. --> 正在处理依赖关系 npm(hoek) >= 0.9,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  91. --> 正在处理依赖关系 npm(cryptiles) >= 0.2,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  92. --> 正在处理依赖关系 npm(boom) >= 0.4,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
  93. ---> 软件包 nodejs-http-signature.noarch.0.0.10.0-.el7 将被 安装
  94. --> 正在处理依赖关系 npm(ctype) < 0.6,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
  95. --> 正在处理依赖关系 npm(assert-plus) < 0.2,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
  96. --> 正在处理依赖关系 npm(asn1) < 0.2,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
  97. --> 正在处理依赖关系 npm(ctype) >= 0.5.,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
  98. --> 正在处理依赖关系 npm(assert-plus) >= 0.1.,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
  99. --> 正在处理依赖关系 npm(asn1) >= 0.1.,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
  100. ---> 软件包 nodejs-json-stringify-safe.noarch.0.5.0.0-.el7 将被 安装
  101. ---> 软件包 nodejs-jsonparse.noarch.0.1.0.0-.el7 将被 安装
  102. ---> 软件包 nodejs-mime.noarch.0.1.2.11-.el7 将被 安装
  103. ---> 软件包 nodejs-node-uuid.noarch.0.1.4.1-.el7 将被 安装
  104. ---> 软件包 nodejs-oauth-sign.noarch.0.0.3.0-.el7 将被 安装
  105. ---> 软件包 nodejs-qs.noarch.0.0.6.6-.el7 将被 安装
  106. ---> 软件包 nodejs-through.noarch.0.2.3.4-.el7 将被 安装
  107. ---> 软件包 nodejs-tunnel-agent.noarch.0.0.3.0-.el7 将被 安装
  108. ---> 软件包 nodejs-wordwrap.noarch.0.0.0.2-.el7 将被 安装
  109. ---> 软件包 npm.x86_64.1.3.10.10-1.6.11.1..el7 将被 安装
  110. --> 正在检查事务
  111. ---> 软件包 nodejs-asn1.noarch.0.0.1.11-.el7 将被 安装
  112. ---> 软件包 nodejs-assert-plus.noarch.0.0.1.4-.el7 将被 安装
  113. ---> 软件包 nodejs-boom.noarch.0.0.4.2-.el7 将被 安装
  114. ---> 软件包 nodejs-combined-stream.noarch.0.0.0.4-.el7 将被 安装
  115. --> 正在处理依赖关系 npm(delayed-stream) = 0.0.,它被软件包 nodejs-combined-stream-0.0.-.el7.noarch 需要
  116. ---> 软件包 nodejs-cryptiles.noarch.0.0.2.2-.el7 将被 安装
  117. ---> 软件包 nodejs-ctype.noarch.0.0.5.3-.el7 将被 安装
  118. ---> 软件包 nodejs-hoek.noarch.0.0.9.1-.el7 将被 安装
  119. ---> 软件包 nodejs-sntp.noarch.0.0.2.4-.el7 将被 安装
  120. --> 正在检查事务
  121. ---> 软件包 nodejs-delayed-stream.noarch.0.0.0.5-.el7 将被 安装
  122. --> 解决依赖关系完成
  123.  
  124. 依赖关系解决
  125.  
  126. ===============================================================================================================================================================================================
  127. Package 架构 版本 大小
  128. ===============================================================================================================================================================================================
  129. 正在安装:
  130. elasticdump noarch 2.2.-.el7 epel k
  131. 为依赖而安装:
  132. http-parser x86_64 2.7.-.el7_4 updates k
  133. libuv x86_64 :1.10.-.el7 epel k
  134. nodejs x86_64 :6.11.-.el7 epel 4.5 M
  135. nodejs-asn1 noarch 0.1.-.el7 epel k
  136. nodejs-assert-plus noarch 0.1.-.el7 epel 7.3 k
  137. nodejs-async noarch 0.2.-.el7 epel k
  138. nodejs-aws-sign noarch 0.3.-.el7 epel 5.7 k
  139. nodejs-boom noarch 0.4.-.el7 epel k
  140. nodejs-combined-stream noarch 0.0.-.el7 epel 7.9 k
  141. nodejs-cookie-jar noarch :0.3.-.el7 epel 6.1 k
  142. nodejs-cryptiles noarch 0.2.-.el7 epel 6.9 k
  143. nodejs-ctype noarch 0.5.-.el7 epel k
  144. nodejs-delayed-stream noarch 0.0.-.el7 epel 7.9 k
  145. nodejs-forever-agent noarch 0.5.-.el7 epel 5.6 k
  146. nodejs-form-data noarch 0.1.-.el7 epel k
  147. nodejs-hawk noarch 1.0.-.el7 epel k
  148. nodejs-hoek noarch 0.9.-.el7 epel k
  149. nodejs-http-signature noarch 0.10.-.el7 epel k
  150. nodejs-json-stringify-safe noarch 5.0.-.el7 epel 6.6 k
  151. nodejs-jsonparse noarch 1.0.-.el7 epel k
  152. nodejs-jsonstream noarch 0.10.-.el7 epel 9.5 k
  153. nodejs-mime noarch 1.2.-.el7 epel k
  154. nodejs-node-uuid noarch 1.4.-.el7 epel k
  155. nodejs-oauth-sign noarch 0.3.-.el7 epel 4.9 k
  156. nodejs-optimist noarch 0.4.-.el7 epel k
  157. nodejs-qs noarch 0.6.-.el7 epel 8.7 k
  158. nodejs-request noarch 2.25.-.el7 epel k
  159. nodejs-sntp noarch 0.2.-.el7 epel k
  160. nodejs-through noarch 2.3.-.el7 epel 7.1 k
  161. nodejs-tunnel-agent noarch 0.3.-.el7 epel 6.3 k
  162. nodejs-wordwrap noarch 0.0.-.el7 epel 6.4 k
  163. npm x86_64 :3.10.-1.6.11.1..el7 epel 2.5 M
  164.  
  165. 事务概要
  166. ===============================================================================================================================================================================================
  167. 安装 软件包 (+ 依赖软件包)
  168.  
  169. 总下载量:7.7 M
  170. 安装大小: M
  171. Is this ok [y/d/N]: y
  172. Downloading packages:
  173. (/): http-parser-2.7.-.el7_4.x86_64.rpm | kB ::
  174. (/): elasticdump-2.2.-.el7.noarch.rpm | kB ::
  175. (/): libuv-1.10.-.el7.x86_64.rpm | kB ::
  176. (/): nodejs-6.11.-.el7.x86_64.rpm | 4.5 MB ::
  177. (/): nodejs-asn1-0.1.-.el7.noarch.rpm | kB ::
  178. (/): nodejs-assert-plus-0.1.-.el7.noarch.rpm | 7.3 kB ::
  179. (/): nodejs-async-0.2.-.el7.noarch.rpm | kB ::
  180. (/): nodejs-aws-sign-0.3.-.el7.noarch.rpm | 5.7 kB ::
  181. (/): nodejs-boom-0.4.-.el7.noarch.rpm | kB ::
  182. (/): nodejs-combined-stream-0.0.-.el7.noarch.rpm | 7.9 kB ::
  183. (/): nodejs-cookie-jar-0.3.-.el7.noarch.rpm | 6.1 kB ::
  184. (/): nodejs-cryptiles-0.2.-.el7.noarch.rpm | 6.9 kB ::
  185. (/): nodejs-ctype-0.5.-.el7.noarch.rpm | kB ::
  186. (/): nodejs-delayed-stream-0.0.-.el7.noarch.rpm | 7.9 kB ::
  187. (/): nodejs-forever-agent-0.5.-.el7.noarch.rpm | 5.6 kB ::
  188. (/): nodejs-form-data-0.1.-.el7.noarch.rpm | kB ::
  189. (/): nodejs-hawk-1.0.-.el7.noarch.rpm | kB ::
  190. (/): nodejs-hoek-0.9.-.el7.noarch.rpm | kB ::
  191. (/): nodejs-http-signature-0.10.-.el7.noarch.rpm | kB ::
  192. (/): nodejs-json-stringify-safe-5.0.-.el7.noarch.rpm | 6.6 kB ::
  193. (/): nodejs-jsonparse-1.0.-.el7.noarch.rpm | kB ::
  194. (/): nodejs-jsonstream-0.10.-.el7.noarch.rpm | 9.5 kB ::
  195. (/): nodejs-mime-1.2.-.el7.noarch.rpm | kB ::
  196. (/): nodejs-node-uuid-1.4.-.el7.noarch.rpm | kB ::
  197. (/): nodejs-oauth-sign-0.3.-.el7.noarch.rpm | 4.9 kB ::
  198. (/): nodejs-optimist-0.4.-.el7.noarch.rpm | kB ::
  199. (/): nodejs-qs-0.6.-.el7.noarch.rpm | 8.7 kB ::
  200. (/): nodejs-request-2.25.-.el7.noarch.rpm | kB ::
  201. (/): nodejs-sntp-0.2.-.el7.noarch.rpm | kB ::
  202. (/): nodejs-through-2.3.-.el7.noarch.rpm | 7.1 kB ::
  203. (/): nodejs-tunnel-agent-0.3.-.el7.noarch.rpm | 6.3 kB ::
  204. (/): nodejs-wordwrap-0.0.-.el7.noarch.rpm | 6.4 kB ::
  205. (/): npm-3.10.-1.6.11.1..el7.x86_64.rpm | 2.5 MB ::
  206. -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  207. 总计 2.0 MB/s | 7.7 MB ::
  208. Running transaction check
  209. Running transaction test
  210. Transaction test succeeded
  211. Running transaction
  212. 警告:RPM 数据库已被非 yum 程序修改。
  213. ** 发现 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
  214. rhn-check-2.0.-.el7.noarch 有缺少的需求 yum-rhn-plugin >= ('', '1.6.4', '')
  215. 正在安装 : :libuv-1.10.-.el7.x86_64 /
  216. 正在安装 : http-parser-2.7.-.el7_4.x86_64 /
  217. 正在安装 : :npm-3.10.-1.6.11.1..el7.x86_64 /
  218. 正在安装 : :nodejs-6.11.-.el7.x86_64 /
  219. 正在安装 : nodejs-hoek-0.9.-.el7.noarch /
  220. 正在安装 : nodejs-boom-0.4.-.el7.noarch /
  221. 正在安装 : nodejs-mime-1.2.-.el7.noarch /
  222. 正在安装 : nodejs-async-0.2.-.el7.noarch /
  223. 正在安装 : nodejs-cryptiles-0.2.-.el7.noarch /
  224. 正在安装 : nodejs-sntp-0.2.-.el7.noarch /
  225. 正在安装 : nodejs-hawk-1.0.-.el7.noarch /
  226. 正在安装 : nodejs-forever-agent-0.5.-.el7.noarch /
  227. 正在安装 : nodejs-aws-sign-0.3.-.el7.noarch /
  228. 正在安装 : nodejs-qs-0.6.-.el7.noarch /
  229. 正在安装 : nodejs-wordwrap-0.0.-.el7.noarch /
  230. 正在安装 : nodejs-optimist-0.4.-.el7.noarch /
  231. 正在安装 : nodejs-assert-plus-0.1.-.el7.noarch /
  232. 正在安装 : nodejs-oauth-sign-0.3.-.el7.noarch /
  233. 正在安装 : nodejs-tunnel-agent-0.3.-.el7.noarch /
  234. 正在安装 : nodejs-asn1-0.1.-.el7.noarch /
  235. 正在安装 : nodejs-delayed-stream-0.0.-.el7.noarch /
  236. 正在安装 : nodejs-combined-stream-0.0.-.el7.noarch /
  237. 正在安装 : nodejs-form-data-0.1.-.el7.noarch /
  238. 正在安装 : :nodejs-cookie-jar-0.3.-.el7.noarch /
  239. 正在安装 : nodejs-jsonparse-1.0.-.el7.noarch /
  240. 正在安装 : nodejs-through-2.3.-.el7.noarch /
  241. 正在安装 : nodejs-jsonstream-0.10.-.el7.noarch /
  242. 正在安装 : nodejs-node-uuid-1.4.-.el7.noarch /
  243. 正在安装 : nodejs-ctype-0.5.-.el7.noarch /
  244. 正在安装 : nodejs-http-signature-0.10.-.el7.noarch /
  245. 正在安装 : nodejs-json-stringify-safe-5.0.-.el7.noarch /
  246. 正在安装 : nodejs-request-2.25.-.el7.noarch /
  247. 正在安装 : elasticdump-2.2.-.el7.noarch /
  248. 验证中 : elasticdump-2.2.-.el7.noarch /
  249. 验证中 : nodejs-forever-agent-0.5.-.el7.noarch /
  250. 验证中 : nodejs-aws-sign-0.3.-.el7.noarch /
  251. 验证中 : nodejs-qs-0.6.-.el7.noarch /
  252. 验证中 : http-parser-2.7.-.el7_4.x86_64 /
  253. 验证中 : nodejs-combined-stream-0.0.-.el7.noarch /
  254. 验证中 : nodejs-wordwrap-0.0.-.el7.noarch /
  255. 验证中 : nodejs-assert-plus-0.1.-.el7.noarch /
  256. 验证中 : nodejs-oauth-sign-0.3.-.el7.noarch /
  257. 验证中 : nodejs-hoek-0.9.-.el7.noarch /
  258. 验证中 : nodejs-cryptiles-0.2.-.el7.noarch /
  259. 验证中 : nodejs-jsonstream-0.10.-.el7.noarch /
  260. 验证中 : nodejs-request-2.25.-.el7.noarch /
  261. 验证中 : nodejs-http-signature-0.10.-.el7.noarch /
  262. 验证中 : :libuv-1.10.-.el7.x86_64 /
  263. 验证中 : nodejs-tunnel-agent-0.3.-.el7.noarch /
  264. 验证中 : nodejs-mime-1.2.-.el7.noarch /
  265. 验证中 : nodejs-hawk-1.0.-.el7.noarch /
  266. 验证中 : nodejs-asn1-0.1.-.el7.noarch /
  267. 验证中 : nodejs-delayed-stream-0.0.-.el7.noarch /
  268. 验证中 : :npm-3.10.-1.6.11.1..el7.x86_64 /
  269. 验证中 : nodejs-optimist-0.4.-.el7.noarch /
  270. 验证中 : nodejs-sntp-0.2.-.el7.noarch /
  271. 验证中 : nodejs-form-data-0.1.-.el7.noarch /
  272. 验证中 : :nodejs-cookie-jar-0.3.-.el7.noarch /
  273. 验证中 : nodejs-boom-0.4.-.el7.noarch /
  274. 验证中 : :nodejs-6.11.-.el7.x86_64 /
  275. 验证中 : nodejs-jsonparse-1.0.-.el7.noarch /
  276. 验证中 : nodejs-through-2.3.-.el7.noarch /
  277. 验证中 : nodejs-node-uuid-1.4.-.el7.noarch /
  278. 验证中 : nodejs-ctype-0.5.-.el7.noarch /
  279. 验证中 : nodejs-async-0.2.-.el7.noarch /
  280. 验证中 : nodejs-json-stringify-safe-5.0.-.el7.noarch /
  281.  
  282. 已安装:
  283. elasticdump.noarch :2.2.-.el7
  284.  
  285. 作为依赖被安装:
  286. http-parser.x86_64 :2.7.-.el7_4 libuv.x86_64 :1.10.-.el7 nodejs.x86_64 :6.11.-.el7 nodejs-asn1.noarch :0.1.-.el7
  287. nodejs-assert-plus.noarch :0.1.-.el7 nodejs-async.noarch :0.2.-.el7 nodejs-aws-sign.noarch :0.3.-.el7 nodejs-boom.noarch :0.4.-.el7
  288. nodejs-combined-stream.noarch :0.0.-.el7 nodejs-cookie-jar.noarch :0.3.-.el7 nodejs-cryptiles.noarch :0.2.-.el7 nodejs-ctype.noarch :0.5.-.el7
  289. nodejs-delayed-stream.noarch :0.0.-.el7 nodejs-forever-agent.noarch :0.5.-.el7 nodejs-form-data.noarch :0.1.-.el7 nodejs-hawk.noarch :1.0.-.el7
  290. nodejs-hoek.noarch :0.9.-.el7 nodejs-http-signature.noarch :0.10.-.el7 nodejs-json-stringify-safe.noarch :5.0.-.el7 nodejs-jsonparse.noarch :1.0.-.el7
  291. nodejs-jsonstream.noarch :0.10.-.el7 nodejs-mime.noarch :1.2.-.el7 nodejs-node-uuid.noarch :1.4.-.el7 nodejs-oauth-sign.noarch :0.3.-.el7
  292. nodejs-optimist.noarch :0.4.-.el7 nodejs-qs.noarch :0.6.-.el7 nodejs-request.noarch :2.25.-.el7 nodejs-sntp.noarch :0.2.-.el7
  293. nodejs-through.noarch :2.3.-.el7 nodejs-tunnel-agent.noarch :0.3.-.el7 nodejs-wordwrap.noarch :0.0.-.el7 npm.x86_64 :3.10.-1.6.11.1..el7
  294.  
  295. 完毕!
  296. [root@localhost ~]#

elasticdump相关功能描述:

  1. [root@localhost ~]# elasticdump --help
  2. elasticdump: Import and export tools for elasticsearch
  3. version: 2.2.
  4.  
  5. Usage: elasticdump --input SOURCE --output DESTINATION [OPTIONS]
  6.  
  7. --input
  8. Source location (required)
  9. --input-index
  10. Source index and type
  11. (default: all, example: index/type)
  12. --output
  13. Destination location (required)
  14. --output-index
  15. Destination index and type
  16. (default: all, example: index/type)
  17. --limit
  18. How many objects to move in batch per operation
  19. limit is approximate for file streams
  20. (default: )
  21. --debug
  22. Display the elasticsearch commands being used
  23. (default: false)
  24. --type
  25. What are we exporting?
  26. (default: data, options: [data, mapping])
  27. --delete
  28. Delete documents one-by-one from the input as they are
  29. moved. Will not delete the source index
  30. (default: false)
  31. --searchBody
  32. Preform a partial extract based on search results
  33. (when ES is the input,
  34. (default: '{"query": { "match_all": {} } }'))
  35. --sourceOnly
  36. Output only the json contained within the document _source
  37. Normal: {"_index":"","_type":"","_id":"", "_source":{SOURCE}}
  38. sourceOnly: {SOURCE}
  39. (default: false)
  40. --all
  41. Load/store documents from ALL indexes
  42. (default: false)
  43. --ignore-errors
  44. Will continue the read/write loop on write error
  45. (default: false)
  46. --scrollTime
  47. Time the nodes will hold the requested search in order.
  48. (default: 10m)
  49. --maxSockets
  50. How many simultaneous HTTP requests can we process make?
  51. (default:
  52. [node <= v0..x] /
  53. Infinity [node >= v0..x] )
  54. --timeout
  55. Integer containing the number of milliseconds to wait for
  56. a request to respond before aborting the request. Passed
  57. directly to the request library. Mostly used when you don't
  58. care too much if you lose some data when importing
  59. but rather have speed.
  60. --offset
  61. Integer containing the number of rows you wish to skip
  62. ahead from the input transport. When importing a large
  63. index, things can go wrong, be it connectivity, crashes,
  64. someone forgetting to `screen`, etc. This allows you
  65. to start the dump again from the last known line written
  66. (as logged by the `offset` in the output). Please be
  67. advised that since no sorting is specified when the
  68. dump is initially created, there's no real way to
  69. guarantee that the skipped rows have already been
  70. written/parsed. This is more of an option for when
  71. you want to get most data as possible in the index
  72. without concern for losing some rows in the process,
  73. similar to the `timeout` option.
  74. --inputTransport
  75. Provide a custom js file to us as the input transport
  76. --outputTransport
  77. Provide a custom js file to us as the output transport
  78. --toLog
  79. When using a custom outputTransport, should log lines
  80. be appended to the output stream?
  81. (default: true, except for `$`)
  82. --help
  83. This page
  84.  
  85. Examples:
  86.  
  87. # Copy an index from production to staging with mappings:
  88. elasticdump \
  89. --input=http://production.es.com:9200/my_index \
  90. --output=http://staging.es.com:9200/my_index \
  91. --type=mapping
  92. elasticdump \
  93. --input=http://production.es.com:9200/my_index \
  94. --output=http://staging.es.com:9200/my_index \
  95. --type=data
  96.  
  97. # Backup index data to a file:
  98. elasticdump \
  99. --input=http://production.es.com:9200/my_index \
  100. --output=/data/my_index_mapping.json \
  101. --type=mapping
  102. elasticdump \
  103. --input=http://production.es.com:9200/my_index \
  104. --output=/data/my_index.json \
  105. --type=data
  106.  
  107. # Backup and index to a gzip using stdout:
  108. elasticdump \
  109. --input=http://production.es.com:9200/my_index \
  110. --output=$ \
  111. | gzip > /data/my_index.json.gz
  112.  
  113. # Backup the results of a query to a file
  114. elasticdump \
  115. --input=http://production.es.com:9200/my_index \
  116. --output=query.json \
  117. --searchBody '{"query":{"term":{"username": "admin"}}}'
  118.  
  119. ------------------------------------------------------------------------------
  120. Learn more @ https://github.com/taskrabbit/elasticsearch-dump
  121.  
  122. [root@localhost ~]#

重点说明:
依据上述的帮助文件,我们重点看elasticdump --input SOURCE --output DESTINATION
这里的source和destination可以是es的数据源,也可以是文件。也就是说,这个命令elasticdump既可以完成数据的导出,也可以完成数据的导入。
当表示es的数据源时,必须是{protocol}://{host}:{port}/{index}.

1. 将es集群中的某个index的数据导出到文件中

  1. [root@localhost ~]# elasticdump --input http://10.90.7.10:9200/robotkdb --output /opt/shihuc/robotkdb.json
  2. Thu, Sep :: GMT | starting dump
  3. Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
  4. Thu, Sep :: GMT | sent objects to destination file, wrote
  5. Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
  6. Thu, Sep :: GMT | sent objects to destination file, wrote
  7. Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
  8. Thu, Sep :: GMT | sent objects to destination file, wrote
  9. Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
  10. Thu, Sep :: GMT | Total Writes:
  11. Thu, Sep :: GMT | dump complete
  12. [root@localhost ~]#

2.直接删除指定的type下的内容

  1. [root@localhost ~]# curl -XDELETE "http://10.90.7.10:9200/robotkdb/weibao?v"
  2. No handler found for uri [/robotkdb/weibao?v] and method [DELETE][root@localhost ~]#

删除不成功。
查询资料显示说,ES2.x版本以上的系统中,禁止了直接删除type

那我要快速删除一个type的内容,该如何处理呢?其实是有的,安装delete-by-query的插件进行。安装完成后,将Elasticsearch重启一下

  1. [root@localhost bin]# ll
  2. 总用量
  3. -rwxr-xr-x es es 8 elasticsearch
  4. -rw-rw-r-- es es 8 elasticsearch.bat
  5. -rw-rw-r-- es es 9 elasticsearch.in.bat
  6. -rwxr-xr-x es es 8 elasticsearch.in.sh
  7. -rw-rw-r-- es es 7 elasticsearch-service-mgr.exe
  8. -rw-rw-r-- es es 7 elasticsearch-service-x64.exe
  9. -rw-rw-r-- es es 7 elasticsearch-service-x86.exe
  10. -rwxr-xr-x es es 8 plugin
  11. -rw-rw-r-- es es 8 plugin.bat
  12. -rw-rw-r-- es es 8 service.bat
  13. [root@localhost bin]# ./plugin install delete-by-query #注意,要到elasticsearch的安装路径下的bin下面执行这个命令
  14. -> Installing delete-by-query...
  15. Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/delete-by-query/2.4.1/delete-by-query-2.4.1.zip ...
  16. Downloading ..DONE
  17. Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/delete-by-query/2.4.1/delete-by-query-2.4.1.zip checksums if available ...
  18. Downloading .DONE
  19. Installed delete-by-query into /opt/ES/elasticsearch-2.4./plugins/delete-by-query
  20. [root@localhost bin]#

重启elasticsearch的过程,就不描述了。然后再用命令执行删除指定的type的数据:

  1. [root@localhost ES]# curl -XDELETE "http://10.90.7.10:9200/robotkdb/weibao/_query?pretty" -d '{
  2. "query":{
  3. "match_all":{}
  4. }}'
  5. {
  6. "took" : ,
  7. "timed_out" : false,
  8. "_indices" : {
  9. "_all" : {
  10. "found" : ,
  11. "deleted" : ,
  12. "missing" : ,
  13. "failed" :
  14. },
  15. "robotkdb" : {
  16. "found" : ,
  17. "deleted" : ,
  18. "missing" : ,
  19. "failed" :
  20. }
  21. },
  22. "failures" : [ ]
  23. }
  24. [root@localhost ES]#

从上述结果看,没有错误。那么,再去查看下,weibao这个type下,还有没有数据!

  1. [root@localhost ES]# curl -XGET "http://10.90.7.10:9200/robotkdb/weibao/_search?pretty"
  2. {
  3. "took" : ,
  4. "timed_out" : false,
  5. "_shards" : {
  6. "total" : ,
  7. "successful" : ,
  8. "failed" :
  9. },
  10. "hits" : {
  11. "total" : ,
  12. "max_score" : null,
  13. "hits" : [ ]
  14. }
  15. }

说明删除指定type的内容成功了。

3. elasticdump数据恢复

那最后再来恢复下刚才删除掉的208个记录吧。前面不是备份了一个数据吗,在这个文件里面/opt/shihuc/robotkdb.json

  1. [root@localhost shihuc]# elasticdump --input /opt/shihuc/robotkdb.json --output "http://10.90.7.10:9200/robotkdb"
  2. Thu, Sep :: GMT | starting dump
  3. Thu, Sep :: GMT | got objects from source file (offset: )
  4. Thu, Sep :: GMT | sent objects to destination elasticsearch, wrote
  5. Thu, Sep :: GMT | got objects from source file (offset: )
  6. Thu, Sep :: GMT | sent objects to destination elasticsearch, wrote
  7. Thu, Sep :: GMT | got objects from source file (offset: )
  8. Thu, Sep :: GMT | Total Writes:
  9. Thu, Sep :: GMT | dump complete

最后在浏览器上访问看看吧,验证数据载入、恢复是否成功!

Elasticsearch的数据备份,删除以及恢复逻辑,到此验证完毕!

总结:

1. Elasticsearch的2.x以上版本不支持直接删除type级别的数据。支持删除index,也支持逐个id的删除。

2. Elasticsearch的数据备份和恢复,没有直接的指令操作,需要安装插件elasticdump来实现。

Elasticsearch的数据导出和导入操作(elasticdump工具),以及删除指定type的数据(delete-by-query插件)的更多相关文章

  1. PCB MS SERVER 数据导出与导入操作步骤----使用第3方工具

    工作每天都与数据库打交道,经常会遇到一些需要将数据库中的数据导出来或将数据导入到数据库 而用微软数据库客户端自带的功能操作步骤好麻烦的,用过的大家都会有相同的感受吧. 微软客户端不好之处整理:这里吐槽 ...

  2. memcached命令行、Memcached数据导出和导入、php连接memcache、php的session存储到memcached

    1.memcached命令行 telnet 127.0.0.1 11211set key2 0 30 2abSTOREDget key2VALUE key2 0 2abEND  如: set key3 ...

  3. memcached命令行、Memcached数据导出和导入

    1.memcached命令行 telnet 127.0.0.1 11211set key2 0 30 2abSTOREDget key2VALUE key2 0 2abEND  如: set key3 ...

  4. elasticsearch 2.4在head删除数据(使用Delete By Query插件)

    之所以说明是2.4版,是因为不同版本删除的语法不一样(例如跟5.x就不同) 首先安装Delete By Query插件,方式跟安装head插件差不多,安装命令:plugin install delet ...

  5. MYSQL数据导出与导入,secure_file_priv参数设置

    https://www.imooc.com/article/41883 MySQL 报错 [Code: 1290, SQL State: HY000]  The MySQL server is run ...

  6. DB2表数据导出、导入及常用sql使用总结

      一.DB2数据的导出: export to [path(例:D:"TABLE1.ixf)]of ixf select [字段(例: * or col1,col2,col3)] from ...

  7. mongoDB 数据导出与导入

    一.导出 命令格式:在mongodb/bin目录下 mongoexport -h IP --port 端口 -u 用户名 -p 密码 -d 数据库 -c 表名 -f 字段 -q 条件导出 --csv ...

  8. oracle数据库数据导出和导入

    oracle的客户端里面的bin下面有两个可执行文件,名称分别为exp.exe和imp.exe. 他俩的用途就是导出和导入数据用的. 全库 导出:exp 用户名/密码@数据库名 full=y file ...

  9. mysql创建账号、授权、数据导出、导入

    1.账号创建及授权 grant all privileges on *.* to 'yangxin'@'%' identified by 'yangxin123456' with grant opti ...

随机推荐

  1. web前端优化

    在谈到Web优化之前,我们回到一个更原始的问题,Web前端的本质是什么.我的理解是: 将信息快速并友好的展示给用户并能够与用户进行交互.快速的意思就是在尽可能短的时间内完成页面的加载,试想一下当你在淘 ...

  2. ubuntu16.04系统安装

    0x1镜像下载 (1)下载地址http://cn.ubuntu.com/download/ 0x2 安装 (1)打开vmware,创建新的虚拟机 (2)选择自定义安装 (3)直接下一步,选择稍后安装系 ...

  3. 5个适用于初学者的有用数据分析表达式(DAX)函数

    数据分析表达式(DAX)入门可能令人生畏,但是,当你了解一些基本功能后,你就可以帮助你解答许多有关数据的新见解.虽然在Power BI或Pivot Charts中创建视觉效果很容易,但我们经常希望查看 ...

  4. [转]Skynet之斗转星移 - 将控制权交给Lua

      Skynet之斗转星移 - 将控制权交给Lua http://www.outsky.org/code/skynet-lua.html Sep 7, 2014 在我看来,Skynet的一个重要优势是 ...

  5. JAVA小程序-----买衣服

    import java.util.Scanner; //引用扫描器 public class TestDemo1 { public static void main(String [] args){ ...

  6. Implementing a CNN for Text Classification in TensorFlow

    参考: 1.Understanding Convolutional Neural Networks for NLP 2.Implementing a CNN for Text Classificati ...

  7. day 017面向对象-反射

    主要内容: isinstance, type, issubclass( 内置函数) 区分函数和方法 反射 一    ( isinstance, type, issubclass) isinstance ...

  8. POJ 2751:Seek the Name, Seek the Fame(Hash)

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24077   Ac ...

  9. linux 执行脚本

    crontab -e 直接编辑定时脚本 保存后,在/var/spool/cron/下自动生成一个以用户名命名的脚本文件.

  10. 02 http,servlet,servletconfig,HttpServletRequest ,HttpServletResponse

    Http协议 协议:双方在交互.通讯的时候, 遵守的一种规范.规则.http协议:针对网络上的客户端 与 服务器端在执行http请求的时候,遵守的一种规范. 其实就是规定了客户端在访问服务器端的时候, ...