本篇內(nèi)容主要講解“Elasticsearch跨集群數(shù)據(jù)遷移怎么實(shí)現(xiàn)”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“Elasticsearch跨集群數(shù)據(jù)遷移怎么實(shí)現(xiàn)”吧!
創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括上黨網(wǎng)站建設(shè)、上黨網(wǎng)站制作、上黨網(wǎng)頁制作以及上黨網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,上黨網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到上黨省份的部分城市,未來相信會繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
| 方案 | elasticsearch-dump | reindex | snapshot | logstash |
|---|---|---|---|---|
| 基本原理 | 邏輯備份,類似MySQLdump將數(shù)據(jù)一條一條導(dǎo)出后再執(zhí)行導(dǎo)入 | reindex 是 Elasticsearch 提供的一個 API 接口,可以把數(shù)據(jù)從一個集群遷移到另外一個集群 | 從源集群通過Snapshot API 創(chuàng)建數(shù)據(jù)快照,然后在目標(biāo)集群中進(jìn)行恢復(fù) | 從一個集群中讀取數(shù)據(jù)然后寫入到另一個集群 |
| 網(wǎng)絡(luò)要求 | 集群間互導(dǎo)需要網(wǎng)絡(luò)互通,先導(dǎo)出文件再通過文件導(dǎo)入集群則不需要網(wǎng)絡(luò)互通 | 網(wǎng)絡(luò)需要互通 | 無網(wǎng)絡(luò)互通要求 | 網(wǎng)絡(luò)需要互通 |
| 遷移速度 | 慢 | 快 | 快 | 一般 |
| 適合場景 | 適用于數(shù)據(jù)量小的場景 | 適用于數(shù)據(jù)量大,在線遷移數(shù)據(jù)的場景 | 適用于數(shù)據(jù)量大,接受離線數(shù)據(jù)遷移的場景 | 適用于數(shù)據(jù)量一般,近實(shí)時數(shù)據(jù)傳輸 |
| 配置復(fù)雜度 | 中等 | 簡單 | 復(fù)雜 | 中等 |
創(chuàng)建 mapping:
PUT dumpindex
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"age": {
"type": "integer"
}
}
}
}插入數(shù)據(jù):
POST _bulk
{"index":{"_index":"dumpindex"}}
{"name":"tom","age":18}
{"index":{"_index":"dumpindex"}}
{"name":"jack","age":19}
{"index":{"_index":"dumpindex"}}
{"name":"bob","age":20}elasticsearch-dump是一款開源的ES數(shù)據(jù)遷移工具, github地址: https://github.com/taskrabbit/elasticsearch-dump
elasticsearch-dump使用node.js開發(fā),可使用npm包管理工具直接安裝:
npm install elasticdump -g
也可以之間通過啟動制作好的 elasticsearch-dump docker 容器來運(yùn)行,需要通過 -v 參數(shù)掛載宿主機(jī)的目錄到容器中
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ 加上命令
例如:
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ --input=/tmp/dumpindex.json \ #這里input的文件是容器中的文件路徑,宿主機(jī)上對應(yīng)的就是/root/elasticsearch-dump/dumpindex.json文件 --output=http://192.168.1.67:9200/dumpindex \ --type=data
通過以下命令將 Elasticsearch 中的數(shù)據(jù)導(dǎo)出到 dumpindex_data.json 文件中。
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ --input=http://192.168.1.171:9200/dumpindex \ --output=/tmp/dumpindex_data.json \ --type=data
查看文件內(nèi)容,包含了索引的數(shù)據(jù)信息:
[root@elastic1]# cat /root/elasticsearch-dump/dumpindex_data.json
{"_index":"dumpindex","_type":"_doc","_id":"q28kPngB8Nd5nYNvOgHd","_score":1,"_source":{"name":"tom","age":18}}
{"_index":"dumpindex","_type":"_doc","_id":"rG8kPngB8Nd5nYNvOgHd","_score":1,"_source":{"name":"jack","age":19}}
{"_index":"dumpindex","_type":"_doc","_id":"rW8kPngB8Nd5nYNvOgHd","_score":1,"_source":{"name":"bob","age":20}}另外還需要導(dǎo)出索引的 mapping,如果直接將前面的數(shù)據(jù)到新的 Elasticsearch 集群,新集群會根據(jù)數(shù)據(jù)自動生成 mapping,有可能和源集群的 mapping 不一致:
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ --input=http://192.168.1.171:9200/dumpindex \ --output=/tmp/dumpindex_mapping.json \ --type=mapping
查看導(dǎo)出的 mapping 文件內(nèi)容:
[root@elastic1 ~]# cat /root/elasticsearch-dump/dumpindex_mapping.json
{"dumpindex":{"mappings":{"properties":{"age":{"type":"integer"},"name":{"type":"text"}}}}}首先導(dǎo)入 mapping 信息:
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ --input=/tmp/dumpindex_mapping.json \ --output=http://192.168.1.67:9200/dumpindex \ --type=mapping
然后導(dǎo)入數(shù)據(jù):
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ --input=/tmp/dumpindex_data.json \ --output=http://192.168.1.67:9200/dumpindex \ --type=data
查看新集群上該索引的mapping信息,和源集群的一致:
GET dumpindex/_mapping
#輸出結(jié)果
{
"dumpindex" : {
"mappings" : {
"properties" : {
"age" : {
"type" : "integer"
},
"name" : {
"type" : "text"
}
}
}
}
}查看新集群的數(shù)據(jù),也和源集群的一致:
GET dumpindex/_search
#輸出結(jié)果
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "rW8kPngB8Nd5nYNvOgHd",
"_score" : 1.0,
"_source" : {
"name" : "bob",
"age" : 20
}
},
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "rG8kPngB8Nd5nYNvOgHd",
"_score" : 1.0,
"_source" : {
"name" : "jack",
"age" : 19
}
},
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "q28kPngB8Nd5nYNvOgHd",
"_score" : 1.0,
"_source" : {
"name" : "tom",
"age" : 18
}
}
]
}
}打開 Kibana 界面,創(chuàng)建 Index Pattern,然后在 Discover 中就可以看到該索引。

然后創(chuàng)建一個 Save Search 任務(wù):

創(chuàng)建完任務(wù)后,選擇生成 CSV 文件:


可以在 Reports 中下載生成的 CSV 文件:

查看導(dǎo)出的 CSV 文件:
? cat dumpindex.csv "_id","_index","_score","_type",age,name q28kPngB8Nd5nYNvOgHd,dumpindex,0,"_doc",18,tom rG8kPngB8Nd5nYNvOgHd,dumpindex,0,"_doc",19,jack rW8kPngB8Nd5nYNvOgHd,dumpindex,0,"_doc",20,bob
通過 elasticsearch-dump 命令導(dǎo)出成 CSV 文件:
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ --input=http://192.168.1.171:9200/dumpindex \ --output="csv:///tmp/dumpindex.csv"
查看導(dǎo)出的 CSV 文件:
[root@elastic1 ~]# cat /root/elasticsearch-dump/dumpindex.csv name,age,@id,@index,@type tom,18,q28kPngB8Nd5nYNvOgHd,dumpindex,_doc jack,19,rG8kPngB8Nd5nYNvOgHd,dumpindex,_doc bob,20,rW8kPngB8Nd5nYNvOgHd,dumpindex,_doc
這里需要注意的是,通過 elasticsearch-dump 命令導(dǎo)出的 CSV 文件可以直接用該命令導(dǎo)入 Elasticsearch。但是通過 Kibana 導(dǎo)出的 CSV 文件需要先將第一行(表頭)的 "_id","_index","_score","_type" 修改成自定義的其他字段(elasticsearch-dump 是改成了@開頭)才可以進(jìn)行導(dǎo)入(因?yàn)檫@些字段是 Elasticsearch 內(nèi)置的字段)。
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ --input "csv:///tmp/dumpindex.csv" \ --output=http://192.168.1.67:9200/dumpindex \ --csvSkipRows 1 #第一行(表頭)不作為數(shù)據(jù)導(dǎo)入
查看導(dǎo)入后的數(shù)據(jù),可以看到之前的 _id 等字段,其實(shí)變成了 @id,索引真正的 _id 是改變了的。因此不推薦使用通過 CSV 的方式導(dǎo)入導(dǎo)出數(shù)據(jù)。
GET dumpindex/_search
#輸出結(jié)果
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "W9OmPngBcQzbxUdL_4fB",
"_score" : 1.0,
"_source" : {
"name" : "bob",
"age" : "20",
"@id" : "rW8kPngB8Nd5nYNvOgHd",
"@index" : "dumpindex",
"@type" : "_doc"
}
},
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "XNOmPngBcQzbxUdL_4fB",
"_score" : 1.0,
"_source" : {
"name" : "jack",
"age" : "19",
"@id" : "rG8kPngB8Nd5nYNvOgHd",
"@index" : "dumpindex",
"@type" : "_doc"
}
}
]
}
}前面將 Elasticsearch 集群中的數(shù)據(jù)導(dǎo)出文件,然后再通過文件將數(shù)據(jù)導(dǎo)入新的 Elasticsearch 集群的做法適合兩個集群間網(wǎng)絡(luò)不通的情況。如果兩個集群的網(wǎng)絡(luò)相通,可以通過下面更簡便的方式直接在兩個集群間互導(dǎo)數(shù)據(jù):
先導(dǎo)出mapping到新集群
docker run --rm -ti elasticdump/elasticsearch-dump \ --input=http://192.168.1.171:9200/dumpindex \ --output=http://192.168.1.67:9200/dumpindex \ --type=mapping
然后導(dǎo)出數(shù)據(jù)到新集群:
docker run --rm -ti elasticdump/elasticsearch-dump \ --input=http://192.168.1.171:9200/dumpindex \ --output=http://192.168.1.67:9200/dumpindex \ --type=data
可以通過查詢語句過濾要遷移的數(shù)據(jù):
docker run --rm -ti elasticdump/elasticsearch-dump \
--input=http://192.168.1.171:9200/dumpindex \
--output=http://192.168.1.67:9200/dumpindex \
--searchBody="{\"query\":{\"match\":{\"name\": \"tom\"}}}"查看新集群的數(shù)據(jù):
GET dumpindex/_search
#輸出結(jié)果
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "q28kPngB8Nd5nYNvOgHd",
"_score" : 1.0,
"_source" : {
"name" : "tom",
"age" : 18
}
}
]
}
}multielasticdump 在 elasticdump 的基礎(chǔ)上做了一層封裝,可以同時 fork 出多個子線程(默認(rèn)情況下是主機(jī)的 CPU 數(shù)量)并行對多個索引進(jìn)行操作。
--input必須是URL,--output必須是文件名,也就是說只能將數(shù)據(jù)從 Elasticsearch 導(dǎo)出到文件中。導(dǎo)出的文件默認(rèn)包含索引的 data,mapping,setting,template。
正則表達(dá)式匹配并導(dǎo)出 Elasticsearch 中 dumpindex.* 的索引:
docker run --rm -ti -v /root/elasticsearch-dump:/tmp elasticdump/elasticsearch-dump \ multielasticdump \ --direction=dump \ --match='dumpindex.*' \ #支持通過正則表達(dá)式匹配索引 --input=http://192.168.1.171:9200 \ --output=/tmp
查看導(dǎo)出的文件:
[root@elastic1 ~]# ll elasticsearch-dump/total 32 -rw-r--r--. 1 root root 343 Mar 17 13:35 dumpindex2.json -rw-r--r--. 1 root root 149 Mar 17 13:35 dumpindex2.mapping.json -rw-r--r--. 1 root root 187 Mar 17 13:35 dumpindex2.settings.json -rw-r--r--. 1 root root 1581 Mar 17 13:35 dumpindex2.template.json -rw-r--r--. 1 root root 337 Mar 17 13:35 dumpindex.json -rw-r--r--. 1 root root 92 Mar 17 13:35 dumpindex.mapping.json -rw-r--r--. 1 root root 186 Mar 17 13:35 dumpindex.settings.json -rw-r--r--. 1 root root 1581 Mar 17 13:35 dumpindex.template.json
可以通過 elasticdump 將文件數(shù)據(jù)導(dǎo)入 Elasticsearch 中。
如果 Elasticsearch 需要認(rèn)證用戶名密碼,可以通過如下方式指定:
--input=http://username:password@192.168.1.171:9200/my_index
首先需要在目標(biāo) Elasticsearch 集群中配置白名單,編輯 elasticsearch.yml 文件,然后重新啟動集群:
reindex.remote.whitelist: 192.168.1.171:9200
在目標(biāo)集群上執(zhí)行 reindex 命令:
POST _reindex
{
"source": {
"remote": {
"host": "http://192.168.1.171:9200"
#如果需要用戶認(rèn)證
#"username": "user",
#"password": "pass",
},
"index": "kibana_sample_data_flights"
# 也支持通過查詢語句過濾
},
"dest": {
"index": "kibana_sample_data_flights"
}
}篩選出 reindex 任務(wù):
GET _tasks?actions=*reindex
查詢具體 reindex 任務(wù)的執(zhí)行情況:
GET _tasks/pMrJwVGSQcSgeTZdh71QRw:1413
Snapshot API 是 Elasticsearch 用于對數(shù)據(jù)進(jìn)行備份和恢復(fù)的一組 API 接口,可以通過 Snapshot API 進(jìn)行跨集群的數(shù)據(jù)遷移,原理就是從源 Elasticsearch 集群創(chuàng)建數(shù)據(jù)快照,然后在目標(biāo) Elasticsearch 集群中進(jìn)行恢復(fù)。
創(chuàng)建快照前先要注冊 Repository , 一個 Repository 可以包含多份快照文件, Repository 主要有以下幾種類型:
fs: 共享文件系統(tǒng),將快照文件存放于文件系統(tǒng)中 url: 指定文件系統(tǒng)的URL路徑,支持協(xié)議:http,https,ftp,file,jar s3: AWS S3對象存儲,快照存放于S3中,以插件形式支持 hdfs: 快照存放于hdfs中,以插件形式支持 azure: 快照存放于azure對象存儲中,以插件形式支持 gcs: 快照存放于google cloud對象存儲中,以插件形式支持
我們這里選擇共享文件系統(tǒng)的方式作為 Repository,首先部署一臺 NFS 服務(wù)器,用于文件共享。
安裝 NFS:
yum install -y nfs-utils systemctlenable nfs.service --now
創(chuàng)建相關(guān)目錄:
mkdir /home/elasticsearch/snapshot chmod 777 /home/elasticsearch/snapshot
編輯 NFS 配置文件 /etc/exports:
# rw 讀寫權(quán)限,sync 同步寫入硬盤 /home/elasticsearch/snapshot 192.168.1.0/24(rw,sync)
修改完成后重新 NFS 服務(wù):
systemctl restart nfs
編輯 /etc/fstab文件,添加如下內(nèi)容:
192.168.1.65:/home/elasticsearch/snapshot /home/elasticsearch/snapshot/ nfs defaults 0 0
編輯完成后執(zhí)行 mount 命令掛載:
[root@elastic1 ~]# mount -a # 查看掛載點(diǎn) [root@elastic1 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on ... 192.168.1.65:/home/elasticsearch/snapshot nfs 142G 39M 142G 1% /home/elasticsearch/snapshot
編輯 elasticsearch.yml 文件,添加如下內(nèi)容:
path.repo: ["/home/elasticsearch/snapshot"]
添加完成后重啟 Elasticsearch,然后通過如下命令可以驗(yàn)證是否添加 repo 目錄成功:
GET _cluster/settings?include_defaults&filter_path=*.path.repo
# 輸出結(jié)果
{
"defaults" : {
"path" : {
"repo" : [
"/home/elasticsearch/snapshot"
]
}
}
}注冊一個名為 dumpindex 的 Repository:
PUT /_snapshot/my_fs_backup
{
"type": "fs",
"settings": {
"location": "/home/elasticsearch/snapshot/dumpindex", #可以就寫dumpindex,相對路徑
"compress": true
}
}查看 RRepository 在各個節(jié)點(diǎn)上的注冊情況:
POST _snapshot/my_fs_backup/_verify
#輸出結(jié)果
{
"nodes" : {
"MjS0guiLSMq3Oouh008uSg" : {
"name" : "elastic3"
},
"V-UXoQMkQYWi5RvkjcO_yw" : {
"name" : "elastic2"
},
"9NPH3gJoQAWfgEovS8ww4w" : {
"name" : "elastic4"
},
"gdUSuXuhQ7GvPogi0RqvDw" : {
"name" : "elastic1"
}
}
}indices:做快照的索引。
wait_for_completion=true:是否等待完成快照后再響應(yīng),如果為true會等快照完成后才響應(yīng)。(默認(rèn)為false,不等快照完成立即響應(yīng))
ignore_unavailable: 設(shè)置為true時,當(dāng)創(chuàng)建快照時忽略不存在的索引。
include_global_state: 設(shè)置為false時,當(dāng)某個索引所有的主分片不是全部的都可用時,可以完成快照。
通過如下命令指定對 dumpindex 索引做快照:
PUT _snapshot/my_fs_backup/snapshot_1?wait_for_completion=true
{
"indices": "dumpindex",
"ignore_unavailable": true,
"include_global_state": false
}
# 輸出結(jié)果
{
"snapshot" : {
"snapshot" : "snapshot_1",
"uuid" : "cTvmz15pQzedDE-fHbzsCQ",
"version_id" : 7110199,
"version" : "7.11.1",
"indices" : [
"dumpindex"
],
"data_streams" : [ ],
"include_global_state" : false,
"state" : "SUCCESS",
"start_time" : "2021-03-17T14:33:20.866Z",
"start_time_in_millis" : 1615991600866,
"end_time" : "2021-03-17T14:33:21.067Z",
"end_time_in_millis" : 1615991601067,
"duration_in_millis" : 201,
"failures" : [ ],
"shards" : {
"total" : 1,
"failed" : 0,
"successful" : 1
}
}
}在前面注冊 Repository 的目錄下可以看到生成了相關(guān)的快照文件:
[elasticsearch@elastic1 ~]$ ll /home/elasticsearch/snapshot/dumpindex/ total 16 -rw-rw-r--. 1 elasticsearch elasticsearch 439 Mar 17 22:18 index-0 -rw-rw-r--. 1 elasticsearch elasticsearch 8 Mar 17 22:18 index.latest drwxrwxr-x. 3 elasticsearch elasticsearch 36 Mar 17 22:18 indices -rw-rw-r--. 1 elasticsearch elasticsearch 193 Mar 17 22:18 meta-cTvmz15pQzedDE-fHbzsCQ.dat -rw-rw-r--. 1 elasticsearch elasticsearch 252 Mar 17 22:18 snap-cTvmz15pQzedDE-fHbzsCQ.dat
和在源集群注冊的方式一樣,修改 elasicsearch.yml 配置文件,并且通過下面命令注冊 Repository:
PUT _snapshot/my_fs_backup
{
"type": "fs",
"settings": {
"location": "/home/elasticsearch/snapshot/dumpindex",
"compress": true
}
}將源集群生成的快照文件拷貝到目標(biāo)集群的 Repository 目錄下:
[elasticsearch@elastic1 ~]$ scp -r /home/elasticsearch/snapshot/dumpindex/* elasticsearch@192.168.1.67:/home/elasticsearch/snapshot/dumpindex/
在目標(biāo)集群上查看快照信息:
GET _snapshot/my_fs_backup/snapshot_1
# 輸出結(jié)果
{
"snapshots" : [
{
"snapshot" : "snapshot_1",
"uuid" : "cTvmz15pQzedDE-fHbzsCQ",
"version_id" : 7110199,
"version" : "7.11.1",
"indices" : [
"dumpindex"
],
"data_streams" : [ ],
"include_global_state" : false,
"state" : "SUCCESS",
"start_time" : "2021-03-17T14:33:20.866Z",
"start_time_in_millis" : 1615991600866,
"end_time" : "2021-03-17T14:33:21.067Z",
"end_time_in_millis" : 1615991601067,
"duration_in_millis" : 201,
"failures" : [ ],
"shards" : {
"total" : 1,
"failed" : 0,
"successful" : 1
}
}
]
}將快照導(dǎo)入目標(biāo)集群的 dumpindex 索引中:
POST _snapshot/my_fs_backup/snapshot_1/_restore
{
"indices": "dumpindex"
}查看索引數(shù)據(jù),可以看到和源集群的一致:
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "q28kPngB8Nd5nYNvOgHd",
"_score" : 1.0,
"_source" : {
"name" : "tom",
"age" : 18
}
},
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "rG8kPngB8Nd5nYNvOgHd",
"_score" : 1.0,
"_source" : {
"name" : "jack",
"age" : 19
}
},
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "rW8kPngB8Nd5nYNvOgHd",
"_score" : 1.0,
"_source" : {
"name" : "bob",
"age" : 20
}
}
]
}
}Logstash支持從一個 Elasticsearch 集群中讀取數(shù)據(jù)然后寫入到另一個 Elasticsearch 集群:
編輯 conf/logstash.conf文件:
input {
elasticsearch {
hosts => ["http://192.168.1.171:9200"]
index => "dumpindex"
#如果需要用戶認(rèn)證
#user => "username"
#password => "password"
}
}
output {
elasticsearch {
hosts => ["http://192.168.1.67:9200"]
index => "dumpindex"
}
}啟動 Logstash:
[elasticsearch@es1 logstash-7.11.1]$ bin/logstash -f config/logstash.conf
在目標(biāo)集群上查看 dumpindex 索引數(shù)據(jù),可以看到和源集群一致:
GET dumpindex/_search
# 輸出結(jié)果
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "jrfpQHgBERNPF_kwE-Jk",
"_score" : 1.0,
"_source" : {
"@version" : "1",
"name" : "tom",
"@timestamp" : "2021-03-17T15:58:39.423Z",
"age" : 18
}
},
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "j7fpQHgBERNPF_kwE-Jk",
"_score" : 1.0,
"_source" : {
"@version" : "1",
"name" : "jack",
"@timestamp" : "2021-03-17T15:58:39.440Z",
"age" : 19
}
},
{
"_index" : "dumpindex",
"_type" : "_doc",
"_id" : "kLfpQHgBERNPF_kwE-Jk",
"_score" : 1.0,
"_source" : {
"@version" : "1",
"name" : "bob",
"@timestamp" : "2021-03-17T15:58:39.440Z",
"age" : 20
}
}
]
}
}到此,相信大家對“Elasticsearch跨集群數(shù)據(jù)遷移怎么實(shí)現(xiàn)”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
文章名稱:Elasticsearch跨集群數(shù)據(jù)遷移怎么實(shí)現(xiàn)
當(dāng)前URL:http://chinadenli.net/article40/jpsieo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、虛擬主機(jī)、搜索引擎優(yōu)化、服務(wù)器托管、商城網(wǎng)站、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)