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

es集群安装及优化

es主节点
192.168.23.100
es节点
192.168.23.101
192.168.23.102

1.安装主节点

1.去官网下载es的yum包
官网下载地址 https://www.elastic.co/cn/downloads/elasticsearch
根据自己的需要下载对应的包
在这里插入图片描述

2.下载好之后把所有的包都传到从节点上,安装

[root@localhost ~]# ansible all -m copy -a 'src=/root/elasticsearch-8.11.3-x86_64.rpm dest=/root/elasticsearch-8.11.3-x86_64.rpm'
192.168.23.102 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": true, "checksum": "64c9029f99fa4beeabae1a36d1a88b8bf44982cf", "dest": "/root/elasticsearch-8.11.3-x86_64.rpm", "gid": 0, "group": "root", "md5sum": "d4b85a836646cd0b8c1d87848bf2e77c", "mode": "0644", "owner": "root", "size": 630669510, "src": "/root/.ansible/tmp/ansible-tmp-1704551077.26-16135-196050427416681/source", "state": "file", "uid": 0
}
192.168.23.101 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": true, "checksum": "64c9029f99fa4beeabae1a36d1a88b8bf44982cf", "dest": "/root/elasticsearch-8.11.3-x86_64.rpm", "gid": 0, "group": "root", "md5sum": "d4b85a836646cd0b8c1d87848bf2e77c", "mode": "0644", "owner": "root", "size": 630669510, "src": "/root/.ansible/tmp/ansible-tmp-1704551077.26-16133-148347610662829/source", "state": "file", "uid": 0
}
[root@localhost ~]# ansible all -m shell -a 'ls /root/'
192.168.23.102 | CHANGED | rc=0 >>
anaconda-ks.cfg
elasticsearch-8.11.3-x86_64.rpm
192.168.23.101 | CHANGED | rc=0 >>
anaconda-ks.cfg
elasticsearch-8.11.3-x86_64.rpm[root@localhost ~]# ansible all -m shell -a 'yum localinstall /root/elasticsearch-8.11.3-x86_64.rpm -y'
[WARNING]: Consider using the yum module rather than running 'yum'.  If you need to use command because yum is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in
ansible.cfg to get rid of this message.
192.168.23.101 | CHANGED | rc=0 >>
Loaded plugins: fastestmirror
Examining /root/elasticsearch-8.11.3-x86_64.rpm: elasticsearch-8.11.3-1.x86_64
Marking /root/elasticsearch-8.11.3-x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package elasticsearch.x86_64 0:8.11.3-1 will be installed
--> Finished Dependency ResolutionDependencies Resolved================================================================================Package          Arch      Version       Repository                       Size
================================================================================
Installing:elasticsearch    x86_64    8.11.3-1      /elasticsearch-8.11.3-x86_64    1.2 GTransaction Summary
================================================================================
Install  1 PackageTotal size: 1.2 G

3.更改主配置文件

[root@localhost ~]# grep -Ev "^#|^$" /etc/elasticsearch/elasticsearch.yml 
cluster.name: ELK cluster            #集群名字,每个节点一样    
node.name: {{ ansible_hostname }}    #每个机器的主机名
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0              # 通讯地址,设置为本机ip或者0.0.0.0,让所有机器都可以访问
discovery.seed_hosts: ["192.168.23.100", "192.168.23.101","192.168.23.102"] #每个节点相同
cluster.initial_master_nodes: ["192.168.23.100"]  #此为选举主节点,如果写一个就默认那一个是主节点,如果写多个,让他们自己去竞争那个是节点
xpack.security.enabled: false   #关闭安全认证
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:enabled: truekeystore.path: certs/http.p12
xpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: certs/transport.p12truststore.path: certs/transport.p12
http.host: 0.0.0.0

4.写yml吧配置文件传送到 其他节点

[root@es ~]# cat 1.yml 
---
[root@es ~]# cat 1.yml 
[root@es ~]# cat 1.yml 
---
- name: copy eshosts: xptasks:- name: copy estemplate:src: /etc/elasticsearch/elasticsearch.ymldest: /etc/elasticsearch/elasticsearch.ymlnotify: restart es- name: restart esservice:name: elasticsearchenabled: yeshandlers:- name: restart esservice:name: elasticsearchstate: restarted    

5.运行playbook

[root@es ~]# ansible-playbook 1.yml PLAY [copy es] ***************************************************************************************************************************************************************************************************TASK [Gathering Facts] *******************************************************************************************************************************************************************************************
ok: [192.168.23.101]
ok: [192.168.23.102]TASK [copy es] ***************************************************************************************************************************************************************************************************
ok: [192.168.23.102]
ok: [192.168.23.101]TASK [restart es] ************************************************************************************************************************************************************************************************
changed: [192.168.23.102]
changed: [192.168.23.101]PLAY RECAP *******************************************************************************************************************************************************************************************************
192.168.23.101             : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
192.168.23.102             : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

此时在访问主节点上的9200端口

在这里插入图片描述

内存优化

[root@es ~]# egrep '## -Xm' /etc/elasticsearch/jvm.options
## -Xms4g
## -Xmx4g#推荐使用物理机的一半,es的heap最大内存不超过30g,26g是最安全的范例
[root@es ~]# egrep '-Xm' /etc/elasticsearch/jvm.options
-Xms30g
-Xmx30g
http://www.lryc.cn/news/279712.html

相关文章:

  • 【开源】基于JAVA+Vue+SpringBoot的医院门诊预约挂号系统
  • Java Swing 图书借阅系统 窗体项目 期末课程设计 窗体设计
  • 2024.01.09.Apple_UI_BUG
  • K8S Nginx Ingress Controller client_max_body_size 上传文件大小限制
  • Untiy HTC Vive VRTK 开发记录
  • 机器学习指南:如何学习机器学习?
  • 使用numpy处理图片——分离通道
  • metartc5_jz源码阅读-yang_rtcpush_on_rtcp_ps_feedback
  • 计算机毕业设计 | SpringBoot+vue的家庭理财 财务管理系统(附源码)
  • 前端面试题集合三(js)
  • ssm基于JAVA的酒店客房管理系统论文
  • 杨中科 .NETCORE ENTITY FRAMEWORK CORE-1 EFCORE 第一部分
  • 微信小程序 全局配置||微信小程序 页面配置||微信小程序 sitemap配置
  • 使用ffmpeg对视频进行静音检测
  • Servlet-Request
  • 数据结构-怀化学院期末题(490)
  • Matlab字符识别实验
  • MySQL夯实之路-存储引擎深入浅出
  • 内存卡为什么会提示格式化,内存卡提示格式化还能恢复吗
  • 阅读文献-胃癌
  • 水仙花数(Java解法)
  • vue3 源码解析(3)— computed 计算属性的实现
  • Alibaba-> EasyExcel 整理3
  • 创建组-RibbonGroup
  • 面试题目1
  • 考古学家 - 华为OD统一考试
  • Linux服务器安全配置基线
  • Kafka外网访问
  • Vant2组件库van-list+Toast下拉加载滚动条回顶问题
  • 使用 C++/WinRT 创作 API