ElasticSearch-7.9.1
下载elasticsearch-7.9.1:
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-9-1
解压后使用非root用户进行启动:
./bin/elasticsearch //前台启动 ./bin/elasticsearch -d //后台启动
没有权限时:
chmod -R 775 bin/
配置:
/config/jvm.options
-Xms512m
-Xmx512m
修改的内存最好大于推荐的内存,不然安装kibana会启动很慢甚至超时
/etc/sysctl.conf
vm.max_map_count = 655360
更新配置:
sysctl -p
外网访问:
elasticsearch.yml
network.host: 0.0.0.0
node.name:node-1 取消注释
cluster.initial_master_nodes: ["node-1","node-2"] 取消注释,去掉 "node-2"
注:
useradd test passwd test //修改目录文件用户 chown -R test /usr/es目录
备份和恢复
1.创建仓库目录,修改elasticsearch/config/elasticsearch.yml
path.repo : ["/home/elastic/my_repo_folder"]
2.创建仓库
curl -XPUT 'http://elastic:elastic@172.0.0.27:9200/_snapshot/my_repository' -H 'content-Type:application/json' -d '{ "type": "fs", "settings": { "location": "/home/elastic/my_repo_folder", "compress": true, "max_restore_bytes_per_sec": "50mb", "max_snapshot_bytes_per_sec": "50mb" }}'
3.创建快照
curl -XPUT 'http://elastic:elastic@172.0.0.27:9200/_snapshot/my_repository/snapshot_1?wait_for_completion=true'
curl -XPUT 'http://elastic:elastic@172.0.0.27:9200/_snapshot/my_repository/snapshot_2?wait_for_completion=true' -H 'Content-Type: application/json' -d '{"indices": "easysite_behavior_data_index"}' //指定索引
4.恢复快照并且重命名重复的索引
curl -XPOST 'http://elastic:elastic@172.0.0.18:9200/_snapshot/my_repository/snapshot_1/_restore' -H 'Content-Type: application/json' -d'{ "ignore_unavailable": true, "include_global_state": false ,"rename_pattern": ".security-7", "rename_replacement": "restored_.security-7"}'
5.删除索引
curl -XDELETE 'http://localhost:9200/index1,index2,index3'
参考:
https://www.cnblogs.com/gyyyl/p/13503229.html
https://www.cnblogs.com/Alandre/p/11386178.html
https://zhuanlan.zhihu.com/p/654858137