Elastic Stack之 Elasticsearch 6.7.1版本单机版安装、集群版安装

本文详细介绍了Elasticsearch 6.7.1版本的单机和集群安装步骤,包括Java环境配置、Elasticsearch的下载与解压、用户权限设置、防火墙配置以及集群配置。在集群配置中,强调了至少需要两个node.master为true的节点以确保高可用性,并解决了启动过程中可能出现的文件描述符和虚拟内存限制错误。
摘要由CSDN通过智能技术生成

1、截至目前Elasticsearch 版本已经更新到了7.10.1版本了,这里先使用Elasticsearch 6.7.1版本,给一个下载地址,如下所示:

官方下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch

如果你只是找到了最新版本的下载地址,却不知道历史版本如何下载,只要点击下面的即可:

2、由于Elasticsearch是Java开发的,所以需要安装Jdk的,这里安装jdk-8u271-linux-x64.tar.gz。

注意:安装elasticsearch之前安装好java,因为elasticsearch是Java语言开发的,注意选择Java的版本是1.8.0的第20版本以后的,第20之前的会出现很多问题。

1 [root@k8s-master package]# tar zxvf jdk-8u271-linux-x64.tar.gz -C /usr/local/soft/

然后配置到环境变量中,如下所示:

1 [root@k8s-master soft]# 
2 [root@k8s-master soft]# vim /etc/profile
3 [root@k8s-master soft]# source /etc/profile

配置环境变量,内容,如下所示:

然后开始安装单节点的 Elasticsearch 6.7.1版本,如下所示:

1 [root@k8s-master package]# tar -zxvf elasticsearch-6.7.1.tar.gz -C /usr/local/soft/

解压缩之后,使用./bin/elasticsearch进行运行,发现报错了,Elasticsearch 不支持使用root进行启动,所以需要创建一个Elasticsearch 的账号,如下所示:

 1 [root@k8s-master soft]# cd elasticsearch-6.7.1/
 2 [root@k8s-master elasticsearch-6.7.1]# 
 3 [root@k8s-master elasticsearch-6.7.1]# 
 4 [root@k8s-master elasticsearch-6.7.1]# ls
 5 bin  config  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.textile
 6 [root@k8s-master elasticsearch-6.7.1]# ./bin/elasticsearch
 7 [2021-01-09T17:19:19,506][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
 8 org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
 9     at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.7.1.jar:6.7.1]
10     at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.7.1.jar:6.7.1]
11     at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.7.1.jar:6.7.1]
12     at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.7.1.jar:6.7.1]
13     at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.7.1.jar:6.7.1]
14     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.7.1.jar:6.7.1]
15     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.7.1.jar:6.7.1]
16 Caused by: java.lang.RuntimeException: can not run elasticsearch as root
17     at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.7.1.jar:6.7.1]
18     at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.7.1.jar:6.7.1]
19     at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.7.1.jar:6.7.1]
20     at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.7.1.jar:6.7.1]
21     ... 6 more
22 [root@k8s-master elasticsearch-6.7.1]# 

创建elsearch组和elsearch用户,然后将刚才解压缩的授权给新创建的用户,如下所示:

 1 [root@k8s-master elasticsearch-6.7.1]# groupadd elsearch
 2 [root@k8s-master elasticsearch-6.7.1]# useradd elsearch -g elsearch
 3 [root@k8s-master elasticsearch-6.7.1]# passwd elsearch
 4 Changing password for user elsearch.
 5 New password:
 6 BAD PASSWORD: The password contains the user name in some form
 7 Retype new password:
 8 passwd: all authentication tokens updated successfully.
 9 [root@k8s-master elasticsearch-6.7.1]# cd /usr/local/soft/
10 [root@slaver4 soft]# ls
11 elasticsearch-6.7.1
12 [root@slaver4 soft]# chown -R elsearch:elsearch elasticsearch-6.7.1/
13 [root@slaver4 soft]# su elsearch
14 [elsearch@slaver4 soft]$ ls
15 elasticsearch-6.7.1
16 [elsearch@slaver4 soft]$ cd elasticsearch-6.7.1/
17 [elsearch@slaver4 elasticsearch-6.7.1]$ ls
18 bin  config  data  hs_err_pid11491.log  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.textile

此时,启动elasticsearch,如下所示:

 1 [elsearch@k8s-master elasticsearch-6.7.1]$ ./bin/elasticsearch
 2 [2021-01-09T17:27:31,756][INFO ][o.e.e.NodeEnvironment    ] [5q5VHg0] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [3gb], net total_space [17.7gb], types [rootfs]
 3 [2021-01-09T17:27:31,764][INFO ][o.e.e.NodeEnvironment    ] [5q5VHg0] heap size [1007.3mb], compressed ordinary object pointers [true]
 4 [2021-01-09T17:27:31,769][INFO ][o.e.n.Node               ] [5q5VHg0] node name derived from node ID [5q5VHg0JSpawCOXUgpsQ3w]; set [node.name] to override
 5 [2021-01-09T17:27:31,770][INFO ][o.e.n.Node               ] [5q5VHg0] version[6.7.1], pid[101788], build[default/tar/2f32220/2019-04-02T15:59:27.961366Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_271/25.271-b09]
 6 [2021-01-09T17:27:31,770][INFO ][o.e.n.Node               ] [5q5VHg0] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -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, -Djava.io.tmpdir=/tmp/elasticsearch-3395773329025720144, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/usr/local/soft/elasticsearch-6.7.1, -Des.path.conf=/usr/local/soft/elasticsearch-6.7.1/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
 7 [2021-01-09T17:27:39,562][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [aggs-matrix-stats]
 8 [2021-01-09T17:27:39,563][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [analysis-common]
 9 [2021-01-09T17:27:39,563][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [ingest-common]
10 [2021-01-09T17:27:39,563][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [ingest-geoip]
11 [2021-01-09T17:27:39,563][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [ingest-user-agent]
12 [2021-01-09T17:27:39,564][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [lang-expression]
13 [2021-01-09T17:27:39,564][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [lang-mustache]
14 [2021-01-09T17:27:39,564][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [lang-painless]
15 [2021-01-09T17:27:39,564][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [mapper-extras]
16 [2021-01-09T17:27:39,566][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [parent-join]
17 [2021-01-09T17:27:39,566][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [percolator]
18 [2021-01-09T17:27:39,566][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [rank-eval]
19 [2021-01-09T17:27:39,567][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [reindex]
20 [2021-01-09T17:27:39,567][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [repository-url]
21 [2021-01-09T17:27:39,567][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [transport-netty4]
22 [2021-01-09T17:27:39,567][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [tribe]
23 [2021-01-09T17:27:39,567][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-ccr]
24 [2021-01-09T17:27:39,567][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-core]
25 [2021-01-09T17:27:39,568][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-deprecation]
26 [2021-01-09T17:27:39,568][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-graph]
27 [2021-01-09T17:27:39,568][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-ilm]
28 [2021-01-09T17:27:39,568][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-logstash]
29 [2021-01-09T17:27:39,568][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-ml]
30 [2021-01-09T17:27:39,568][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded module [x-pack-monitoring]
31 [2021-01-09T17:27:39,568][INFO ][o.e.p.PluginsService     ] [5q5VHg0] loaded
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值