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

来源:互联网 发布:地产数据 编辑:程序博客网 时间:2024/06/05 16:03

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 pathexport JAVA_HOME=/opt/jdk1.8.0_112export PATH=$PATH:$JAVA_HOME/binexport CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib

(3)生效

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

(4)查看JDK版本

[root@node1 ~]# java -versionjava 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.gzResolving 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 OKLength: 28535876 (27M) [application/x-gzip]Saving to: ‘elasticsearch-6.1.0.tar.gz’100%[==============================================================================================>] 28,535,876  33.8KB/s   in 10m 53s2017-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 /optelasticsearch-6.1.0/elasticsearch-6.1.0/lib/........elasticsearch-6.1.0/modules/lang-painless/antlr4-runtime-4.5.3.jarelasticsearch-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]$ jps2327 Elasticsearch2344 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]$ jps2933 Jps2918 Elasticsearch[es@node1 elasticsearch-6.1.0]$ jps2947 Jps2918 Elasticsearch[es@node1 elasticsearch-6.1.0]$ jps3023 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

这里写图片描述

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 塑料瓶子盖子打不开怎么办 按压瓶盖坏了怎么办 瓶盖拧错位了怎么办 红酒盖子开不了怎么办 胶盖罐头打不开怎么办 玻璃瓶的塑料盖打不开怎么办 香水按压不出来怎么办 电高压锅盖子打不开怎么办 杯子螺口错位怎么办 散粉盖子扭不开怎么办 玻璃瓶饮料盖子打不开怎么办 玻璃瓶玻璃盖子打不开怎么办 美甲没有胶水怎么办 按压式瓶盖打不开怎么办 睫毛胶水瓶盖打不开怎么办 玻璃杯盖子滑丝怎么办 瓶盖滑扣了怎么办 胶水瓶口被塞住怎么办 美林盖子打不开怎么办 美林瓶盖打不开怎么办 泰诺瓶盖打不开怎么办 玻璃罐头瓶盖打不开怎么办 塑料罐头瓶盖打不开怎么办 喷笔壶盖打不开怎么办 陶瓷壶盖卡住了怎么办 贝德玛瓶盖摔坏怎么办 塑料盖子错位拧不开怎么办 安全瓶盖坏了怎么办 刚买面霜打不开怎么办 可乐瓶盖鼓起来怎么办 暖壶塞子吸住了怎么办 茶兀瓶盖打不开怎么办 水杯盖太紧了拧不开怎么办 矿泉水瓶盖拧不开了怎么办 弩弦用手拉不上怎么办 茅台酒瓶口漏酒怎么办 化妆品盖子丢了怎么办 化妆品盖子碎了怎么办 自制水泵压力小怎么办 大学数学不会做怎么办 下雪了怎么办教案幼儿园小班