当前位置: 首页 > article >正文

1 elasticsearch安装

【0】官网参考

https://www.elastic.co/guide/en/elasticsearch/reference/7.11/targz.html

【1】Centos7 下载安装

【1.1】下载

官网:Download Elasticsearch | Elastic

选择好自己想要的相关版本即可;

【2】Centos7.X 前置环境配置(ulimit,vm.max_map_count,JDK)

1)ulimit

它至少要65535

vim /etc/security/limits.conf

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* soft stack 65535
* hard stack 65535

 ulimit -a,如下图,发现没有生效

退出登录重登后生效;su root

(2)vm.max_map_count >= 262144

vim /etc/sysctl.conf

然后在里面加上参数:

vm.max_map_count=2655350

保存,然后重新加载参数:

sysctl -p

(3)JDK安装,1.8+

检查是否有JAVA环境:

如果没有,参考下面文档

参考安装文档:

  如何在linux下安装jdk - 郭大侠1 - 博客园

注意,Elasticsearch7.x版本 建议使用 jdk 11版本以上,但其实1.8版本及以上也够了,如果没有设置 $JAVA_HOME 环境变量,那么将会默认使用自带jdk(自带11版本的);

所以其实不装问题也不大,设置一下$JAVA_HOME 环境变量在这个目录即可

(4)Swapping 设置

vim /etc/sysctl.conf

vm.swappiness=1

【3】Centos7.X下载安装 Elasticsearch7.X

【3.1】下载解压

(1)手动下载

那很明显,我们下载的就是这个

  LINUX X86_64shaasc

(1)自动下载

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.1-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.1-linux-x86_64.tar.gz.sha512
shasum -a 512 -c elasticsearch-7.11.1-linux-x86_64.tar.gz.sha512 
tar -xzf elasticsearch-7.11.1-linux-x86_64.tar.gz

【3.2】建立ES启动账户elk、授权

不知道从什么版本开始,elasticsearch 认为用 root 启动不安全,所以需要额外建立账户

groupadd elk
useradd elk -g elk
chown -R elk:elk ./elasticsearch-7.11.1
mv elasticsearch-7.11.1 /usr/local/elasticsearch

【3.3】配置 ElasticSearch 配置文件

cd /usr/local/elasticsearch
vim config/elasticsearch.yml
 
#添加配置
discovery.seed_hosts: ["127.0.0.1"]
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]

【3.4】启动:使用守护进程

# -d 是作为守护进程运行 , -p 是把进程id 存到文件
su - elk -c "exec /usr/local/elasticsearch/bin/elasticsearch -d -p /tmp/elasticsearch.pid" 

【3.5】核验安装是否成功

(1)查看9200端口是否启用、监听

(2)访问本机 9200 端口

 You can test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost:

就是说默认是本机9200端口,用就完事了;如下图:这就表示成功了!

(3)URL上访问

注意,如果这个不行,请注意查看防火墙、配置文件中的  network.host: 0.0.0.0 是否配置

【3.6】怎么关闭退出?

(1)pkill -F /tmp/elasticsearch.pid   (推荐,但前提是前面启动时使用了 -p 并文件是这个位置 )

(2)直接 kill pid

 #重启

su - elk -c "exec /usr/local/elasticsearch/bin/elasticsearch -d -p /tmp/elasticsearch.pid" 

【3.7】查阅:日志位置

这里面有很多日志,框出来的是错误日志,启动报错之类的信息看这里就好了;

至于其他的,gc 垃圾回收日志,slowlog 慢日志,audit.json 审计信息;

我这里有 log2 data2,是因为我之前有开多个实例;

【3.8】elasticsearch linux二进制版本目录介绍

目录结构说明,在配置文件里操作使用
• home目录 :使用$ES_HOME表示,如上图,就是 /usr/local/elasticsearch
• bin/ : 位置 $ES_HOME/bin,包含了elasticsearch和elasticsearch-plugin等脚本
• conf/ :位置 $ES_HOME/config,包含了 配置文件 elasticsearch.yml 和 log4j2.properties,使用 path.conf 指定
• data/ :位置 $ES_HOME/data,包含了每个index/shard的数据文件,可以指定多个位置,使用 path.data 指定
• logs/ : 位置 $ES_HOME/logs,使用 path.logs 指定
• plguins/ : 位置$ES_HOME/plugins
• repo/ :使用 path.repo指定,没有默认位置,表示共享文件系统repository的位置。可以指定多个位置。
• script/ :位置$ES_HOME/scripts,使用 path.scripts 指定。

【4】基本查询使用 

(1)查看健康情况(_cat/health)

(2)查看所有索引(_cat/indices)

(3)查看所有节点(_cat/nodes)

【错误处理】

(1)FileAlreadyExistsException:/root/elasticsearch/........

表示之前可能启动过一次,但是被中止或者失败了;

后续的路径文件已经生产,删掉这个文件即可;

(2)uncaught exception in thread [main]org.elasticsearch.bootstrap.StartupException:

寻找主要信息:failed to obtain node locks

导致的原因可能是因为之前运行的es还没有正常关闭。

第一步:通过命令:ps aux | grep ‘elastic’ 进行查看

    ES可能已经起了两个进程,把进程kill掉之后重新启动就可以了。

第二步:通过命令: kill -9 进程号 关闭此进程。

第三步:重新启动es。./bin/elasticsearch

(3)ElasticsearchUncaughtExceptionHandler

这是因为不知从哪个版本后,elasticsearch为了安全性,是不能用root用户启动的。

解决的办法:当然是创建一个用户,用创建的用户启动啦,注意权限的问题,目录也应该改为创建的用户权限!

我是用elk的用户启动,exec参数指定命令,这样就可以了
su - elk -c "exec /opt/appl/elasticsearch-6.5.4/bin/elasticsearch -d

(4)【bootstrap checks failed】max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

每个进程最大同时打开文件数太小:解决,见【2】中(1)

[root@DB1 config]# ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
ERROR: Elasticsearch did not exit normally - check the logs at /usr/local/elasticsearch-7.11.1/logs/elasticsearch.log

(5)【bootstrap checks failed】max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

elasticsearch用户拥有的内存权限太小,至少需要262144

(6)【bootstrap checks failed】the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

看提示可知:缺少默认配置,至少需要配置discovery.seed_hosts/discovery.seed_providers/cluster.initial_master_nodes中的一个参数.

discovery.seed_hosts:  集群主机列表
discovery.seed_providers: 基于配置文件配置集群主机列表
cluster.initial_master_nodes: 启动时初始化的参与选主的node,生产环境必填

vim config/elasticsearch.yml
 
 
#添加配置
discovery.seed_hosts: ["127.0.0.1"]
 
cluster.initial_master_nodes: ["node-1"]

(7)could not find java; set JAVA_HOME or ensure java is in PATH

JAVA 缺失,确定装了JDK

 【开发模式与生产模式】

默认情况下,Elasticsearch假定您正在开发模式下工作。如果上述任何设置的配置不正确,都会在日志文件中写入警告,但是您将能够启动和运行Elasticsearch节点。

一旦您配置了类似的网络设置network.host,Elasticsearch就会假设您即将投入生产,并将上述警告升级为异常。这些异常将阻止您的Elasticsearch节点启动。这是一项重要的安全措施,可确保不会因服务器配置错误而丢失数据。

请注意,可以通过http.host和单独配置HTTP和传输transport.host。这对于将单个节点配置为可通过HTTP进行访问以进行测试(而不触发生产模式)很有用。

设置开发者模式:(如果是具体IP,则是生产模式,他们的区别就是是否能够需要做启动自检)

http.host: localhost
transport.bind_host: localhost
discovery.type: single-node 
开机启动检查相关参数:


http://www.kler.cn/news/321194.html

相关文章:

  • 什么是开放式耳机?具有什么特色?非常值得入手的蓝牙耳机推荐
  • 【C++位图】构建灵活的空间效率工具
  • 计算机毕业设计选题推荐-基于python的养老院数据可视化分析
  • R18 NES 之SSB-less SCell operation for inter-band CA
  • 基于vue框架的宠物寻回小程序8g7el(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。
  • MATLAB系列09:图形句柄
  • 论文解读《Object-Centric Learning with Slot Attention》
  • 网络模型的保存与读取
  • Testbench编写与Vivado Simulator的基本操作
  • 如何快速免费搭建自己的Docker私有镜像源来解决Docker无法拉取镜像的问题(搭建私有镜像源解决群晖Docker获取注册表失败的问题)
  • 解决SVN蓝色问号的问题
  • 线性基学习DAY2
  • Kafka 面试题
  • 一个证明-待验证
  • 平衡、软技能与持续学习
  • pdf编辑转换器怎么用?分享9个pdf编辑、转换方法(纯干货)
  • 基于深度学习的药品三期OCR字符识别
  • 生成式语言模型底层技术面试
  • 修改Docker默认存储路径,解决系统盘占用90%+问题(修改docker root dir)
  • 【笔记】数据结构|链表算法总结|快慢指针场景和解决方案|链表归并算法和插入算法|2012 42
  • 共享单车轨迹数据分析:以厦门市共享单车数据为例(八)
  • 爬虫过程 | 蜘蛛程序爬取数据流程(初学者适用)
  • P335_0334韩顺平Java_零钱通介绍
  • 华为NAT ALG技术的实现
  • AttributeError: ‘Sequential‘ object has no attribute ‘predict_classes‘如何解决
  • 【Python报错已解决】ModuleNotFoundError: No module named ‘psutil’
  • Android——运行时动态申请权限
  • [Redis][Hash]详细讲解
  • 828华为云征文 | 在华为云X实例上部署微服务架构的文物大数据管理平台的实践
  • linux命令:显示已安装在linux内核的模块的详细信息的工具modinfo详解