一、简介
elasticsearch是使用java开发的,基于lucene的搜索引擎。
二、知识点
1、doc
在elasticsearch中,存的是一个一个的json格式的文档,也即是索引。
2、index
index相当于表,也可以理解为数据库(因为内部还可以指定type),里面存的是文档。
3、type
在index内部,如果index理解为数据库,那么type可以理解为表,同一index下的数据,是存在同一空间中的。
4、mapping
在建index索引时,有时要根据需要创建mapping信息,这类似是solr中的schema。里面可以指定字段的
详细信息,如分词器等。
三、安装步骤
1、下载elasticsearch
链接地址:https://www.elastic.co/downloads/past-releases
这里使用elasticsearch的6.2.2版本
2、解压安装包并放到常用安装目录下
3、修改config目录下的elasticsearch.yml文件
a)打开注释,修改集群名称: cluster.name: my-application
b)打开注释,修改结点名称: node.name: node-1
c)打开注释,指定服务地址: network.host: 192.168.0.107
d)打开注释,指定http服务端口号: http.port: 9200
e)指定java连接服务端口(可不指定,默认为9300): transport.tcp.port: 9300
4、启动elasticsearch
bin/elasticsearch
加参数-d 可以后台启动:bin/elasticsearch -d
四、查看
在浏览器上输入址址:http://192.168.0.107:9200
五、报错处理
1、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决:
a、sudo vim /etc/sysctl.conf
添加vm.max_map_count=655360
b、sudo sysctl -p
2、由于elasticsearch在建索引时,会创建很多文件,因此通常需要修改系统打开文件的个数,
可在/etc/security/limits.conf中修改,
通过命令ulimit可查看当前值。