※ 简介
Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。Elasticsearch用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。官方客户端在Java、.NET(C#)、PHP、Python、Apache Groovy、Ruby和许多其他语言中都是可用的。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr,也是基于Lucene。
※ 作用
Elasticsearch是一款支持 PB 级别的结构化或者非结构化数据全文搜索引擎,能胜任上百个服务节点的拓展(横向拓展最好);提供了RESTful API接口,支持各种语言调用。
Elasticsearch与Solr的比较总结:
※ Linux 安装
前提:必须安装jdk1.8以上版本
[root@localhost BigData]# tar -zxvf elasticsearch-6.2.4.tar.gz #解压即用
[xdh@localhost BigData]$ cd elasticsearch-6.2.4/
[xdh@localhost elasticsearch-6.2.4]$ vi config/elasticsearch.yml
**#修改**:network.host: 0.0.0.0。所有用户即可访问
[xdh@localhost elasticsearch-6.2.4]$ bin/elasticsearch # 启动方式一
[xdh@localhost elasticsearch-6.2.4]$ bin/elasticsearch -d # 启动方式二
[xdh@localhost elasticsearch-6.2.4]$ jps #查看运行状态
**#本地验证是否开启**
[root@localhost ~]# curl http://127.0.0.1:9200/
{
"name" : "WGQK9qq",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "V76-lf93TeWq6MYJwh6lQA",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
[xdh@node128 bin]$ ps -ef | grep elastic **#查找Elasticsearch**
xdh 2900 1 14 19:12 pts/0 00:00:16 /usr/local/src/jdk/jdk1.8.0_161/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch.CUyddC3u -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/BigData/elasticsearch-6.2.4 -Des.path.conf=/BigData/elasticsearch-6.2.4/config -cp /BigData/elasticsearch-6.2.4/lib/org.elasticsearch.bootstrap.Elasticsearch -d
xdh 2968 2704 0 19:14 pts/0 00:00:00 grep --color=auto elastic
[xdh@node128 bin]$ kill -9 2900 **#关闭Elasticsearch**
[xdh@node128 bin]$ ps -ef | grep elastic
xdh 2970 2704 0 19:14 pts/0 00:00:00 grep --color=auto elastic
**注意点:**
Elasticsearch 不能用root用户安装,需要新建一个用户才行
[root@localhost /]# chown -R xdh:xdh /BigData/
安装Elasticsearch 需要先安装JDK1.8以上版本
※ Linux 安装常见报错问题
1. 其他电脑无法访问es地址
关闭防火墙:systemctl stop firewalld.service
2.报错:ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3798] for user [xdh] is too low, increase to at least [4096]
解决办法:[xdh@localhost elasticsearch-6.2.4]$ sudo vi /etc/security/limits.conf
[root@localhost elasticsearch-6.2.4]# sudo vi /etc/sysctl.conf
vm.max_map_count=262144
重启电脑(谨慎处理)
[root@localhost elasticsearch-6.2.4]# shutdown -r now
3. ERROR: [1] bootstrap checks failed
[1]: max number of threads [3798] for user [xdh] is too low, increase to at least [4096]
解决办法:
[root@localhost elasticsearch-6.2.4]# vi /etc/security/limits.d/90-nproc.conf
[root@localhost elasticsearch-6.2.4]# su root
重启电脑(谨慎处理)
[root@localhost elasticsearch-6.2.4]# shutdown -r now