一、安装ElasticSearch7.4.2
1:ElasticSearch下载地址,下载对应的tar包。
2:tar -zxf 解压
3:进入解压后的ElasticSearch7.4.2目录,创建data目录,mkdir;用于存储以后的索引数据
4 :进入config目录,编辑 elasticsearch.yml文件,
配置如下:
cluster.name: zz-elasticsearch //集群名称:zz-elasticsearch
node.name: es-node1 //节点名称:es-node1,
path.data: /usr/local/elasticsearch-7.4.2/data //数据路径:放入刚创建的data目录中
path.logs: /usr/local/elasticsearch-7.4.2/logs //r日志路径:放入刚创建的data目录中
network.host: 0.0.0.0 //用于设置网络接收,允许所有ip地址访问该elasticsearch.
http.port: 9200 //配置对外访问端口
cluster.initial_master_nodes: ["es-node1"] //配置master集群节点,目前单节点:node-1
5:elastic的启动不能使用root用户,新增elasticsearch用户:useradd esuser
6:给esuser赋予权限:chown -R esuser:esuser /usr/local/elasticsearch-7.4.2
7:切换到esuser用户,启动elasticsearch
8:解决错误:错误信息如下:
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
8、编辑:vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vim /etc/sysctl.conf
vm.max_map_count=262146
9、刷新文件 sysctl -p
访问: IP:9200
后台方式启动命令 ./elasticsearch -d
二、谷歌安装 Elasticsearch-head 插件
1、下载插件:https://github.com/liufengji/es-head
2、安装插件: google ---》更多工具----》扩展程序
将解压的elasticsearch-head.crx文件拖进来。
提示程序包无效:"CRX_HEADER_INVALID"
将elasticsearch-head.crx更名为elasticsearch-head.rar 再解压;
进入elasticsearch-head文件夹将_metadata文件夹重命名为metadata
打开Google的扩展程序,点击加载已解压的扩展程序,选择解压elasticsearch-head文件夹即可添加插件成功
4、点击上面的图标,输入地址,点击链接
5、解决问题。创建索引报错:406 (Not Acceptable)
修改 vendor.js 中 6886行
contentType: "application/x-www-form-urlencoded", 改为: contentType: "application/json",
三、使用POSTMAN测试,创建索引
{
"mappings":{
"properties":{
"realname":{
"type": "text",
"index": true
},
"username":{
"type": "keyword",
"index": true
}
}
}
}