ElasticSearch 6.x 学习笔记:1.下载安装与配置

1. 安装配置JDK 8

(1)下载并解压缩

[root@node1 ~]# tar -zxvf jdk-8u112-linux-x64.tar.gz -C /opt

(2)编辑环境变量 vi /etc/profile.d/custom.sh

[root@node1 ~]# vi /etc/profile.d/custom.sh
[root@node1 ~]# cat /etc/profile.d/custom.sh
#!/bin/bash
#java path
export JAVA_HOME=/opt/jdk1.8.0_112
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib

(3)生效

[root@node1 ~]# source /etc/profile.d/custom.sh

(4)查看JDK版本

[root@node1 ~]# java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
[root@node1 ~]#

2. ElasticSearch 6.x 软件包下载

(1)ElasticSearch 相关软件下载官网 https://www.elastic.co/cn/downloads

(2)下载ElasticSearch https://www.elastic.co/downloads/elasticsearch

[root@node1 ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.0.tar.gz
--2017-12-18 07:54:45--  https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.0.tar.gz
Resolving artifacts.elastic.co (artifacts.elastic.co)... 184.73.156.41, 54.225.188.6, 54.235.82.130, ...
Connecting to artifacts.elastic.co (artifacts.elastic.co)|184.73.156.41|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 28535876 (27M) [application/x-gzip]
Saving to: ‘elasticsearch-6.1.0.tar.gz’

100%[==============================================================================================>] 28,535,876  33.8KB/s   in 10m 53s

2017-12-18 08:05:39 (42.7 KB/s) - ‘elasticsearch-6.1.0.tar.gz’ saved [28535876/28535876]

[root@node1 ~]#

(2)解压缩 tar -zxvf elasticsearch-6.1.0.tar.gz

[root@node1 ~]# tar -zxvf elasticsearch-6.1.0.tar.gz -C /opt
elasticsearch-6.1.0/
elasticsearch-6.1.0/lib/
....
....
elasticsearch-6.1.0/modules/lang-painless/antlr4-runtime-4.5.3.jar
elasticsearch-6.1.0/plugins/
[root@node1 ~]# 

3. 创建用户

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

(1)创建es用户组

[root@node1 ~]# groupadd es

(2)创建用户es useradd es(用户名) -g es(组名) -p es(密码)

[root@node1 ~]# useradd es -g es -p es

(3)修改权限 更改elasticsearch-6.1.0文件夹以及内部文件的所属用户以及组为es,-R表示逐级(N层目录)

[root@node1 ~]# chown -R es:es /opt/elasticsearch-6.1.0

4. 启动

(1)切换用户

[root@node1 ~]# su es

(2)启动ElasticSearch

[es@node1 root]$ cd /opt/elasticsearch-6.1.0/
[es@node1 elasticsearch-6.1.0]$ bin/elasticsearch 
[2017-12-18T09:23:57,668][INFO ][o.e.n.Node               ] [] initializing ...
[2017-12-18T09:23:57,883][INFO ][o.e.e.NodeEnvironment    ] [MD1gu0h] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [15.4gb], net total_space [21.9gb], types [rootfs]
[2017-12-18T09:23:57,884][INFO ][o.e.e.NodeEnvironment    ] [MD1gu0h] heap size [1007.3mb], compressed ordinary object pointers [true]
[2017-12-18T09:23:57,887][INFO ][o.e.n.Node               ] node name [MD1gu0h] derived from node ID [MD1gu0heRDeWuoFvGaygqg]; set [node.name] to override
[2017-12-18T09:23:57,888][INFO ][o.e.n.Node               ] version[6.1.0], pid[2172], build[c0c1ba0/2017-12-12T12:32:54.550Z], OS[Linux/3.10.0-514.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_112/25.112-b15]
[2017-12-18T09:23:57,888][INFO ][o.e.n.Node               ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/opt/elasticsearch-6.1.0, -Des.path.conf=/opt/elasticsearch-6.1.0/config]
[2017-12-18T09:24:00,157][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [aggs-matrix-stats]
[2017-12-18T09:24:00,157][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [analysis-common]
[2017-12-18T09:24:00,158][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [ingest-common]
[2017-12-18T09:24:00,158][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [lang-expression]
[2017-12-18T09:24:00,158][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [lang-mustache]
[2017-12-18T09:24:00,158][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [lang-painless]
[2017-12-18T09:24:00,158][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [mapper-extras]
[2017-12-18T09:24:00,159][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [parent-join]
[2017-12-18T09:24:00,159][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [percolator]
[2017-12-18T09:24:00,159][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [reindex]
[2017-12-18T09:24:00,159][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [repository-url]
[2017-12-18T09:24:00,159][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [transport-netty4]
[2017-12-18T09:24:00,160][INFO ][o.e.p.PluginsService     ] [MD1gu0h] loaded module [tribe]
[2017-12-18T09:24:00,160][INFO ][o.e.p.PluginsService     ] [MD1gu0h] no plugins loaded
[2017-12-18T09:24:03,471][INFO ][o.e.d.DiscoveryModule    ] [MD1gu0h] using discovery type [zen]
[2017-12-18T09:24:04,371][INFO ][o.e.n.Node               ] initialized
[2017-12-18T09:24:04,371][INFO ][o.e.n.Node               ] [MD1gu0h] starting ...
[2017-12-18T09:24:04,637][INFO ][o.e.t.TransportService   ] [MD1gu0h] publish_address {192.168.80.131:9300}, bound_addresses {192.168.80.131:9300}
[2017-12-18T09:24:04,672][INFO ][o.e.b.BootstrapChecks    ] [MD1gu0h] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-12-18T09:24:07,765][INFO ][o.e.c.s.MasterService    ] [MD1gu0h] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {MD1gu0h}{MD1gu0heRDeWuoFvGaygqg}{AXDov8dlRNGpubGAks8ODA}{192.168.80.131}{192.168.80.131:9300}
[2017-12-18T09:24:07,773][INFO ][o.e.c.s.ClusterApplierService] [MD1gu0h] new_master {MD1gu0h}{MD1gu0heRDeWuoFvGaygqg}{AXDov8dlRNGpubGAks8ODA}{192.168.80.131}{192.168.80.131:9300}, reason: apply cluster state (from master [master {MD1gu0h}{MD1gu0heRDeWuoFvGaygqg}{AXDov8dlRNGpubGAks8ODA}{192.168.80.131}{192.168.80.131:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2017-12-18T09:24:07,835][INFO ][o.e.h.n.Netty4HttpServerTransport] [MD1gu0h] publish_address {192.168.80.131:9200}, bound_addresses {192.168.80.131:9200}
[2017-12-18T09:24:07,835][INFO ][o.e.n.Node               ] [MD1gu0h] started
[2017-12-18T09:24:07,851][INFO ][o.e.g.GatewayService     ] [MD1gu0h] recovered [0] indices into cluster_state

ctrl+c停止。 (3)后台运行 可以通过参数-d后台运行

[es@node1 elasticsearch-6.1.0]$ bin/elasticsearch -d

(4)查询进程

[es@node1 elasticsearch-6.1.0]$ jps
2327 Elasticsearch
2344 Jps
[es@node1 elasticsearch-6.1.0]$

5. 验证

使用curl验证

[es@node1 elasticsearch-6.1.0]$ curl localhost:9200
{
  "name" : "MD1gu0h",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "MRAhTG8pR1mAif_tGg9qYg",
  "version" : {
    "number" : "6.1.0",
    "build_hash" : "c0c1ba0",
    "build_date" : "2017-12-12T12:32:54.550Z",
    "build_snapshot" : false,
    "lucene_version" : "7.1.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
[es@node1 elasticsearch-6.1.0]$

6.异常闪退解决办法

可能出现elasticsearch启动后,闪退现象。

[es@node1 elasticsearch-6.1.0]$ bin/elasticsearch -d
[es@node1 elasticsearch-6.1.0]$ jps
2933 Jps
2918 Elasticsearch
[es@node1 elasticsearch-6.1.0]$ jps
2947 Jps
2918 Elasticsearch
[es@node1 elasticsearch-6.1.0]$ jps
3023 Jps
[es@node1 elasticsearch-6.1.0]$

查看日志

[es@node1 elasticsearch-6.1.0]$ vi logs/elasticsearch.log

发现异常信息

[2017-12-18T08:57:49,869][INFO ][o.e.n.Node               ] initialized
[2017-12-18T08:57:49,870][INFO ][o.e.n.Node               ] [MD1gu0h] starting ...
[2017-12-18T08:57:50,145][INFO ][o.e.t.TransportService   ] [MD1gu0h] publish_address {192.168.80.131:9300}, bound_addresses {192.168.80.131:9300}
[2017-12-18T08:57:50,163][INFO ][o.e.b.BootstrapChecks    ] [MD1gu0h] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-12-18T08:57:50,169][ERROR][o.e.b.Bootstrap          ] [MD1gu0h] node validation exception
[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]
[2017-12-18T08:57:50,245][INFO ][o.e.n.Node               ] [MD1gu0h] stopping ...
[2017-12-18T08:57:50,289][INFO ][o.e.n.Node               ] [MD1gu0h] stopped
[2017-12-18T08:57:50,290][INFO ][o.e.n.Node               ] [MD1gu0h] closing ...
[2017-12-18T08:57:50,311][INFO ][o.e.n.Node               ] [MD1gu0h] closed
[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]

切换到root用户,

[root@node1 elasticsearch-6.1.0]# vi /etc/sysctl.conf

添加内容如下:

vm.max_map_count=262144

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

[root@node1 logs]# vi /etc/security/limits.conf

添加如下内容

* hard nofile 65536
* soft nofile 65536

* soft nproc 2048
* hard nproc 4096

# End of file

然后重启即可。

7.修改配置文件

[es@node1 elasticsearch-6.1.0]$ vi config/elasticsearch.yml

修改network.host和http.port

# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.80.131
#
# Set a custom port for HTTP:
#
http.port: 9200

保存退出。

8.再次启动

(1)curl

[root@node1 ~]# curl 192.168.80.131:9200
{
  "name" : "MD1gu0h",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "MRAhTG8pR1mAif_tGg9qYg",
  "version" : {
    "number" : "6.1.0",
    "build_hash" : "c0c1ba0",
    "build_date" : "2017-12-12T12:32:54.550Z",
    "build_snapshot" : false,
    "lucene_version" : "7.1.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
[root@node1 ~]# 

(2)使用浏览器打开

如果在Windows平台通过浏览器打开,需要配置hosts。编辑C:\Windows\System32\drivers\etc\hosts 添加

192.168.80.131  node1

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏Netkiller

ElasticSearch + Logstash + Kibana 日志采集

本文节选自《Netkiller Monitoring 手札》 ElasticSearch + Logstash + Kibana 一键安装 配置 logst...

2704
来自专栏安富莱嵌入式技术分享

【安富莱二代示波器教程】第5章 示波器设计—波形快速刷新方案

波形快速刷新有很多方案需要测试,由于我们的GUI是采用的emWin,所以下面的这些测试都是基于emWin实现的。

852
来自专栏杨建荣的学习笔记

sqlplus / as sysdba无法登录的奇怪报错 (r8笔记第36天)

最近看了一个问题,看问题的表现着实比较奇怪,困扰了我好一会儿。 问题的背景是帮助开发的同学解决一个数据库问题,最后问题解决之后,我想做一个操作系统级的检查,帮他...

3418
来自专栏有困难要上,没有困难创造困难也要上!

在VirtualBox上使用Bosh部署Cloud Foundry

2997
来自专栏杨建荣的学习笔记

性能调优之redo切换频率(47天)

生产系统的一个库(负责容错处理的),目前遇到了严重的性能问题,数据量也大的出奇,一个分区表一百多个分区,blob字段达到了800多G.查看 AWR 系统负载倒不...

3274
来自专栏Netkiller

怎样制作RPM包

怎样制作RPM包 摘要 我在网上找RPM包的制作例子几乎都是C源码编译安装然后生成RPM包, 而我的程序不是C写的很多时候是脚本语言如Python, PHP 甚...

3946
来自专栏逸鹏说道

再论 ASP.NET 中获取客户端IP地址

说到IP获取无非是我们常见的以下几种方式,但是具体获取的值具体区别在哪?网上不乏相关文章,说的也是很详细,但是真正使用起来,还有很多不太对的地方。IP在不同系统...

3477
来自专栏PingCAP的专栏

TiDB 在小米的应用实践

MIUI 是小米公司旗下基于 Android 系统深度优化、定制、开发的第三方手机操作系统,也是小米的第一个产品。MIUI 在 Android 系统基础上,针对...

1202
来自专栏Golang语言社区

Golang 连接mssql sql server

package main import ( "database/sql" "fmt" "strings" ) import ( _ "github....

38510
来自专栏计算机视觉战队

Caffe源码---Blob基本使用

看到这个的时候,估计你也在学习caffe,嘿嘿!Blob在内存中表示4维数组,维度从低到高为(width_,height_,channels_,num_)。Bl...

2354

扫码关注云+社区