Elasticsaerch to Elasticsearch migration
how to move elasticsearch data from one server to another
A의 analyzer, mapping, data를 B로 옮기기
Copy an index from A to B with analyzer and mapping :
1. analyzer
analyzer를 가져온다.
elasticdump --input={protocol}://{host}:{port}/{index} --output={protocol}://{host}:{port}/{index} --type=analyzer
* output (데이터를 받는) 서버에 index가 없어도 자동으로 생성해 준다.
Elasticdump will create the index you wrote in ouput when it doesn't exist.
2. mapping
mapping을 가져온다.
elasticdump --input={protocol}://{host}:{port}/{index} --output={protocol}://{host}:{port}/{index} --type=mapping
3. data
데이터를 가져온다. 이 때, 데이터가 몇 백만 건 이상이라면 --limit=10000 (max: 10,000) 으로 1만건씩 처리되게 해준다. (default : 100)
elasticdump --input={protocol}://{host}:{port}/{index} --output={protocol}://{host}:{port}/{index} --type=data
// to speed up
elasticdump --input={protocol}://{host}:{port}/{index} --output={protocol}://{host}:{port}/{index} --type=data --limit=10000
and it would look like below.
When Authorization needed
만약 aws Es 서버, authorizaion이 필요한 경우
If one of the es servers needs a "authorization", you can add your id, password or ApiKey.
1. 유저이름과 비밀번호 입력하기, Adding id & password
--input=http://name:password@{host}:{port}/{index}
2. Headers에 apikey 넣기, Adding ApiKey to Headers
elasticdump --input={protocol}://{host}:{port}/{index} --output={protocol}://{host}:{port}/{index}
--output-headers='{"Authorization": "ApiKey {your apikey} "}'
--type=data
remember, there is a " ", space between ApiKey and your apikey.
내가 사용한 최종 elasticdump 명령어
Here is my final elasticdump command
elasticdump --bulk=true --input=http://localhost:9200/station_address --output=https://blabla.ap-somewhere-2.aws.elastic-cloud.com:9243/station_address --output-headers='{"Authorization": "ApiKey dksjeCKVALENcasdlf3ksdhgik4jaksddfblanablabla"}' --type=data
type analyzer -> mapping -> data 순으로 그대로 입력했다.
ouput 서버에 데이터가 잘 도착함!!
Preference : https://github.com/elasticsearch-dump/elasticsearch-dump#notes