升级全过程
chmod 755 /home/elastic/.ssh && chmod 644 authorized_keys && chmod 644 id_rsa.pub && chmod 600 id_rsa
root用户挂载
sshfs elastic@172.20.4.244:/data/backup /data/bak -o allow_other
一个节点执行:
创建仓库:
curl -XPUT 'http://172.20.8.171:9200/_snapshot/backup0615' -H 'Content-Type: application/json' -d '{
"type": "fs",
"settings": {
"location": "/home/data/kfesdatabak",
"compress": true
}
}'
查看仓库信息:
curl -XGET 'http://10.3.5.61:9200/_snapshot/_all?pretty'
curl -XDELETE 'http://10.3.5.61:9200/_snapshot/backup0622?pretty'
创建快照(默认):
curl -XPUT 'http://172.20.8.171:9200/_snapshot/backup0615/snapshot_1?wait_for_completion=true&pretty'
创建快照(设置参数):
curl -XPUT 'http://172.20.8.171:9200/_snapshot/backup0615/snapshot_1?pretty' -H 'Content-Type: application/json' -d'
{
"indices": "newindex,.marvel-es-data-1,test,fujiovmthw1856091935,biurrdwslo4876782488,qdzqjpisiq4211779427,jsvkxhdqtg1878285484,dfndsfyfsr0835468931,nfhevbnubp6817406919,ysjjececio3237427125",
"ignore_unavailable": true,
"include_global_state": false
}
'
查看创建快照状态
curl -XGET 'http://172.20.8.171:9200/_snapshot/backup0615/snapshot_1?pretty'
查看快照信息:
curl -XGET "http://172.20.4.239:9200/_snapshot/my_backup/snapshot_1"
删除快照:
curl -XDELETE "http://172.20.4.238:9200/_snapshot/my_backup/snapshot_1"
-------------------------------------------------------------------------------------------------------------------------------------------------------------
rm -rf authorized_keys && cat id_rsa222.pub >> authorized_keys && cat id_rsa236.pub >> authorized_keys && cat id_rsa237.pub >> authorized_keys && cat id_rsa238.pub >> authorized_keys && cat id_rsa244.pub >> authorized_keys
chmod 755 /home/wzx/.ssh && chmod 644 authorized_keys && chmod 644 id_rsa.pub && chmod 600 id_rsa
各节点root用户执行
chmod -R 777 /data/esbak/backup
chown -R wzx:gwzx /data/esbak/backup
sshfs wzx@172.20.4.244:/data/databak /data/esbak/backup -o allow_other
拷贝上文备份后数据至244服务器/data/databak目录下
创建仓库:
curl -XPUT 'http://172.20.4.236:9200/_snapshot/backup0615' -H 'Content-Type: application/json' -d '{
"type": "fs",
"settings": {
"location": "/work/datasnap",
"compress": true
}
}'
直接恢复:
curl -XPOST 'http://172.20.8.222:9200/_snapshot/my_backup/snapshot_1/_restore?pretty'
指定索引、参数恢复:
curl -XPOST 'http://172.20.8.222:9200/_snapshot/my_backup/snapshot_1/_restore?pretty' -H 'Content-Type: application/json' -d'
{
"indices": "newindex,.marvel-es-data-1,test,fujiovmthw1856091935,biurrdwslo4876782488,qdzqjpisiq4211779427,jsvkxhdqtg1878285484,dfndsfyfsr0835468931,nfhevbnubp6817406919,ysjjececio3237427125",
"ignore_unavailable": true,
"include_global_state": true,
}
'
查看恢复状态
curl -XGET 'http://172.20.4.236:9200/_snapshot/backup0615/snapshot_1/_status?pretty'
---------------------------------------------------------------------------------------------------------------------------------------------------------------
升级前检查
./bin/plugin install https://github.com/elastic/elasticsearch-migration/releases/download/v2.0.4/elasticsearch-migration-2.0.4.zip
http://localhost:9200/_plugin/elasticsearch-migration
curl -XPUT 'http://172.20.4.238:9211/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}
'
curl -XPOST 'http://172.20.4.238:9211/_flush/synced?pretty'
下载安装elasticsearch-head
https://github.com/mobz/elasticsearch-head
安装node和npm
https://nodejs.org/en/download/
wget https://nodejs.org/dist/v6.10.3/node-v6.10.3-linux-x64.tar.xz
xz -d node-v6.10.3-linux-x64.tar.xz
tar xvf node-v6.10.3-linux-x64.tar
mkdir -p /usr/local/node
mv node-v6.10.3-linux-x64 /usr/local/node/
npm install
npm install -g grunt-cli
elastic用户设置环境变量
export NODE_PATH=/usr/local/node/node-v6.10.3-linux-x64
export PATH=$NODE_PATH/bin:$PATH
更新索引设置
curl -XPUT 'http://172.20.4.238:9222/test/_settings?pretty' -H 'Content-Type: application/json' -d'
{
"index" : {
"number_of_replicas" : 2
}
}
'
curl -XPUT 'http://172.20.8.171:9200/_snapshot/backup0615/snapshot_1?pretty' -H 'Content-Type: application/json' -d'
{
"ignore_unavailable": true,
"include_global_state": false
}
'
curl -XPOST 'http://10.3.5.69:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
{
"commands" : [ {
"move" :
{
"index" : "fujiovmthw1856091935",
"shard" : 2,
"from_node" : "yc236",
"to_node" : "yc237"
}
}]
}'