ElasticSearch-6.3.2 linux 安装

在linux 系统安装ElasticSearch-6.3.2最新版本,也适合6.x 系列版本做参考

前提先在linux 安装好jdk1.8

 

创建用户

从5.0开始,ElasticSearch 安全级别提高了,不允许采用root帐号启动,所以我们要添加一个用户

 

1 创建 elasticsearch 用户组

[root@localhost ~]# groupadd elasticsearch

2 创建用户 es 并设置密码为es

[root@localhost ~]# useradd es
[root@localhost ~]# passwd es

3 用户es 添加到 elasticsearch 用户组

[root@localhost ~]# usermod -G elasticsearch es

4 设置sudo权限

[root@localhost ~]# visudo
在root ALL=(ALL) ALL 一行下面 
添加es用户 如下:
es ALL=(ALL) ALL

添加成功保存后切换到es用户操作
[root@localhost ~]# su es
[es@localhost root]$ 

  

下载安装包

在/usr/local/src 目录下 下载elasticsearch ,并解压 tar.gz 

[es@localhost src]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.tar.gz

[es@localhost src]$ tar -xvf elasticsearch-6.3.2.tar.gz 

把解压的文件移动到 /usr/local 
[es@localhost src]$ sudo mv elasticsearch-6.3.2 /usr/local

更改elasticsearch-6.3.2 文件夹以及内部文件的所属用户为es, 用户组组为elasticsearch,-R表示逐级

[es@localhost local]$ sudo chown -R es:elasticsearch elasticsearch-6.3.2

 

ElasticSearch 配置

elasticsearch.yml 修改

[es@localhost elasticsearch-6.3.2]$ vim config/elasticsearch.yml 

修改内容(没有就添加):

cluster.name: my-application

node.name: node-1

network.host: 0.0.0.0 

http.port: 9200

#因为Centos6不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

修改/etc/sysctl.conf 

切换回root 用户 执行

vim /etc/sysctl.conf

在文件最后面添加内容:

vm.max_map_count=262144

保存退出后,使用sysctl -p 刷新生效

[root@localhost ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
vm.max_map_count = 262144
[root@localhost ~]# 

修改文件/etc/security/limits.conf

vim /etc/security/limits.conf

添加如下内容:

* hard nofile 65536
* soft nofile 65536

* soft nproc 2048
* hard nproc 4096 

启动elasticesearch 可能还会报如下错误

max number of threads [1024] for user [lish] likely too low, increase to at least [4096]

解决:切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 4096

 

启动 elasticsearch

完成上面配置修改后,切换到es 用户,目录切换到 elasticsearch 安装目录下执行

[es@localhost elasticsearch-6.3.2]$ bin/elasticsearch

在浏览器输入localhost:9200 验证是否启动成功,如果浏览器输出如下信息,代表安装启动成功

{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "8okSnhNzRr6Xo233szO0Vg",
  "version" : {
    "number" : "6.3.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "053779d",
    "build_date" : "2018-07-20T05:20:23.451332Z",
    "build_snapshot" : false,
    "lucene_version" : "7.3.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

  

如果启动过程中出现异常信息,请根据信息百度相关问题,下面是我启动过程遇到的错误信息并附上解决方案

异常信息1:expecting token of type [START_OBJECT] but found [VALUE_STRING]]; 

错误原因:elasticsearch.yml 文件内部错误 
解决办法:仔细检查yml文件中的配置项书写格式: (空格)name:(空格)value

---------------------------------------------------------------------------------
异常信息2:java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
 错误原因:Centos6不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动
 
解决办法:修改elasticsearch.yml 添加一下内容 :

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
异常信息3:BindTransportException[Failed to bind to [9300-9400]
解决办法 打开配置文件elasticsearch.yml 将 network.host: 192.168.0.1 修改为本机IP 0.0.0.0


--------------------------------------------------------------------------------------------
异常信息4:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

解决办法:切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf 

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 2048
View Code

 

 

 

 
posted @ 2018-08-09 13:10  jingping  阅读(16851)  评论(1编辑  收藏  举报