下载最新稳定版本的 elasticsearch:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.0.zip
解压 unzip elasticsearch-6.0.0.zip
修改配置文件: /usr/elasticsearch-6.0.0/config
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
cluster.name: motor-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: motor-es-node1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
#
# ----------------------------------- Paths ------------------------------------
#
path.data: /opt/es/data
#
# Path to log files:
#
path.logs: /opt/es/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: 192.168.136.128
#
# Set a custom port for HTTP:
#
http.port: 9200
transport.tcp.port: 9300
#
# 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: ["192.168.136.128", "192.168.136.145"]
discovery.zen.ping.unicast.hosts: ["192.168.136.128"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# 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
http.cors.enabled: true
http.cors.allow-origin: "*"
主要配置 日志路径 和 数据路径 和 集群 名称 节点 名称等 ES会将同网络下集群名称相同的节点加入集群中,所以注意修改个节点的节点名称
ES 启动 是不能使用 root 用户启用的
解决办法有两个:
1 新建一个新的用户 使用新的用户 启动,比如我新建了es 用户组 和 es 用户 这样的话 要吧 es文件夹下的 所有文件,所有日志 和 数据文件都要 让新用户有权限
首先 ll 会发现 所有的 文件所有都是属于 root 用户组的root用户
新建 es 用户组的es用户后执行
chown -R es:es elasticsearch6.0.6
之后再 ll 用户的所有的文件夹是es组和es 用户,es 日志 和 数据路劲文件做相同的操作
之后 su es
切换 es用户 在bin/elasticsearch 启动 elasticsearch 就可以 启动完成之后
访问 http://IP:9200/ 出现页面说明安装成功
IK Analysis for Elasticsearch
安装的两种方式:
方式1: - download pre-build package from here: https://github.com/medcl/elasticsearch-analysis-ik/releases
unzip plugin to folder your-es-root/plugins/
方式2 : use elasticsearch-plugin to install ( version > v5.5.1 )
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.0.0/elasticsearch-analysis-ik-6.0.0.zip
注意ik 和 elasticsearch的版本匹配问题
2 .restart elasticsearch 一定要重启 elasticsearch
移除名为
ik
的analyzer和tokenizer,请分别使用 ik_smart
和 ik_max_word
ik_max_word 和 ik_smart 什么区别?
ik_max_word: 会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合;
ik_smart: 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”。
IK的安装 完成参考的是官网 :https://github.com/medcl/elasticsearch-analysis-ik
关于使用IK和创建 mapping 会用另外的一篇记录下