Elasticsearch 5.6.5 安装教程

Posted 猪脚踏浪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Elasticsearch 5.6.5 安装教程相关的知识,希望对你有一定的参考价值。

下载地址   https://www.elastic.co/downloads/past-releases/elasticsearch-5-6-5

 安装环境  centos6.5  ,  jdk1.8

一:解压  

[[email protected] programs]# tar zxvf elasticsearch-5.6.5.tar.gz

 二:创建ES用户和组(创建elsearch用户组及elsearch用户)

因为使用root用户执行ES程序,将会出现错误;所以这里需要创建单独的用户去执行ES 文件。 

[[email protected] programs]# groupadd elsearch   ##添加用户组
[[email protected] programs]# useradd elsearch -g elsearch   ##添加用户到用户组
[[email protected] programs]# chown -R elsearch:elsearch elasticsearch-5.6.5  ##更改该文件夹下所属的用户组的权限

 三:创建ES数据文件和日志文件

直接在root用户根目录一下创建 

[[email protected] data]# mkdir /data

更改权限

[[email protected] data]# chown -R elsearch:elsearch /data/

 切换用户

[[email protected] data]# su - elsearch

 创建 es的data和logs目录

[[email protected] ~]$ cd /data
[elsearch@localhost ~]$ mkdir -p es/data
[elsearch@localhost ~]$ mkdir -p es/logs

 四:修改ES配置文件

 进入到config文件夹,编辑 elasticsearch.yml 

/usr/local/programs/elasticsearch-5.6.5/config
[root@localhost config]# vi elasticsearch.yml 

修改如下(没有配置集群,只是简单的配置了一下):

#集群名称
cluster.name: my-application     
#节点名称
node.name: node-1    
#数据存储目录(多个路径用逗号分隔)
path.data: /data/es/data
#日志目录
path.logs: /data/es/logs
# 修改一下ES的监听地址,这样别的机器才可以访问
network.host: 10.10.10.5
# 监听端口(默认的就好)  
http.port: 9200

 注意,设置参数的时候“:冒号”后面要有空格

五:启动

切换到elsearch用户,进入到bin 目录下执行 ./elasticsearch 命令就可以了,执行 ./elasticesrarch -d 是后台运行

[[email protected] bin]$ ./elasticsearch
[2018-01-05T10:17:09,102][INFO ][o.e.n.Node               ] [node-1] initializing ...
[2018-01-05T10:17:09,271][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/data (/dev/mapper/ol-data)]], net usable_space [737.3gb], net total_space [737.3gb], spins? [possibly], types [xfs]
[2018-01-05T10:17:09,272][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [1.9gb], compressed ordinary object pointers [true]
[2018-01-05T10:17:09,273][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [O9EeZpd5Q0yYJjRUV7bfLg]
[2018-01-05T10:17:09,273][INFO ][o.e.n.Node               ] [node-1] version[5.6.5], pid[4810], build[6a37571/2017-12-04T07:50:10.466Z], OS[Linux/3.8.13-35.3.1.el7uek.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_65/25.65-b01]
[2018-01-05T10:17:09,274][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/programs/elasticsearch-5.6.5]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2018-01-05T10:17:11,467][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-groovy]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [parent-join]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty3]
[2018-01-05T10:17:11,468][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2018-01-05T10:17:11,469][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2018-01-05T10:17:14,679][INFO ][o.e.d.DiscoveryModule    ] [node-1] using discovery type [zen]
[2018-01-05T10:17:15,887][INFO ][o.e.n.Node               ] [node-1] initialized
[2018-01-05T10:17:15,888][INFO ][o.e.n.Node               ] [node-1] starting ...
[2018-01-05T10:17:16,187][INFO ][o.e.t.TransportService   ] [node-1] publish_address {10.10.10.5:9300}, bound_addresses {10.10.10.5:9300}
[2018-01-05T10:17:16,209][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-01-05T10:17:16,238][INFO ][o.e.n.Node               ] [node-1] stopping ...
[2018-01-05T10:17:16,351][INFO ][o.e.n.Node               ] [node-1] stopped
[2018-01-05T10:17:16,351][INFO ][o.e.n.Node               ] [node-1] closing ...
[2018-01-05T10:17:16,367][INFO ][o.e.n.Node               ] [node-1] closed

 发现错误1:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

意思是说你的进程不够用了。

解决方案: 切到root 用户:进入到security目录下的limits.conf;执行命令 vi /etc/security/limits.conf :

[[email protected] bin]# vi /etc/security/limits.conf

在文件的末尾添加下面的参数值:

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

 

发现错误2:

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

操作系统的vm.max_map_count参数设置太小导致的,请使用root用户登录系统,执行以下命令:

[[email protected] bin]# sysctl -w vm.max_map_count=655360        
vm.max_map_count = 655360
[root@localhost bin]# sysctl -a | grep "vm.max_map_count"    #查看是否修改成功
vm.max_map_count = 655360

 再次切换到elsearch用户,进入到bin 目录下执行 ./elasticsearch 命令,启动正常。

六:测试

外部访问需要方法9200端口,打开防火墙端口。

在浏览器中访问http://自己配置的IP地址:9200/,出现下面信息:

{
  "name" : "node-1",
  "cluster_name" : "my-application",
  "cluster_uuid" : "xS4wySq2SMKdeBvSO2nxqg",
  "version" : {
    "number" : "5.6.5",
    "build_hash" : "6a37571",
    "build_date" : "2017-12-04T07:50:10.466Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}

说明可以正常访问。

以上是关于Elasticsearch 5.6.5 安装教程的主要内容,如果未能解决你的问题,请参考以下文章

kibana 和ES安装配置常见问题解决

elasticsearch ik中文分词器的安装配置使用

是否需要从Logstash向HTTPS输出到Elasticsearch购买“xpack”?

Elasticsearch Java API 配置测试

Elasticsearch安装教程

Elasticsearch入门教程:Elasticsearch及插件安装