国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ElasticSearch 數(shù)據(jù)遷移工具elasticdump

這篇具有很好參考價值的文章主要介紹了ElasticSearch 數(shù)據(jù)遷移工具elasticdump。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

ElasticSearch 數(shù)據(jù)遷移工具elasticdump

Elasticdump 是一個用于導入和導出 Elasticsearch 數(shù)據(jù)的命令行工具。它提供了一種方便的方式來在不同的 Elasticsearch 實例之間傳輸數(shù)據(jù),或者進行數(shù)據(jù)備份和恢復。

使用 Elasticdump,你可以將 Elasticsearch 索引中的數(shù)據(jù)導出為 JSON 文件,或者將 JSON 文件中的數(shù)據(jù)導入到 Elasticsearch 索引中。它支持各種選項和過濾器,用于指定源和目標,包括索引模式、文檔類型、查詢過濾器等等。

主要特征包括

  • 支持在Elasticsearch實例或者集群之間傳輸和備份數(shù)據(jù)??梢詫?shù)據(jù)從一個集群復制到另一個集群。
  • 支持不同格式的數(shù)據(jù)傳輸,包括JSON、NDJSON、CSV、備份文件等。
  • 可以通過命令行或者程序化的方式使用。命令行方式提供了便捷的操作接口。
  • 支持增量式同步,只復制目標集群中不存在的文檔。
  • 支持各種認證方式連接Elasticsearch,如basic auth、Amazon IAM等。
  • 支持多線程操作,可以加快數(shù)據(jù)遷移的速度。
  • 開源免費,代碼托管在GitHub上。

一、安裝node

首先獲取安裝包

wget https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz
tar axf node-v16.14.0-linux-x64.tar.xz -C /usr/local/
mv /usr/local/node-v16.14.0-linux-x64  /usr/local/node

然后配置環(huán)境變量

vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH

接下來刷新環(huán)境變量,然后測試一下安裝是否完成

 source /etc/profile
 node -v
 npm -v

如果是mac 的話可以使用brew 安裝

brew install node@16

二、在線安裝elasticdump

執(zhí)行下面的命令安裝

npm install elasticdump -g

使用下面的命令查看安裝目錄

npm root -g

我的位置在這里/opt/homebrew/lib/node_modules

ElasticSearch 數(shù)據(jù)遷移工具elasticdump,ElasticSearch,elasticsearch,elasticdump

三、離裝elasticdump

這里的原理是將node安裝包和elasticdump安裝報復制到需要離線安裝的服務器。

  1. 獲取node 的離線安裝包進行安裝即可,參考第一步
  2. 獲取elasticdump的安裝包安裝,所以我們首選需要一個打包工具
npm install -g npm-pack-all

然后我們切換到上面elasticdump的安裝路,打包elasticdump,會在當前目錄生成elasticdump-6.103.0.tgz 這樣一個壓縮包,這就是我們離線安裝需要的包

cd /opt/homebrew/lib/node_modules/elasticdump/
npm-pack-all

ElasticSearch 數(shù)據(jù)遷移工具elasticdump,ElasticSearch,elasticsearch,elasticdump

到這里我們看到離線包已經(jīng)生成好了,接下來我們復制到我們之前已經(jīng)安裝好node 的機器上,執(zhí)行下面的命令

npm install elasticdump-6.103.0.tgz

后面為了方便使用,我們可以配置一下elasticdump的環(huán)境變量

vim ~/.bashrc
# 追加以下內容
#node 
export DUMP_HOME=/opt/homebrew/lib/node_modules/elasticdump/
export PATH=$DUMP_HOME/bin:$PATH
# 刷新
source ~/.bashrc

四、使用elasticdump

這里的使用主要分為兩種,一種是數(shù)據(jù)備份,一種是數(shù)據(jù)遷移

  1. 備份主要指的是生成備份的數(shù)據(jù)文件,在需要的時候進行還原
  2. 數(shù)據(jù)遷移是指將原來索引里的數(shù)據(jù)遷移到新的索引

其實數(shù)據(jù)備份也能達到數(shù)據(jù)遷移的目的,但是在兩個環(huán)境的網(wǎng)絡不通的時候我們只能使用數(shù)據(jù)備份

我們安裝成功后,在elasticdump的bin目錄下其實有兩個工具,一個是elasticdump 另外一個是multielasticdump

ElasticSearch 數(shù)據(jù)遷移工具elasticdump,ElasticSearch,elasticsearch,elasticdump

數(shù)據(jù)遷移

遷移索引

elasticdump \
  --input=http://192.168.1.140:9200/source_index \
  --output=http://192.168.1.141:9200/target_index \
  --type=mapping

遷移數(shù)據(jù)

elasticdump \
  --input=http://192.168.1.140:9200/source_index \
  --output=http://192.168.1.141:9200/target_index \
  --type=data \
  --limit=2000  # 每次操作的objects數(shù)量,默認100,數(shù)據(jù)量大的話,可以調大加快遷移速度

這個命令會將源 Elasticsearch 實例中的 “my_index” 索引的所有數(shù)據(jù)導出,并保存到 “/path/to/output.json” 的 JSON 文件中。

  • --input:指定輸入的 Elasticsearch 實例和索引。可以是一個 URL,也可以是本地 Elasticsearch 實例的路徑。
  • --output:指定輸出的文件路徑,數(shù)據(jù)將保存為一個 JSON 文件。
  • --type:指定要導出的數(shù)據(jù)類型,通常為 “data” 表示文檔數(shù)據(jù)。

你還可以使用其他選項來進一步控制導出過程,如 --query, --size, --limit, --filter 等,具體取決于你的需求??梢酝ㄟ^運行 elasticdump --help 命令來

數(shù)據(jù)備份

導出索引和數(shù)據(jù)

elasticdump \
  --input=http://192.168.1.140:9200/source_index \
  --output=/data/source_index_mapping.json \
  --type=mapping
elasticdump \
  --input=http://192.168.1.140:9200/source_index \
  --output=/data/source_index.json \
  --type=data \
  --limit=2000

導入索引和數(shù)據(jù)

elasticdump \
  --input=/data/source_index_mapping.json \
  --output=http://192.168.1.141:9200/source_index \
  --type=mapping
elasticdump \
  --input=/data/source_index.json \
  --output=http://192.168.1.141:9200/source_index \
  --type=data \
  --limit=2000

其他用法

還有其他使用的細節(jié),例如壓縮,指定query 什么的,我們可以參考下面的例子

# Copy an index from production to staging with analyzer and mapping:
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=http://staging.es.com:9200/my_index \
  --type=analyzer
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=http://staging.es.com:9200/my_index \
  --type=mapping
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=http://staging.es.com:9200/my_index \
  --type=data

# Backup index data to a file:
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=/data/my_index_mapping.json \
  --type=mapping
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=/data/my_index.json \
  --type=data

# Backup and index to a gzip using stdout:
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=$ \
  | gzip > /data/my_index.json.gz

# Backup the results of a query to a file
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=query.json \
  --searchBody="{\"query\":{\"term\":{\"username\": \"admin\"}}}"
  
# Specify searchBody from a file
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=query.json \
  --searchBody=@/data/searchbody.json  

# Copy a single shard data:
elasticdump \
  --input=http://es.com:9200/api \
  --output=http://es.com:9200/api2 \
  --input-params="{\"preference\":\"_shards:0\"}"

# Backup aliases to a file
elasticdump \
  --input=http://es.com:9200/index-name/alias-filter \
  --output=alias.json \
  --type=alias

# Import aliases into ES
elasticdump \
  --input=./alias.json \
  --output=http://es.com:9200 \
  --type=alias

# Backup templates to a file
elasticdump \
  --input=http://es.com:9200/template-filter \
  --output=templates.json \
  --type=template

# Import templates into ES
elasticdump \
  --input=./templates.json \
  --output=http://es.com:9200 \
  --type=template

# Split files into multiple parts
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=/data/my_index.json \
  --fileSize=10mb

# Import data from S3 into ES (using s3urls)
elasticdump \
  --s3AccessKeyId "${access_key_id}" \
  --s3SecretAccessKey "${access_key_secret}" \
  --input "s3://${bucket_name}/${file_name}.json" \
  --output=http://production.es.com:9200/my_index

# Export ES data to S3 (using s3urls)
elasticdump \
  --s3AccessKeyId "${access_key_id}" \
  --s3SecretAccessKey "${access_key_secret}" \
  --input=http://production.es.com:9200/my_index \
  --output "s3://${bucket_name}/${file_name}.json"

# Import data from MINIO (s3 compatible) into ES (using s3urls)
elasticdump \
  --s3AccessKeyId "${access_key_id}" \
  --s3SecretAccessKey "${access_key_secret}" \
  --input "s3://${bucket_name}/${file_name}.json" \
  --output=http://production.es.com:9200/my_index
  --s3ForcePathStyle true
  --s3Endpoint https://production.minio.co

# Export ES data to MINIO (s3 compatible) (using s3urls)
elasticdump \
  --s3AccessKeyId "${access_key_id}" \
  --s3SecretAccessKey "${access_key_secret}" \
  --input=http://production.es.com:9200/my_index \
  --output "s3://${bucket_name}/${file_name}.json"
  --s3ForcePathStyle true
  --s3Endpoint https://production.minio.co

# Import data from CSV file into ES (using csvurls)
elasticdump \
  # csv:// prefix must be included to allow parsing of csv files
  # --input "csv://${file_path}.csv" \
  --input "csv:///data/cars.csv"
  --output=http://production.es.com:9200/my_index \
  --csvSkipRows 1    # used to skip parsed rows (this does not include the headers row)
  --csvDelimiter ";" # default csvDelimiter is ','

常用參數(shù)

--direction  dump/load 導出/導入
--ignoreType  被忽略的類型,data,mapping,analyzer,alias,settings,template
--includeType  包含的類型,data,mapping,analyzer,alias,settings,template
--suffix  加前綴,es6-${index}
--prefix  加后綴,${index}-backup-2018-03-13

總結

elasticdump是ElasticSearch提供的一個工具,我們主要可以用來完成

  1. 數(shù)據(jù)備份
  2. 數(shù)據(jù)遷移

這一節(jié)我們主要介紹了elasticdump的安裝和使用,還有就是,Elasticdump 是一個第三方工具,不是官方的 Elasticsearch 產(chǎn)品。雖然它對某些用例很有幫助,但在使用之前,確保與你的 Elasticsearch 版本兼容,并查閱工具的文檔以了解任何特定的注意事項或限制。

總體來說,elasticdump是一個非常實用的數(shù)據(jù)遷移和備份工具。它可以幫助我們輕松地在不同Elasticsearch集群之間進行數(shù)據(jù)遷移,實現(xiàn)集群之間的無縫數(shù)據(jù)同步。文章來源地址http://www.zghlxwxcb.cn/news/detail-575034.html

到了這里,關于ElasticSearch 數(shù)據(jù)遷移工具elasticdump的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 離線安裝elasticdump導出elasticsearch數(shù)據(jù)

    項目需要導出知識庫博客文章數(shù)據(jù),格式為json; 知識庫系統(tǒng)部署在內網(wǎng),沒有node和 elasticdump 數(shù)據(jù)導出工具,需要離線安裝node和elasticdump,方法是找一臺與內網(wǎng)配置一樣的外網(wǎng)機器在線安裝node和elasticdump環(huán)境,再把安裝包導入內網(wǎng)安裝。 備注: 使用的機器是x86+銀行麒麟V4桌

    2024年02月03日
    瀏覽(18)
  • elasticdump:es批量索引遷移心得

    目錄 1.方法介紹 1.1一行代碼看懂用法 1.2導出源數(shù)據(jù)的 settings、mapping 、data 1.3將導出的數(shù)據(jù)文件導入至目標索引 1.4從數(shù)據(jù)源直接導入到目標集群 1.2.1:導出源數(shù)據(jù)索引的 settings文件 2:導出源數(shù)據(jù)索引的 mapping文件 3:導出源數(shù)據(jù)索引的 data文件 1:導入 settings 至目標索引 2:

    2024年02月08日
    瀏覽(16)
  • elasticsearch備份恢復,elasticdump使用

    elasticsearch備份恢復,elasticdump使用

    準備環(huán)境 1. 將node-v10.23.1-linux-x64.tar.xz上傳到服務器/usr/local目錄下 2. tar xf node-v10.23.1-linux-x64.tar.xz 3. 將node_modules.tar.gz上傳到服務器/usr/local目錄 4. tar -zxvf node_modules.tar.gz 5. 設置NODE環(huán)境 ? 5.1 vim /etc/profile ? ? export NODEJS_HOME=/usr/local/node-v10.23.1-linux-x64 ? ? export PATH=$NODEJS_HOME/bin:

    2024年01月19日
    瀏覽(15)
  • Elasticsearch備份與還原:使用elasticdump

    Elasticsearch備份與還原:使用elasticdump

    在數(shù)據(jù)管理的世界里,備份和還原數(shù)據(jù)是重中之重的日常工作,特別是對于Elasticsearch這樣的強大而復雜的搜索引擎。備份不僅可以用于災難恢復,還可以在數(shù)據(jù)遷移、測試或者升級等場景中發(fā)揮重要作用。 在本博客中,我們將會重點介紹如何使用一個非常實用的工具——e

    2024年02月04日
    瀏覽(19)
  • elasticdump工具安裝及使用詳解(在線和離線)

    elasticdump工具安裝及使用詳解(在線和離線)

    1.1 安裝node和npm 以node版本 V16.18.1為例: 詳見博文:Linux系統(tǒng)中安裝nodejs(node、npm)_IT之一小佬的博客-CSDN博客 1.2 安裝elasticdump 1.3 創(chuàng)建軟鏈接 ????????如果比著1.1安裝的話,此時不用創(chuàng)建軟鏈接,直接使用elasticdump --help也是可能成功的。在1.1中配置過環(huán)境變量path。 創(chuàng)建軟鏈

    2024年02月03日
    瀏覽(25)
  • Elasticsearch數(shù)據(jù)遷移(使用快照)

    Elasticsearch數(shù)據(jù)遷移(使用快照)

    前言 :由于做項目的時候沒有進行長期考慮,把es,mysql,api等都部署在同一臺服務器上,隨著業(yè)務的增加,需要將部分服務和存儲遷移到其他服務器。es上目前已有100萬以上的數(shù)據(jù),上網(wǎng)查資料,snapshot適合數(shù)據(jù)量大的遷移,所以沒來得及考慮就果斷選擇嘗試一下。 一.生成

    2024年04月10日
    瀏覽(27)
  • Elasticsearch 數(shù)據(jù)遷移方案

    倘若準備將自建的 elasticsearch 遷移K8s,或者的遷移到其他elasticsearch集群,可以根據(jù)自己的業(yè)務需要選擇適當?shù)倪w移方案, 針對業(yè)務可以停服或可以暫停寫操作場景 ,可以使用以下幾種方案完成數(shù)據(jù)遷移: COS 快照,全程Cloud Object Storage logstash elasticsearch-dump 各種遷移方案對比

    2024年02月16日
    瀏覽(17)
  • Logstash:遷移數(shù)據(jù)到 Elasticsearch

    Logstash:遷移數(shù)據(jù)到 Elasticsearch

    在生產(chǎn)環(huán)境中,不使用 Apache Kafka 等流平臺進行數(shù)據(jù)遷移并不是一個好的做法。 在這篇文章中,我們將詳細探討 Apache Kafka 和 Logstash 的關系。 但首先讓我們簡單了解一下 Apache Kafka 的含義。 Apache Kafka 是分布式流平臺,擅長實時數(shù)據(jù)集成和消息傳遞。 Kafka 架構不復雜且直接。

    2024年02月02日
    瀏覽(21)
  • Elasticsearch-dump 遷移數(shù)據(jù)

    Elasticsearch-dump 遷移數(shù)據(jù)

    elasticsearch-dump可以將ES中的某個索引數(shù)據(jù)遷移至其他的ES中,或者將ES數(shù)據(jù)整體遷移,我這里的場景是將生產(chǎn)的ES索引數(shù)據(jù)遷移至開發(fā)環(huán)境的ES中 1、elasticsearch-dump遷移 Tools for moving and saving indicies. 從來移動和保存索引的工具。 GITHUB項目地址: https://github.com/taskrabbit/elasticsearch-d

    2024年02月11日
    瀏覽(17)
  • 【筆記】Elasticsearch snapshot(快照)數(shù)據(jù)遷移

    【筆記】Elasticsearch snapshot(快照)數(shù)據(jù)遷移

    0.簡介 ? ? ? ? 項目中需要進行Elasticsearch(以下簡稱ES)新舊集群切換,涉及到集群數(shù)據(jù)遷移。本篇筆記錄了利用Elasticsearch snapshot特性進行數(shù)據(jù)遷移的關鍵步驟。 1.遷移前檢查 ? ? ? ? 在開始進行遷移前,做以下兩點檢查。?? ? ? ? ? 1)檢查是否開啟path.repo選項 ? ? ? ? ?

    2024年02月19日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包