首页 > 系统相关 >Linux学习-ELK(一)

Linux学习-ELK(一)

时间:2024-09-10 22:20:19浏览次数:3  
标签:ELK name es1 192.168 学习 elasticsearch Linux root es

配置三台elasticsearch服务器

安装包
elasticsearch.j2

报错
#---执行rsync命令报以下错误
[root@es1 ~]# rsync -av /etc/hosts 192.168.29.172:/etc/hosts
[email protected]'s password:
bash: rsync: 未找到命令
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.3]
解决方法

== 同步双方机器都需要安装rsync==

机器环境:RockyLinux8.6
资源列表:es1,es2,es3,nfs-server
es1:192.168.29.171
es2:192.168.29.172
es3:192.168.29.173
nfs-server:192.168.29.139
#-----------------配置本地yum仓库
#------------搭建nfs-server

[root@harbor ~]# yum install -y nfs-utils
#查看nfs-server配置文件
[root@harbor ~]# cat /etc/exports
/var/ftp 192.168.29.0/24(rw,no_root_squash)
[root@harbor ~]# systemctl enable nfs-server --now
#------------搭建nfs-server
[root@harbor ftp]# createrepo --update /var/ftp/elk
Directory walk started
Directory walk done - 5 packages
Loaded information about 0 packages
Temporary output repo path: /var/ftp/elk/.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished
[root@harbor ~]# ls /var/ftp/elk
elasticsearch-7.17.8-x86_64.rpm  kibana-7.17.8-x86_64.rpm    metricbeat-7.17.8-x86_64.rpm
filebeat-7.17.8-x86_64.rpm       logstash-7.17.8-x86_64.rpm  repodata
#-----------------配置本地yum仓库
#---------在三台机器上分别安装elasticsearch
#-----yum配置文件
[root@es1 ~]# cat /etc/yum.repos.d/extra.repo
[es]
name=Rocky Linux $releasever - es
#mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever
baseurl=ftp://192.168.29.139/elk/
gpgcheck=0
enabled=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[root@es1 ~]# dnf install -y elasticsearch
#集群名称
cluster.name: elk-cluster
#节点名称
node.name: es1
#监听地址
network.host: 0.0.0.0
#集群广播成员,用于设置Elasticsearch节点启动时去连接的种子节点列表,这有助于节点能够发现集群中的其他节点
discovery.seed_hosts: ["es1", "es2","es3"]
#集群创始人成员,用于指定集群启动时应该被选举为初始主节点的节点列表
cluster.initial_master_nodes: ["es1", "es2","es3"]
[root@es1 ~]# systemctl enable elasticsearch --now

[root@es1 ~]# curl 192.168.29.171:9200
{
  "name" : "es1",
  "cluster_name" : "elk-cluster",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "7.17.8",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "120eabe1c8a0cb2ae87cffc109a5b65d213e9df1",
    "build_date" : "2022-12-02T17:33:09.727072865Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
使用Ansible批量部署ES
[root@harbor es]# cat ansible.cfg
[defaults]
inventory         = hostlist
host_key_checking = False

#elasticsearch.j2通过变量获取主机名称
node.name: {{ ansible_hostname }}

#部署es的playbook文件
[root@harbor es]# cat deployes.yaml
---
- name: deploy es
  hosts: es
  tasks:
  - name: 'set /etc/hosts'
    copy:
      dest: /etc/hosts
      owner: root
      group: root
      mode: 0644
      content: |
        127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
        ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
        {% for i in groups.es %}
        {{ hostvars[i].ansible_ens160.ipv4.address }}{{ hostvars[i].ansible_hostname }}
        {% endfor %}
  - name: install es
    dnf:
      name: elasticsearch
      state: latest
      update_cache: yes
  - name: copy config file
    template:
      src: elasticsearch.j2
      dest: /etc/elasticsearch/elasticsearch.yml
      owner: root
      group: elasticsearch
      mode: 0600
  - name: update es service
    service:
      name: elasticsearch
      state: started
      enabled: yes
#主机列表文件
[root@harbor es]# cat hostlist
[web]
192.168.29.161
192.168.29.162
[es]
192.168.29.171
192.168.29.172
192.168.29.173
[root@harbor es]# ansible-playbook deployes.yaml
#部署完成后,查看集群状态

[root@el2 ~]# curl 192.168.29.172:9200/_cat/nodes?pretty
192.168.29.172 26 94  4 0.55 0.21 0.10 cdfhilmrstw * es2
192.168.29.171 12 93  4 0.09 0.11 0.08 cdfhilmrstw - es1
192.168.29.173  7 93 30 1.09 0.32 0.16 cdfhilmrstw - es3

部署插件页面

[root@es1 ~]# dnf install -y nginx
[root@es1 ~]# systemctl enable nginx --now
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@es1 ~]# tar xf head.tar.gz -C /usr/share/nginx/html/

在这里插入图片描述

认证和代理
[root@es1 conf.d]# cat /etc/nginx/default.d/es.conf
location ~* ^/es/(.*)$ {
        proxy_pass http://127.0.0.1:9200/$1;
        auth_basic "elastic admin";
        auth_basic_user_file /etc/nginx/auth-user;
}
[root@es1 conf.d]# dnf install -y httpd-tools
[root@es1 conf.d]# htpasswd -cm /etc/nginx/auth-user admin
[root@es1 conf.d]# systemctl restart nginx

在这里插入图片描述

标签:ELK,name,es1,192.168,学习,elasticsearch,Linux,root,es
From: https://blog.csdn.net/xuwenpeng/article/details/142071255

相关文章

  • 【05】纯血鸿蒙HarmonyOS NEXT星河版开发0基础学习笔记-条件渲染+if/switch判断与for/
     序言:本文详细介绍了ArkTs语言中的数组、if单双多分支判断、switch判读、while循环、for循环并给出相应的具体案例和实现代码,附有综合案例京东购物的加购。笔者也是跟着B站黑马的课程一步步学习,学习的过程中添加部分自己的想法整理为笔记分享出来,如有代码错误或笔误,欢迎指正......
  • 【06】纯血鸿蒙HarmonyOS NEXT星河版开发0基础学习笔记-综合案例·生肖抽奖卡具体实现
    序言:本文综合了前五次笔记的知识内容,完成了相对来说较为复杂的生肖抽奖卡案例,通过拆分和一步步的思路分析完成本案例,通过完成这次案例,笔者可以说是把前面的所有内容或多或少的都有所复习,特此分享给大家。笔者也是跟着B站黑马的课程一步步学习,学习的过程中添加部分自己的想法......
  • 机器学习入门篇
    文章目录什么是机器学习?常见机器学习框架经典算法及使用场景1.监督学习(SupervisedLearning)2.无监督学习(UnsupervisedLearning)3.半监督学习(Semi-SupervisedLearning)4.强化学习(ReinforcementLearning)5.集成学习(EnsembleLearning)6.深度学习(DeepLearning)什......
  • Linux网络——从《计算机网络》到网络编程
    文章目录从《计算机网络》到网络编程从计算机到计算机网络解决问题网络与计算机系统计算机网络的传输流程IP地址与MAC地址从《计算机网络》到网络编程科班的同学大多学过计算机网络,而非科班的同学也多多少少听说过一些计算机网络体系十分繁杂且精妙,这三四十年来计......
  • 数码管学习之路(静动态数码管源码及学习理解)
    1,了解数码管分类及结构    数码管是一种半导体发光器件,其基本单元是发光二极管。数码管按段数一般分为七段数码管和八段数码管,八段数码管比七段数码管多一个发光二极管(多一个小数点显示)。当然也还有一些其他类型的数码管如“N”形管、“米”字管以及工业科研领域用的1......
  • 【Linux进程详解】进程地址空间
    目录1.直接写代码看现象2.引入最基本的理解3.细节问题-理解它1.直接写代码看现象#include<stdio.h>#include<string.h>#include<unistd.h>#include<stdlib.h>#include<unistd.h>intg_val=100;intmain(){printf("fatherisrunning,pid:%d,......
  • 【学习】【xxl-job】8000字 + 25图探秘其核心架构原理
    参考......
  • Linux命令实践
    Linux命令实践学习Linux核心命令1.ls列出当前目录中的文件和目录djy666@ubuntu:~$ls20221307公共的模板视频图片文档下载音乐桌面Desktopdjyhellohello.chello.osnapls-l列出详细信息使用长格式列出目录内容,包括文件权限、所有者、文件......
  • gdb动态调试初步学习
    CTF题目simple-check-100先分析主程序可以得出需要通过check_key然后就可以输出flag了gdb启动在main函数那里打一个断点r运行到断点位置n单步调试直到testeax,eax查看eax的值ireax设置eax的值为1set$eax=1c继续直接运行完......
  • HTML/CSS/JS学习笔记 Day4(HTML--C3 表格)
    跟着该视频学习,记录笔记:【黑马程序员pink老师前端入门教程,零基础必看的h5(html5)+css3+移动端前端视频教程】https://www.bilibili.com/video/BV14J4114768?p=12&vd_source=04ee94ad3f2168d7d5252c857a2bf358Day4 内容梳理:目录HTML3.0表格3.1表格标签(1)语法基本标签......