es集群安装

向右看齐 2022-11-16 04:51 314阅读 0赞

]官网下载es

  1. https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.0-linux-x86_64.tar.gz

集群环境机器准备




































ip 监听端口 主机名 系统 es实例名 es版本
10.10.164.1 9200/9300 elsearch Centos6 node-1 7.12.0
10.10.164.2 9200/9300 elsearch Centos6 node-2 7.12.0
10.10.164.3 9200/9300 elsearch Centos6 node-3 7.12.0

每一台服务器都需要操作。

  1. 在/opt下创建es 把下载好后把安装包放入
  2. cd /opt
  3. #创建es目录
  4. mkdir es
  5. cd es
  6. #下载安装包
  7. wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.0-linux-x86_64.tar.gz
  8. #解压
  9. tar -vxf elasticsearch-7.12.0-linux-x86_64.tar.gz
  10. #修改解压后的文件名为 elasticsearch-a,(为了方便区分根据节点名)
  11. mv elasticsearch-7.4.0 elasticsearch-1
  12. # 创建数据存储目录
  13. mkdir -p /opt/es/elasticsearch-a/data
  14. # 创建日志存储目录
  15. mkdir -p /opt/es/elasticsearch-a/logs
  16. #注:这里为了区分是es的多个节点,
  17. #第1台的目录文件夹为 elasticsearch-1
  18. #第2台的目录文件夹为 elasticsearch-2
  19. #第3台的目录文件夹为 elasticsearch-3

节点node-1配置

进入到es安装目录下的config文件夹中,修改elasticsearch.yml 文件

  1. # ======================== Elasticsearch Configuration =========================
  2. #
  3. # NOTE: Elasticsearch comes with reasonable defaults for most settings.
  4. # Before you set out to tweak and tune the configuration, make sure you
  5. # understand what are you trying to accomplish and the consequences.
  6. #
  7. # The primary way of configuring a node is via this file. This template lists
  8. # the most important settings you may want to configure for a production cluster.
  9. #
  10. # Please consult the documentation for further information on configuration options:
  11. # https://www.elastic.co/guide/en/elasticsearch/reference/index.html
  12. #
  13. # ---------------------------------- Cluster -----------------------------------
  14. #
  15. # Use a descriptive name for your cluster:
  16. #
  17. #配置es的集群名称,同一个集群中的多个节点使用相同的标识
  18. #如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。
  19. cluster.name: my-cluster
  20. #
  21. # ------------------------------------ Node ------------------------------------
  22. #
  23. # Use a descriptive name for the node:
  24. #
  25. #节点名称
  26. node.name: node-1
  27. #是不是有资格竞选主节点
  28. node.master: true
  29. #
  30. # Add custom attributes to the node:
  31. #
  32. #node.attr.rack: r1
  33. #
  34. # ----------------------------------- Paths ------------------------------------
  35. #
  36. # Path to directory where to store the data (separate multiple locations by comma):
  37. #
  38. #数据存储路径
  39. path.data: /opt/es/data
  40. #
  41. # Path to log files:
  42. #
  43. #日志存储路径
  44. path.logs: /opt/es/logs
  45. #
  46. # ----------------------------------- Memory -----------------------------------
  47. #
  48. # Lock the memory on startup:
  49. #
  50. #ES默认开启了内存地址锁定,为了避免内存交换提高性能。但是Centos6不支持SecComp功能,启动会报错,所以需要将其设置为false
  51. #bootstrap.memory_lock: true
  52. #
  53. # Make sure that the heap size is set to about half the memory available
  54. # on the system and that the owner of the process is allowed to use this
  55. # limit.
  56. #
  57. # Elasticsearch performs poorly when the system is swapping the memory.
  58. #
  59. # ---------------------------------- Network -----------------------------------
  60. #
  61. # By default Elasticsearch is only accessible on localhost. Set a different
  62. # address here to expose this node on the network:
  63. #
  64. #节点所绑定的IP地址,并且该节点会被通知到集群中的其他节点
  65. #通过指定相同网段的其他节点会加入该集群中 0.0.0.0任意IP都可以访问elasticsearch
  66. network.host: 10.10.164.1
  67. bootstrap.system_call_filter: false
  68. #
  69. # By default Elasticsearch listens for HTTP traffic on the first free port it
  70. # finds starting at 9200. Set a specific HTTP port here:
  71. #
  72. #作为数据节点
  73. node.data: true
  74. #对外提供服务的http端口,默认为9200
  75. http.port: 9200
  76. # 是否支持跨域
  77. http.cors.enabled: true
  78. # *表示支持所有域名
  79. http.cors.allow-origin: "*"
  80. #内部节点之间沟通端口
  81. transport.tcp.port: 9300
  82. #设置是否压缩TCP传输时的数据,默认为false
  83. transport.tcp.compress: true
  84. #network.publish_host:10.10.164.1
  85. cluster.routing.allocation.disk.threshold_enabled: false
  86. #
  87. # For more information, consult the network module documentation.
  88. #
  89. # --------------------------------- Discovery ----------------------------------
  90. #
  91. # Pass an initial list of hosts to perform discovery when this node is started:
  92. # The default list of hosts is ["127.0.0.1", "[::1]"]
  93. #
  94. #es7.x 之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点
  95. discovery.seed_hosts: ["10.10.164.1:9300", "10.10.164.2:9300","10.10.164.3:9300"]
  96. #
  97. # Bootstrap the cluster using an initial set of master-eligible nodes:
  98. #
  99. #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
  100. cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
  101. #
  102. # For more information, consult the discovery and cluster formation module documentation.
  103. #
  104. # ---------------------------------- Various -----------------------------------
  105. #
  106. # Require explicit names when deleting indices:
  107. #
  108. #action.destructive_requires_name: true

节点node-2配置

  1. # ======================== Elasticsearch Configuration =========================
  2. #
  3. # NOTE: Elasticsearch comes with reasonable defaults for most settings.
  4. # Before you set out to tweak and tune the configuration, make sure you
  5. # understand what are you trying to accomplish and the consequences.
  6. #
  7. # The primary way of configuring a node is via this file. This template lists
  8. # the most important settings you may want to configure for a production cluster.
  9. #
  10. # Please consult the documentation for further information on configuration options:
  11. # https://www.elastic.co/guide/en/elasticsearch/reference/index.html
  12. #
  13. # ---------------------------------- Cluster -----------------------------------
  14. #
  15. # Use a descriptive name for your cluster:
  16. #
  17. #配置es的集群名称,同一个集群中的多个节点使用相同的标识
  18. #如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。
  19. cluster.name: my-cluster
  20. #
  21. # ------------------------------------ Node ------------------------------------
  22. #
  23. # Use a descriptive name for the node:
  24. #
  25. #节点名称
  26. node.name: node-2
  27. #是不是有资格竞选主节点
  28. node.master: true
  29. #
  30. # Add custom attributes to the node:
  31. #
  32. #node.attr.rack: r1
  33. #
  34. # ----------------------------------- Paths ------------------------------------
  35. #
  36. # Path to directory where to store the data (separate multiple locations by comma):
  37. #
  38. #数据存储路径
  39. path.data: /opt/es/data
  40. #
  41. # Path to log files:
  42. #
  43. #日志存储路径
  44. path.logs: /opt/es/logs
  45. #
  46. # ----------------------------------- Memory -----------------------------------
  47. #
  48. # Lock the memory on startup:
  49. #
  50. #ES默认开启了内存地址锁定,为了避免内存交换提高性能。但是Centos6不支持SecComp功能,启动会报错,所以需要将其设置为false
  51. #bootstrap.memory_lock: true
  52. #
  53. # Make sure that the heap size is set to about half the memory available
  54. # on the system and that the owner of the process is allowed to use this
  55. # limit.
  56. #
  57. # Elasticsearch performs poorly when the system is swapping the memory.
  58. #
  59. # ---------------------------------- Network -----------------------------------
  60. #
  61. # By default Elasticsearch is only accessible on localhost. Set a different
  62. # address here to expose this node on the network:
  63. #
  64. #节点所绑定的IP地址,并且该节点会被通知到集群中的其他节点
  65. #通过指定相同网段的其他节点会加入该集群中 0.0.0.0任意IP都可以访问elasticsearch
  66. network.host: 10.10.164.2
  67. bootstrap.system_call_filter: false
  68. #
  69. # By default Elasticsearch listens for HTTP traffic on the first free port it
  70. # finds starting at 9200. Set a specific HTTP port here:
  71. #
  72. #作为数据节点
  73. node.data: true
  74. #对外提供服务的http端口,默认为9200
  75. http.port: 9200
  76. # 是否支持跨域
  77. http.cors.enabled: true
  78. # *表示支持所有域名
  79. http.cors.allow-origin: "*"
  80. #内部节点之间沟通端口
  81. transport.tcp.port: 9300
  82. #设置是否压缩TCP传输时的数据,默认为false
  83. transport.tcp.compress: true
  84. #network.publish_host:10.10.164.2
  85. cluster.routing.allocation.disk.threshold_enabled: false
  86. #
  87. # For more information, consult the network module documentation.
  88. #
  89. # --------------------------------- Discovery ----------------------------------
  90. #
  91. # Pass an initial list of hosts to perform discovery when this node is started:
  92. # The default list of hosts is ["127.0.0.1", "[::1]"]
  93. #
  94. #es7.x 之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点
  95. discovery.seed_hosts: ["10.10.164.1:9300", "10.10.164.2:9300","10.10.164.3:9300"]
  96. #
  97. # Bootstrap the cluster using an initial set of master-eligible nodes:
  98. #
  99. #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
  100. cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
  101. #
  102. # For more information, consult the discovery and cluster formation module documentation.
  103. #
  104. # ---------------------------------- Various -----------------------------------
  105. #
  106. # Require explicit names when deleting indices:
  107. #
  108. #action.destructive_requires_name: true

节点node-3配置

  1. # ======================== Elasticsearch Configuration =========================
  2. #
  3. # NOTE: Elasticsearch comes with reasonable defaults for most settings.
  4. # Before you set out to tweak and tune the configuration, make sure you
  5. # understand what are you trying to accomplish and the consequences.
  6. #
  7. # The primary way of configuring a node is via this file. This template lists
  8. # the most important settings you may want to configure for a production cluster.
  9. #
  10. # Please consult the documentation for further information on configuration options:
  11. # https://www.elastic.co/guide/en/elasticsearch/reference/index.html
  12. #
  13. # ---------------------------------- Cluster -----------------------------------
  14. #
  15. # Use a descriptive name for your cluster:
  16. #
  17. #配置es的集群名称,同一个集群中的多个节点使用相同的标识
  18. #如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。
  19. cluster.name: my-cluster
  20. #
  21. # ------------------------------------ Node ------------------------------------
  22. #
  23. # Use a descriptive name for the node:
  24. #
  25. #节点名称
  26. node.name: node-3
  27. #是不是有资格竞选主节点
  28. node.master: true
  29. #
  30. # Add custom attributes to the node:
  31. #
  32. #node.attr.rack: r1
  33. #
  34. # ----------------------------------- Paths ------------------------------------
  35. #
  36. # Path to directory where to store the data (separate multiple locations by comma):
  37. #
  38. #数据存储路径
  39. path.data: /opt/es/data
  40. #
  41. # Path to log files:
  42. #
  43. #日志存储路径
  44. path.logs: /opt/es/logs
  45. #
  46. # ----------------------------------- Memory -----------------------------------
  47. #
  48. # Lock the memory on startup:
  49. #
  50. #ES默认开启了内存地址锁定,为了避免内存交换提高性能。但是Centos6不支持SecComp功能,启动会报错,所以需要将其设置为false
  51. #bootstrap.memory_lock: true
  52. #
  53. # Make sure that the heap size is set to about half the memory available
  54. # on the system and that the owner of the process is allowed to use this
  55. # limit.
  56. #
  57. # Elasticsearch performs poorly when the system is swapping the memory.
  58. #
  59. # ---------------------------------- Network -----------------------------------
  60. #
  61. # By default Elasticsearch is only accessible on localhost. Set a different
  62. # address here to expose this node on the network:
  63. #
  64. #节点所绑定的IP地址,并且该节点会被通知到集群中的其他节点
  65. #通过指定相同网段的其他节点会加入该集群中 0.0.0.0任意IP都可以访问elasticsearch
  66. network.host: 10.10.164.3
  67. bootstrap.system_call_filter: false
  68. #
  69. # By default Elasticsearch listens for HTTP traffic on the first free port it
  70. # finds starting at 9200. Set a specific HTTP port here:
  71. #
  72. #作为数据节点
  73. node.data: true
  74. #对外提供服务的http端口,默认为9200
  75. http.port: 9200
  76. # 是否支持跨域
  77. http.cors.enabled: true
  78. # *表示支持所有域名
  79. http.cors.allow-origin: "*"
  80. #内部节点之间沟通端口
  81. transport.tcp.port: 9300
  82. #设置是否压缩TCP传输时的数据,默认为false
  83. transport.tcp.compress: true
  84. #network.publish_host:10.10.164.3
  85. cluster.routing.allocation.disk.threshold_enabled: false
  86. #
  87. # For more information, consult the network module documentation.
  88. #
  89. # --------------------------------- Discovery ----------------------------------
  90. #
  91. # Pass an initial list of hosts to perform discovery when this node is started:
  92. # The default list of hosts is ["127.0.0.1", "[::1]"]
  93. #
  94. #es7.x 之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点
  95. discovery.seed_hosts: ["10.10.164.1:9300", "10.10.164.2:9300","10.10.164.3:9300"]
  96. #
  97. # Bootstrap the cluster using an initial set of master-eligible nodes:
  98. #
  99. #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
  100. cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
  101. #
  102. # For more information, consult the discovery and cluster formation module documentation.
  103. #
  104. # ---------------------------------- Various -----------------------------------
  105. #
  106. # Require explicit names when deleting indices:
  107. #
  108. #action.destructive_requires_name: true

启动用户与赋权

  1. groupadd elsearch
  2. useradd elsearch -g elsearch -p elasticsearch #useradd [user name] -g [group name] -p [password]
  3. chown -R elsearch:elsearch elasticsearch #chown -R [user name:group name] 该用户所分配有权限的目录
  4. su elsearch #切换账户
  5. cd elasticsearch/bin #进入你的elasticsearch目录下的bin目录
  6. ./elasticsearch
  7. ElasticSearch后台启动命令
  8. ./elasticsearch -d
  9. 查看后台命令是否启动成功
  10. ps aux|grep elasticsearch

同启动1节点一致,分别再次启动 2节点、3节点

查看集群状态

查看集群节点

http://IP:9200/_cat/nodes?v

20210406131823306.png

查看集群状态

http://IP:9201/_cluster/stats?pretty

2021040613140890.png

安装遇到的问题

https://blog.csdn.net/qq_39313596/article/details/107513482?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522161768618216780255218764%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=161768618216780255218764&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-1-107513482.first_rank_v2_pc_rank_v29&utm_term=es+hlvy

JVM设置官网

https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html

发表评论

表情:
评论列表 (有 0 条评论,314人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ES管理

    转载自 [ES集群管理][ES] 8 集群管理 ES通常以集群方式工作,这样做不仅能够提高 ES的搜索能力还可以处理大数据搜索的能力,同时也增加了系统的容错能力及高可用

    相关 ES配置

    ES集群步骤: 1,需要几个ES节点,安装几个ES服务,同一台机器设置对外暴露的Http端口和ES交互的TCP端口需要不一致 2,每个ES服务如下增加ES配置,有中文说明,

    相关 ES管理

    ES通常以集群方式工作,这样做不仅能够提高 ES的搜索能力还可以处理大数据搜索的能力,同时也增加了系统的 容错能力及高可用,ES可以实现PB级数据的搜索 集群的结构图如下