介绍
墙裂推荐 :elasticSearch权威指南
官方参考手册
ealsticSearch是国外大佬失业期间为了帮老婆做个菜谱搜索引擎而开发的,后面走火入魔一发不可收拾,功能越写越牛逼,逐渐忘记了给老婆做菜谱app这个事.这个故事告诉我们.
elasticSearch简介
elasticSearch(es) 是一个开源,分布式的文档型数据存储,实时数据搜索和分析引擎.底层基于lucene(搜索引擎的搜索引擎,solr也是基于lucene开发的,lucene就相当于藤原拓海他爸搞到的赛用发动机引擎,非常牛逼,非常难理解和直接使用),使用java对其进行了大量的开发,提供了方便调用的api和resultFull接口(简而言之就是那lucene做了个webSite,你把数据灌进去直接使用就行,从lucene开发者,变成了使用者).
功能
- 数据存储, 分布式,四舍五入就是能存海量数据
- 数据搜索, 倒排索引,目标字段高亮
- 数据分析
安装
可选: 新建用户
useradd elasticesearch -G 用户组(考虑需要java环境,自己玩直接root完事了) passwd elasticksearch
-
下载安装包
国内:
[官网:](https://www.elastic.co/downloads/ https://docker.elastic.dev/ https://www.elastic.co/guide/index.html)
这里选择6.7版本, 7.x模式需要java11才行,liunx版本最好也别太低不然会有奇奇怪怪的错. -
解压
tar -zxvf -C /opt/module/
- 修改配置文件
vim config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#集群名,相同集群名的集群为同一集群
cluster.name: es-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#节点名
node.name: node-1
#
# Add custom attributes to the node:
#
node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#数据存储路径,相对位置的data目录下
path.data: data
#
# Path to log files:
#日志存储路径,相对位置的data目录下
path.logs: logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: linux02
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["linux01","linux02","linux03"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
bootstrap.system_call_filter: false
- 有错改错没错启动
启动
./bin/elasticsearch
1)不要用root用户去启动
2)可能出现
ERROR: [1] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
解决方案:
vi /etc/security/limits.conf,添加下面内容:
- soft nofile 65535
- hard nofile 65535
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案:
vim /etc/sysctl.conf
在最后面添加:
vm.max_map_count=262144
使用sysctl -p命令刷新
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
解决方案:
在root用户下追加配置
vim /etc/security/limits.conf
配置内容 *表示所有用户生效
* soft nofile 65536
* hard nofile 65536
重新登录即可生效
可使用命令查看是否生效ulimit -H -n
3)别的问题:
盘它
- 测试
es启动命令在其目录的bin下
启动命令: …/bin/elasticsearch
以守护进程方式启动: …/bin/elasticsearch -d
停止命令: …/bin/elasticsearch -q
打开hostname:9200 出现以下信息证明安装并启动成功:
[root@linux02 ~]# curl -XGET linux02:9200
{
"name" : "node-1",
"cluster_name" : "es-application",
"cluster_uuid" : "i2Hu3tBqQ5izXmdsV6cKcw",
"version" : {
"number" : "6.7.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "8453f77",
"build_date" : "2019-03-21T15:32:29.844721Z",
"build_snapshot" : false,
"lucene_version" : "7.7.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}