Element vue Select 下拉框預設
阿新 • • 發佈:2020-08-16
1.安裝npm環境
# 安裝npm(只需要在一個節點安裝即可,如果前端還有nginx做反向代理可以每個節點都裝) [root@elkstack01 ~]# yum install -y npm # 進入下載head外掛程式碼目錄 [root@elkstack01 src]# cd /usr/local/ # 從GitHub上克隆程式碼到本地 [root@elkstack01 local]# git clone git://github.com/mobz/elasticsearch-head.git # 克隆完成後,進入elasticsearch外掛目錄 [root@elkstack01 local]# cd elasticsearch-head/ # 清除快取 [root@elkstack01 elasticsearch-head]# npm cache clean -f # 使用npm安裝n模組(不同的專案js指令碼所需的node版本可能不同,所以就需要node版本管理工具)
2.安裝備份工具
[root@db01 ~]# npm install elasticdump -g
3.備份命令
1)備份引數
--input: 資料來源
--output: 接收資料的目標
--type: 匯出的資料型別(settings, analyzer, data, mapping, alias, template)
2)備份資料到另一個ES叢集
elasticdump \ --input=http://10.0.0.51:9200/my_index \ --output=http://100.10.0.51:9200/my_index \ --type=analyzer elasticdump \ --input=http://10.0.0.51:9200/my_index \ --output=http://100.10.0.51:9200/my_index \ --type=mapping elasticdump --input=http://10.0.0.51:9200/my_index --output=http://100.10.0.51:9200/my_index --type=data elasticdump \ --input=http://10.0.0.51:9200/my_index \ --output=http://100.10.0.51:9200/my_index \ --type=template
3)備份資料到本地的json檔案
elasticdump \
--input=http://10.0.0.51:9200/student \
--output=/tmp/student_mapping.json \
--type=mapping
elasticdump \
--input=http://10.0.0.51:9200/student \
--output=/tmp/student_data.json \
--type=data
4)匯出檔案打包
elasticdump \ --input=http://production.es.com:9200/my_index \ --output=$ \ | gzip > /data/my_index.json.gz
5)備份指定條件的資料
elasticdump \
--input=http://production.es.com:9200/my_index \
--output=query.json \
--searchBody="{\"query\":{\"term\":{\"username\": \"admin\"}}}"
# 幫助文件:https://github.com/elasticsearch-dump/elasticsearch-dump
4.匯入命令
elasticdump \
--input=./student_template.json \
--output=http://10.0.0.51:9200 \
--type=template
elasticdump \
--input=./student_mapping.json \
--output=http://10.0.0.51:9200 \
--type=mapping
elasticdump \
--input=./student_data.json \
--output=http://10.0.0.51:9200 \
--type=data
elasticdump \
--input=./student_analyzer.json \
--output=http://10.0.0.51:9200 \
--type=analyzer
# 恢復資料的時候,如果資料已存在,會覆蓋原資料
5.備份指令碼
#!/bin/bash
echo '要備份的機器是:'${1}
index_name='
test
student
linux7
'
for index in `echo $index_name`
do
echo "start input index ${index}"
elasticdump --input=http://${1}:9200/${index} --output=/data/${index}_alias.json --type=alias &> /dev/null
elasticdump --input=http://${1}:9200/${index} --output=/data/${index}_analyzer.json --type=analyzer &> /dev/null
elasticdump --input=http://${1}:9200/${index} --output=/data/${index}_data.json --type=data &> /dev/null
elasticdump --input=http://${1}:9200/${index} --output=/data/${index}_alias.json --type=alias &> /dev/null
elasticdump --input=http://${1}:9200/${index} --output=/data/${index}_template.json --type=template &> /dev/null
done
6.匯入指令碼
#!/bin/bash
echo '要匯入的機器是:'${1}
index_name='
test
student
linux7
'
for index in `echo $index_name`
do
echo "start input index ${index}"
elasticdump --input=/data/${index}_alias.json --output=http://${1}:9200/${index} --type=alias &> /dev/null
elasticdump --input=/data/${index}_analyzer.json --output=http://${1}:9200/${index} --type=analyzer &> /dev/null
elasticdump --input=/data/${index}_data.json --output=http://${1}:9200/${index} --type=data &> /dev/null
elasticdump --input=/data/${index}_template.json --output=http://${1}:9200/${index} --type=template &> /dev/null
done