前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Elasticsearch基础

Elasticsearch基础

作者头像
用户1456517
发布2019-03-05 16:02:26
4990
发布2019-03-05 16:02:26
举报
文章被收录于专栏:芝麻实验室芝麻实验室

环境说明:

  • 节点信息
    • node1: 192.168.10.221 (CentOS7)
    • node2: 192.168.10.222 (CentOS7)
    • node3: 192.168.10.223 (CentOS7)

安装前的准备

  • 时间同步 # ntpdate time_server_ip
  • 基于主机名的地址解析(即使用/etc/hosts,此处不推荐使用DNS域名解析系统) # cat /etc/hosts 192.168.10.221 node1 192.168.10.222 node2 192.168.10.223 node3 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  • 获取elasticsearch >> 传送门
    • 注:本系列实例中使用的ELK Stack组件均为XXX.5.5.3.rpm

安装elasticsearch

  • 在各个els节点安装elasticsearch 注:elasticsearch本身至少需要2GB的RAM才能运行Elasticsearch # yum -y install java-1.8.0-openjdk.x86_64 #依赖于Java环境 # rpm -ivh elasticsearch-5.5.3.rpm # cp /etc/elasticsearch/elasticsearch.yml{,.bak} # mkdir -pv /els/{data,log} # chown -R elasticsearch:elasticsearch /els/{data,log}

配置elasticsearch

  • 配置els集群 vim /etc/elasticsearch/elasticsearch.yml # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # cluster.name: zhima #集群名称 # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: node1 #当前节点在集群中的唯一标识名 # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # path.data: /els/data #节点数据存储路径 # # Path to log files: # path.logs: /els/log #节点日志存储路径 # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 192.168.10.221 #当前节点的IPv4/IPv6地址 # # Set a custom port for HTTP: # http.port: 9200 #服务端口,默认9200 # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # discovery.zen.ping.unicast.hosts: ["node1","node2","node3"] #集群成员列表,应保持奇数个 # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # discovery.zen.minimum_master_nodes: 2 #选举的获胜条件,为避免“脑裂”,应为(N/2+1) # # For more information, consult the zen discovery module documentation.
  • 启动elasticsearch # systemctl start elasticsearch.service
请输入图片描述
请输入图片描述

elasticsearch的使用

  • 集群构建状态检查
请输入图片描述
请输入图片描述
  • 获取集群成员关系 # curl -XGET 'http://192.168.10.221:9200/_cat/nodes' #获取集群成员关系 192.168.10.221 14 96 21 0.84 0.89 0.69 mdi - node1 #成员节点 192.168.10.223 12 48 0 0.00 0.01 0.05 mdi * node3 #星号表示主节点 192.168.10.222 11 48 0 0.04 0.03 0.05 mdi - node2 #成员节点
  • 创建索引 # curl -XPUT 'http://192.168.10.221:9200/docker'
  • 获取当前集群下的所有可用索引 # curl -XGET 'http://192.168.10.221:9200/_cat/indices?pretty' green open xiaomu QEwhn5gGQ2m3oEFjoAvKMA 5 1 0 0 1.5kb 810b green open docker FXWGiH6oSCyL6Int-W7boA 5 1 0 0 1.5kb 810b
  • 健康性检查
    • 节点健康性检查

    # curl -XGET 'http://192.168.10.221:9200/_cat/health?pretty' 1516176817 16:13:37 zhima green 3 3 20 10 0 0 0 0 - 100.0%

    • 集群健康性检查
    请输入图片描述
    请输入图片描述

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018/01/18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档