Elasticsearch安装

1.什么是ELK

ELK是Elasticsearch、Logstash、 Kibana三大开源框架首字母大写简称。市面上也被成为Elastic Stack

1.Elasticsearch     负责日志的检索和存储

2.Logstash            负责日志的收集和分析,处理

3.Kibana                负责日志的可视化

 官方文档说明

启动 Elasticsearch |Elasticsearch 指南 [8.11] |弹性的

ELK架构:

 1.搭建ELK

     1.先搭建 Elasticsearsh   ,因为搭建了 Elasticsearsh之后,无论是搭建 Kibana,还是 logstash都可以尽兴数的联调

     2.搭建Kibana ,先把 web界面展示出来

     3.搭建 logstash

 1.安装 Elasticsearsh  

ES最新下载地址Past Releases of Elastic Stack Software | Elastic

历史版本下载Past Releases of Elastic Stack Software | Elastic

官网的下载会非常慢,我们也可以选择华为云镜像下载Index of elasticsearch-local

 1.下载好之后会有一个包,我们把他传到服务器上

 2.此时就已经传到服务器上了,并解压

[root@xpxplinux ~]# ls
anaconda-ks.cfg  elasticsearch-8.11.3-linux-x86_64.tar.gz  initial-setup-ks.cfg  snap  公共  模板  视频  图片  文档  下载  音乐  桌面

[root@xpxplinux ~]# tar xf elasticsearch-8.11.3-linux-x86_64.tar.gz 
[root@xpxplinux ~]# ls
anaconda-ks.cfg  elasticsearch-8.11.3  elasticsearch-8.11.3-linux-x86_64.tar.gz  initial-setup-ks.cfg  snap  公共  模板  视频  图片  文档  下载  音乐  桌面
[root@xpxplinux ~]# cd elasticsearch-8.11.3/
[root@xpxplinux elasticsearch-8.11.3]# ls
bin  config  jdk  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.asciidoc

#目录介绍
bin    启动文件
config 配置文件目录
    log4j2 日志配置文件
    jvm.options java虚拟机相关的配置(默认启动占1g内存,内容不够需要自己调整)
    elasticsearch.yml elasticsearch的配置文件! 默认9200端口!跨域!
lib  相关jar包
modules 功能模块目录
plugins 插件目录 ik分词器

3.更改配置文件

[root@xpxplinux config]# pwd
/root/elasticsearch-8.11.3/config
[root@xpxplinux config]# vim elasticsearch.yml 
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#


#吧  Network  的network.host 改成 0.0.0.0  因为是yaml语法,所以必须是顶行写 负责会报错

4.启动

[root@xpxplinux bin]# pwd
/root/elasticsearch-8.11.3/bin
[root@xpxplinux bin]# ./elasticsearch
十二月 16, 2023 11:58:18 上午 sun.util.locale.provider.LocaleProviderAdapter <clinit>
WARNING: COMPAT locale provider will be removed in a future release
[2023-12-16T11:58:20,648][ERROR][o.e.b.Elasticsearch      ] [xpxplinux] fatal exception while booting Elasticsearchjava.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.server@8.11.3/org.elasticsearch.bootstrap.Elasticsearch.initializeNatives(Elasticsearch.java:282)
	at org.elasticsearch.server@8.11.3/org.elasticsearch.bootstrap.Elasticsearch.initPhase2(Elasticsearch.java:167)
	at org.elasticsearch.server@8.11.3/org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:72)

See logs for more details.

ERROR: Elasticsearch did not exit normally - check the logs at /root/elasticsearch-8.11.3/logs/elasticsearch.log

ERROR: Elasticsearch exited unexpectedly, with exit code 1



当报这个错的时候,是因为 elasticsearch 是不允许root用户执行

5.创建用户,并执行

[root@xpxplinux ~]# useradd es            
[root@xpxplinux ~]# passwd es  
[root@xpxplinux ~]# cp -r elasticsearch-8.11.3 /home/es/   
[root@xpxplinux ~]# chmod -R 777 /home/es/elasticsearch-8.11.3/   
[root@xpxplinux ~]# su - es
上一次登录:六 12月 16 21:42:36 CST 2023pts/0 上
[es@xpxplinux ~]$ cd elasticsearch-8.11.3/bin/
[es@xpxplinux bin]$ ls
elasticsearch           elasticsearch-create-enrollment-token  elasticsearch-geoip     elasticsearch-reconfigure-node  elasticsearch-setup-passwords     elasticsearch-syskeygen
elasticsearch-certgen   elasticsearch-croneval                 elasticsearch-keystore  elasticsearch-reset-password    elasticsearch-shard               elasticsearch-users
elasticsearch-certutil  elasticsearch-env                      elasticsearch-node      elasticsearch-saml-metadata     elasticsearch-sql-cli
elasticsearch-cli       elasticsearch-env-from-file            elasticsearch-plugin    elasticsearch-service-tokens    elasticsearch-sql-cli-8.11.3.jar
[es@xpxplinux bin]$ ./elasticsearch
[2023-12-16T21:52:12,873][ERROR][o.e.b.Elasticsearch      ] [xpxplinux] node validation exception
[1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch. For more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.11/bootstrap-checks.html]
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]; for more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.11/_maximum_map_count_check.html]
ERROR: Elasticsearch did not exit normally - check the logs at /home/es/elasticsearch-8.11.3/logs/elasticsearch.log
[2023-12-16T21:52:12,918][WARN ][o.e.n.Node               ] [xpxplinux] unexpected exception while waiting for http server to closejava.util.concurrent.ExecutionException: java.lang.IllegalStateException: Can't move to stopped state when not started
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.elasticsearch.server@8.11.3/org.elasticsearch.node.Node.prepareForClose(Node.java:1776)
	at org.elasticsearch.server@8.11.3/org.elasticsearch.bootstrap.Elasticsearch.shutdown(Elasticsearch.java:468)
	at java.base/java.lang.Thread.run(Thread.java:1583)

See logs for more details.

发现抱错

6.修改系统最大文件句柄数(修改后需要重启系统才能生效)

[root@xpxplinux ~]# vim /etc/sysctl.conf
[root@xpxplinux ~]# grep -Ev '^$|^#' /etc/sysctl.conf 
vm.max_map_count=262144
[root@xpxplinux ~]# sysctl -p
vm.max_map_count = 262144
[root@xpxplinux ~]# su - es
上一次登录:六 12月 16 21:56:03 CST 2023:0 上
[es@xpxplinux ~]$ cd elasticsearch-8.11.3/bin/
[es@xpxplinux bin]$ ls
elasticsearch           elasticsearch-create-enrollment-token  elasticsearch-geoip     elasticsearch-reconfigure-node  elasticsearch-setup-passwords     elasticsearch-syskeygen
elasticsearch-certgen   elasticsearch-croneval                 elasticsearch-keystore  elasticsearch-reset-password    elasticsearch-shard               elasticsearch-users
elasticsearch-certutil  elasticsearch-env                      elasticsearch-node      elasticsearch-saml-metadata     elasticsearch-sql-cli
elasticsearch-cli       elasticsearch-env-from-file            elasticsearch-plugin    elasticsearch-service-tokens    elasticsearch-sql-cli-8.11.3.jar
[es@xpxplinux bin]$ ./elasticsearch
[2023-12-16T22:07:14,233][WARN ][o.e.h.n.Netty4HttpServerTransport] [xpxplinux] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/192.168.134.139:9200, remoteAddress=/192.168.134.139:42332}
[2023-12-16T22:07:41,327][WARN ][o.e.h.n.Netty4HttpServerTransport] [xpxplinux] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/192.168.134.139:9200, remoteAddress=/192.168.134.1:53986}
[2023-12-16T22:07:41,328][WARN ][o.e.h.n.Netty4HttpServerTransport] [xpxplinux] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/192.168.134.139:9200, remoteAddress=/192.168.134.1:53987}


#此时抱这个错误是因 导致 localhost:9200 无法访问,是因为 elasticsearch 开启了安全认证模式,需要关闭

7. 关闭 elasticsearch 安全认证模式,打开vim elasticsearch.yml,吧这两个 ture改成 false,保存退出

8.重启 elasticsearch 

[es@xpxplinux config]$ vim elasticsearch.yml 
[es@xpxplinux config]$ cd ..
[es@xpxplinux elasticsearch-8.11.3]$ cd bin/
[es@xpxplinux bin]$ ls
elasticsearch           elasticsearch-create-enrollment-token  elasticsearch-geoip     elasticsearch-reconfigure-node  elasticsearch-setup-passwords     elasticsearch-syskeygen
elasticsearch-certgen   elasticsearch-croneval                 elasticsearch-keystore  elasticsearch-reset-password    elasticsearch-shard               elasticsearch-users
elasticsearch-certutil  elasticsearch-env                      elasticsearch-node      elasticsearch-saml-metadata     elasticsearch-sql-cli
elasticsearch-cli       elasticsearch-env-from-file            elasticsearch-plugin    elasticsearch-service-tokens    elasticsearch-sql-cli-8.11.3.jar
[es@xpxplinux bin]$ ./elasticsearch
十二月 16, 2023 10:18:28 下午 sun.util.locale.provider.LocaleProviderAdapter <clinit>
WARNING: COMPAT locale provider will be removed in a future release
[2023-12-16T22:18:30,173][INFO ][o.a.l.i.v.PanamaVectorizationProvider] [xpxplinux] Java vector incubator API enabled; uses preferredBitSize=256
[2023-12-16T22:18:31,121][INFO ][o.e.n.Node               ] [xpxplinux] version[8.11.3], pid[4973], build[tar/64cf052f3b56b1fd4449f5454cb88aca7e739d9a/2023-12-08T11:33:53.634979452Z], OS[Linux/3.10.0-693.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/21.0.1/21.0.1+12-29]

9.再次访问

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装Elasticsearch,你可以按照以下步骤进行操作: 1. 首先,你可以从官方网站下载Elasticsearch安装包。官网下载地址为。 2. 下载完成后,解压缩安装包。你可以使用以下命令解压缩tar.gz文件: ```shell tar -zxvf elasticsearch-7.8.1-linux-x86_64.tar.gz ``` 3. 解压缩完成后,进入解压缩后的目录,找到配置文件elasticsearch.yml。你可以使用以下命令来编辑该文件并进行配置: ```shell vim /usr/local/elasticsearch-7.13.2/config/elasticsearch.yml ``` 4. 在编辑配置文件之前,你可能需要了解一些配置选项以满足你的需求。根据你的环境和需求,修改elasticsearch.yml文件中的配置选项。 5. 当你完成了配置文件的修改后,保存并退出编辑器。 6. 现在,可以启动Elasticsearch了。你可以使用以下命令启动Elasticsearch: ```shell ./bin/elasticsearch ``` 这是一个基本的安装和启动Elasticsearch的过程。请注意,具体的步骤可能因操作系统和版本而略有不同。确保你仔细阅读官方文档以获取更详细的安装指南。 关于卸载Elasticsearch,你可以按照以下步骤进行操作: 1. 首先,你可以通过以下命令来查看已安装Elasticsearch软件包: ```shell dpkg -l | grep elastic ``` 2. 接下来,你可以使用以下命令查找Elasticsearch安装关联: ```shell dpkg -L elasticsearch ``` 3. 然后,使用以下命令来移除已安装Elasticsearch软件包: ```shell dpkg -P elasticsearch ``` 4. 继续使用以下命令查找未卸载的目录和文件: ```shell find ./elasticsearch | grep elasticsearch ``` 注意:根据你的环境和安装方式,可能会有其他目录和文件与Elasticsearch相关。 5. 最后,根据你的环境,使用以下命令来移除相关的目录和文件: ```shell rm -r /var/lib/elasticsearch rm /var/lib/dpkg/info/elasticsearch.* rm /etc/default/elasticsearch rm /etc/init.d/elasticsearch ``` 请根据自己的具体环境和需求来执行移除目录和文件的操作,确保操作正确无误。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [一、ElasticSearch安装](https://blog.csdn.net/m0_51295655/article/details/123193074)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值