RPM包方式部署

节点信息

节点 节点IP
elastic-01 10.0.0.51
elastic-02 10.0.0.52
elastic-03 10.0.0.53

准备工作

配置好三个节点的名称解析,修改/etc/hosts字段,增加解析记录

  1. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  2. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  3. 10.0.0.51 elastic-01
  4. 10.0.0.52 elastic-02
  5. 10.0.0.53 elastic-03

安装

将elasticsearch安装包上传至三台服务器,并通过yum方式安装
[root@elastic-01 ~]# yum install -y elasticsearch-7.13.4-x86_64.rpm

配置

下面是elastic-01节点的配置,将此配置文件复制到另外两个节点,并修改node-name字段即可

  1. [root@elastic-01 ~]# cat /etc/elasticsearch/elasticsearch.yml
  2. # ======================== Elasticsearch Configuration =========================
  3. #
  4. # NOTE: Elasticsearch comes with reasonable defaults for most settings.
  5. # Before you set out to tweak and tune the configuration, make sure you
  6. # understand what are you trying to accomplish and the consequences.
  7. #
  8. # The primary way of configuring a node is via this file. This template lists
  9. # the most important settings you may want to configure for a production cluster.
  10. #
  11. # Please consult the documentation for further information on configuration options:
  12. # https://www.elastic.co/guide/en/elasticsearch/reference/index.html
  13. #
  14. # ---------------------------------- Cluster -----------------------------------
  15. #
  16. # Use a descriptive name for your cluster:
  17. #
  18. cluster.name: xsc-ela
  19. #
  20. # ------------------------------------ Node ------------------------------------
  21. #
  22. # Use a descriptive name for the node:
  23. #
  24. node.name: elastic-01
  25. node.data: true
  26. #
  27. # Add custom attributes to the node:
  28. #
  29. #node.attr.rack: r1
  30. #
  31. # ----------------------------------- Paths ------------------------------------
  32. #
  33. # Path to directory where to store the data (separate multiple locations by comma):
  34. #
  35. path.data: /var/lib/elasticsearch
  36. #
  37. # Path to log files:
  38. #
  39. path.logs: /var/log/elasticsearch
  40. #
  41. # ----------------------------------- Memory -----------------------------------
  42. #
  43. # Lock the memory on startup:
  44. #
  45. #bootstrap.memory_lock: true
  46. #
  47. # Make sure that the heap size is set to about half the memory available
  48. # on the system and that the owner of the process is allowed to use this
  49. # limit.
  50. #
  51. # Elasticsearch performs poorly when the system is swapping the memory.
  52. #
  53. # ---------------------------------- Network -----------------------------------
  54. #
  55. # By default Elasticsearch is only accessible on localhost. Set a different
  56. # address here to expose this node on the network:
  57. #
  58. network.host: 0.0.0.0
  59. #
  60. # By default Elasticsearch listens for HTTP traffic on the first free port it
  61. # finds starting at 9200. Set a specific HTTP port here:
  62. #
  63. http.port: 9200
  64. #
  65. # For more information, consult the network module documentation.
  66. #
  67. # --------------------------------- Discovery ----------------------------------
  68. #
  69. # Pass an initial list of hosts to perform discovery when this node is started:
  70. # The default list of hosts is ["127.0.0.1", "[::1]"]
  71. #
  72. discovery.seed_hosts:
  73. - elastic-01
  74. - 10.0.0.52:9300
  75. - 10.0.0.53
  76. #
  77. # Bootstrap the cluster using an initial set of master-eligible nodes:
  78. #
  79. cluster.initial_master_nodes: ["elastic-01", "elastic-02", "elastic-03"]
  80. #
  81. # For more information, consult the discovery and cluster formation module documentation.
  82. #
  83. # ---------------------------------- Various -----------------------------------
  84. #
  85. # Require explicit names when deleting indices:
  86. #
  87. #action.destructive_requires_name: true

启动

三个节点依次启动Elasticsearch

  1. [root@elastic-01 ~]# systemctl start elasticsearch.service
  2. [root@elastic-02 ~]# systemctl start elasticsearch.service
  3. [root@elastic-03 ~]# systemctl start elasticsearch.service

安装状态检测

  • 检查节点信息是否健康

    1. [root@elastic-01 ~]# curl -X GET "localhost:9200/_cat/health?v"
    2. epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
    3. 1627523688 01:54:48 xsc-ela green 3 3 18 9 0 0 0 0 - 100.0%
  • 查看节点

    1. [root@elastic-01 ~]# curl -X GET "localhost:9200/_cat/nodes?v"
    2. ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
    3. 10.0.0.51 24 97 1 0.01 0.04 0.05 cdfhilmrstw * elastic-01
    4. 10.0.0.53 15 96 0 0.10 0.05 0.05 cdfhilmrstw - elastic-03
    5. 10.0.0.52 19 96 0 0.00 0.01 0.05 cdfhilmrstw - elastic-02
  • 查看索引

    1. [root@elastic-01 ~]# curl -X GET "localhost:9200/_cat/indices?v"
    2. health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
    3. green open nginx_test_2021.07.29 OMtP9e4ESRiRiB8MBWbsCQ 1 1 15 0 94.3kb 47.1kb
    4. green open .apm-custom-link 0qFbAAiLQeC3ldT3vbDUQQ 1 1 0 0 416b 208b
    5. green open .apm-agent-configuration UV-OTgILQYSDq-licT99Gg 1 1 0 0 416b 208b
    6. green open .kibana-event-log-7.13.4-000001 pAsKggWmTgWBgYi2zUK5dg 1 1 1 0 11.2kb 5.6kb
    7. green open filebeat-7.13.4-2021.07.28-000001 iAbgjsdZR8unGL9aT_q-rg 1 1 6 0 64.6kb 32.3kb
    8. green open .async-search R3z9OSc0T1S3OGiHiFhBeA 1 1 0 0 53.4kb 231b
    9. green open .kibana_7.13.4_001 gwkkud28Td-A2ys5tD-3MQ 1 1 50 1 8.5mb 4.2mb
    10. green open .kibana_task_manager_7.13.4_001 vYIF80d0S_SSu9Ayu3dVKg 1 1 10 1757 718.4kb 413.3kb