使用node安裝elasticdump
[root@ops ~]# node -v
v14.17.6
[root@ops ~]# npm install elasticdump
查看你源es里面的索引有哪些
[root@ops ~]# curl -i -XGET http://"elastic:JNKtUf5B4Oe5Ivqnuc"@es-cn-g4t3gxrui0004zm5z.elasticsearch.aliyuncs.com:9200/_cat/indices?v
HTTP/1.1 200 OK
content-type: text/plain; charset=UTF-8
content-length: 3302
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open wechat_user_info _Svz4qDETIOEvbAzTewliw 5 2 0 0 3kb 1kb
green open extension lpbxnzr-QUqmXxrDK60cmw 5 2 0 0 3kb 1kb
green open customer_user_account mlSUhQXORRSYx9MJbsBorQ 5 2 572 0 1.3mb 471.3kb
green open user_message s6SW_rpSR8GmBcIsifZ3-w 5 2 0 0 3kb 1kb
green open house 6XhO-UbhTT-LwNdtqw4Cdg 5 2 583682 0 1.1gb 385.7mb
green open customer_anonymous_account CQMKkjBiTGiVdhZIseR6VA 5 2 45 0 317.8kb 105.9kb
green open .apm-custom-link WstOEQxiRL24INfhnphqFQ 1 1 0 0 416b 208b
green open post fSEore4oRhGM44d_eLteZg 5 2 184 0 1mb 347.7kb
green open .kibana_task_manager_1 MBCwBsDVQAWTvQdZQgldrw 1 1 5 1 81.9kb 40.9kb
green open user_info 2re7MgtNTm6r-hvcoZZg8Q 5 2 12 0 196.4kb 65.4kb
green open .monitoring-kibana-7-2023.11.07 YSQsl3cuQhOi9asP58b_Zw 1 1 2 0 22.5kb 11.2kb
green open .monitoring-kibana-7-2023.11.08 8szT0oGFRLSyZOpY8fWD1Q 1 1 1 0 23.1kb 11.5kb
green open .monitoring-es-7-2023.11.07 dSbM9udXTgy4yQQpvnS83g 1 1 119236 229108 151.7mb 76.1mb
green open business_user_account wGvSv211TSyvhEcy-Nzvcw 5 2 990 1 6.1mb 2mb
green open .monitoring-es-7-2023.11.08 O1fX0oAoSqCUqQ36VC3Haw 1 1 180553 319956 476.5mb 238mb
green open likes FjHgQDSYR36q2PPJQtEMwA 5 2 0 0 3kb 1kb
green open article_content Z4IGaaHpTaasHBaFKQoEcQ 5 2 5 0 82kb 27.3kb
green open business_device 1UwYwpJgRcyd5aXE2BnyCw 5 2 1853 7 4.6mb 1.5mb
green open .apm-agent-configuration 0LfqQR-jT2KqvsIva2i8KQ 1 1 0 0 416b 208b
green open .kibana_1 am8KrE9-RfuTqvsicd13Rg 1 1 3 0 54.7kb 27.3kb
green open .security-7 06D2B3WRTdKKuqWjQp0YZQ 1 1 45 0 212.4kb 99.2kb
green open customer_device -S_R9RN3SXWFGUdjaWcOZw 5 2 0 0 3kb 1kb
green open household Rdv6gBptSTysBlHz88la6w 5 2 20784 0 21.4mb 7.1mb
green open comment jtLWvgBmSPehw06Y3q0SXA 5 2 0 0 3kb 1kb
green open device QHirSqifTLOrXo4zCf_Whg 5 2 0 0 3kb 1kb
把索引存到了index.txt文件中 通過for循環(huán)把每個(gè)索引的數(shù)據(jù)都同步過去
遷移指定索引的setting --type=settings
遷移指定索引的mapping --type=mapping
遷移指定索引的data --type=data
for i in `cat index.txt`;do echo $i 開始進(jìn)行遷移&&elasticdump --input=http://"elastic:密碼"@es-cn-co92ym384.public.elasticsearch.aliyuncs.com:9200/$i --output=http://"elastic:密碼"@es-cn-gzm5.elasticsearch.aliyuncs.com:9200/$i --type=data;done