基于Linux Centos7 环境下,安装Elasticsearch6.2.2,以及安装elasticsearch-analysis-ik-6.2.2分词器

一、Elasticsearch简介

Elasticsearch是一个高度可伸缩的开源全文搜索和分析引擎。它允许您快速、实时地存储、搜索和分析大量数据。它通常用作底层引擎/技术,为具有复杂搜索特性和需求的应用程序提供动力。

二、安装环境

JDK版本:必须1.8以上

yum install java-1.8.0-openjdk.x86_64

三、安装步骤

1. 创建目录
[root@VM_0_3_centos /]# mkdir software
2. 创建用户

ElasticSearch默认是不能使用root用户进行启动的,所以需要先添加一个用户,并使用用户身份安装ElasticSearch。

[root@VM_0_3_centos software]# adduser qianye 
[root@VM_0_3_centos software]# passwd qianye 
3. 下载Elasticsearch6.2.2安装包

切换到创建的用户下
这里是使用wget下载Elasticsearch6.2.2安装包,也可以去Elaticsearch官网下载

[root@VM_0_3_centos /]# chown -R qianye:qianye software
[root@VM_0_3_centos /]# su qianye 
[qianye@VM_0_3_centos /]$ cd software/
[qianye@VM_0_3_centos software]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz
4. 解压Elasticsearch6.2.2安装包
[qianye@VM_0_3_centos software]$ tar -zxvf elasticsearch-6.2.2.tar.gz

解压后

[qianye@VM_0_3_centos software]$ ll
total 28408
drwxr-xr-x 8 qianye qianye     4096 Feb 17  2018 elasticsearch-6.2.2
-rw-rw-r-- 1 qianye qianye 29049540 May 15  2018 elasticsearch-6.2.2.tar.gz
5. 进入elasticsearch-6.2.2包,启动elasticsearch
[qianye@VM_0_3_centos software]$ cd elasticsearch-6.2.2/
[qianye@VM_0_3_centos elasticsearch-6.2.2]$ cd bin/
[qianye@VM_0_3_centos bin]$ ./elasticsearch

启动后,提示一下信息,则启动成功

[2019-07-17T16:58:08,178][INFO ][o.e.n.Node               ] [SoRQUPp] starting ...
[2019-07-17T16:58:08,470][INFO ][o.e.t.TransportService   ] [SoRQUPp] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
[2019-07-17T16:58:08,495][WARN ][o.e.b.BootstrapChecks    ] [SoRQUPp] max virtual memory areas vm.max_map_count [65530] is too low, increase to at le
ast [262144]
[2019-07-17T16:58:11,597][INFO ][o.e.c.s.MasterService    ] [SoRQUPp] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {SoRQUPp}{So
RQUPpDQqqsqIAbrItF_Q}{d9xfGSLdRm2VFJxdlo1HIg}{127.0.0.1}{127.0.0.1:9300}
[2019-07-17T16:58:11,603][INFO ][o.e.c.s.ClusterApplierService] [SoRQUPp] new_master {SoRQUPp}{SoRQUPpDQqqsqIAbrItF_Q}{d9xfGSLdRm2VFJxdlo1HIg}{127.0.
0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {SoRQUPp}{SoRQUPpDQqqsqIAbrItF_Q}{d9xfGSLdRm2VFJxdlo1HIg}{127.0.0.1}{127.0.0.1
:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2019-07-17T16:58:11,631][INFO ][o.e.h.n.Netty4HttpServerTransport] [SoRQUPp] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}
[2019-07-17T16:58:11,631][INFO ][o.e.n.Node               ] [SoRQUPp] started
[2019-07-17T16:58:11,653][INFO ][o.e.g.GatewayService     ] [SoRQUPp] recovered [0] indices into cluster_state
6. 测试启动成功结果

新开一个窗口,输入curl:localhost:9200,出现一下信息,则说明启动成功。
基于Linux Centos7 环境下,安装Elasticsearch6.2.2,以及安装elasticsearch-analysis-ik-6.2.2分词器_第1张图片

四、配置外网访问

在config/elasticsearch.yml添加如下内容:
network.host: 0.0.0.0
基于Linux Centos7 环境下,安装Elasticsearch6.2.2,以及安装elasticsearch-analysis-ik-6.2.2分词器_第2张图片

五、 后台启动elasticsearch

[qianye@VM_0_3_centos elasticsearch-6.2.2]$ nohup bin/elasticsearch &

五、常见错误处理

  1. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    问题:
    最大虚拟内存区域vm.max_map_count[65530]太低,至少增加到[262144]
    解决方法:
    [root@localhost ~]# vim /etc/sysctl.conf,添加一行配置vm.max_map_count=655360
    执行:sysctl -p 使其生效

  2. max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
    问题:
    用于elasticsearch进程的最大文件描述符[65535]过低,至少增加到[65536]

  3. max number of threads [1024] for user [es] is too low, increase to at least [4096]
    问题:
    用户的最大线程数[1024]太低,至少增加到[4096]
    对于第2个和第3个问题,可以通过编辑[root@localhost ~]# vi /etc/security/limits.conf ,添加如下内容:

    * soft nofile 65536
    * hard nofile 65536
    * soft nproc 4096
    * hard nproc 4096
    

    solf是软限制的意思,hard是硬限制;软限制可以在程序的进程中自行改变(突破限制),而硬限制则不行(除非程序进程有root权限)

六、安装elasticsearch-analysis-ik-6.2.2分词器

1. 下载elasticsearch-analysis-ik-6.2.2分词器安装包

https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v6.2.2

2. 上传安装包

将下载好的elasticsearch-analysis-ik-6.2.2分词器安装包,上传到elasticsearch-6.2.2文件夹下的plugins文件夹下

3. 解压安装包,并修改文件夹名称,并移除安装包
[qianye@VM_0_3_centos plugins]$ unzip elasticsearch-analysis-ik-6.2.2.zip
[qianye@VM_0_3_centos plugins]$ mv elasticsearch elasticsearch-ik
[qianye@VM_0_3_centos plugins]$ rm -rf elasticsearch-analysis-ik-6.2.2.zip

基于Linux Centos7 环境下,安装Elasticsearch6.2.2,以及安装elasticsearch-analysis-ik-6.2.2分词器_第3张图片

4. 重启启动elasticsearch服务

出现如下信息,则表示ik成功加入

你可能感兴趣的:(Linux,Elasticsearch,Centos7,ik分词器)