1. 程式人生 > 其它 >ES 內熱節點部署三

ES 內熱節點部署三

目錄

▪ 用途 ▪ 架構 ▪ 192.168.1.51 elasticsearch-data部署雙例項 ▪ 192.168.1.52 elasticsearch-data部署雙例項 ▪ 192.168.1.53 elasticsearch-data部署雙例項 ▪ 測試


用途

前情提要:

▷ 在第一篇《EFK教程 - 快速入門指南》中,闡述了EFK的安裝部署,其中ES的架構為三節點,即master、ingest、data角色同時部署在三臺伺服器上。 ▷ 在第二篇《EFK教程 - ElasticSearch高效能高可用架構》中,闡述了EFK的data/ingest/master角色的用途及分別部署三節點,在實現效能最大化的同時保障高可用

前兩篇文章,ES叢集中只存在一個例項,而在本文中,將在一個叢集中部署多個ES例項,來實現資源合理分配。例如data伺服器存在SSD與SAS硬碟,可以將熱資料存放到SSD,而冷資料存放到SAS,實現資料冷熱分離。

在本文中,將為data伺服器建立2個例項,分別基於SSD和基於SAS硬碟,將nginx的9月份索引放在SAS盤上,其它的全放在SSD盤上


架構

架構圖

伺服器配置


192.168.1.51 elasticsearch-data部署雙例項

索引遷移(此步不能忽略):將192.168.1.51上的索引放到其它2臺data節點上

  1. curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'

  2. {

  3. "index.routing.allocation.include._ip": "192.168.1.52,192.168.1.53"

  4. }'

確認當前索引儲存位置:確認所有索引不在192.168.1.51節點上

  1. curl "http://192.168.1.31:9200/_cat/shards?h=n"

停掉192.168.1.51的程序,修改目錄結構及配置:請自行按SSD和SAS硬碟掛載好資料盤

  1. # 安裝包下載和部署請參考第一篇《EFK教程 - 快速入門指南》

  2. cd /opt/software/

  3. tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz

  4. mv /opt/elasticsearch /opt/elasticsearch-SAS

  5. mv elasticsearch-7.3.2 /opt/

  6. mv /opt/elasticsearch-7.3.2 /opt/elasticsearch-SSD

  7. chown elasticsearch.elasticsearch /opt/elasticsearch-* -R

  8. rm -rf /data/SAS/*

  9. chown elasticsearch.elasticsearch /data/* -R

  10. mkdir -p /opt/logs/elasticsearch-SAS

  11. mkdir -p /opt/logs/elasticsearch-SSD

  12. chown elasticsearch.elasticsearch /opt/logs/* -R

SAS例項/opt/elasticsearch-SAS/config/elasticsearch.yml配置

  1. cluster.name: my-application

  2. node.name: 192.168.1.51-SAS

  3. path.data: /data/SAS

  4. path.logs: /opt/logs/elasticsearch-SAS

  5. network.host: 192.168.1.51

  6. http.port: 9200

  7. transport.port: 9300

  8. # discovery.seed_hosts和cluster.initial_master_nodes 一定要帶上埠號,不然會走http.port和transport.port埠

  9. discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  10. cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  11. http.cors.enabled: true

  12. http.cors.allow-origin: "*"

  13. node.master: false

  14. node.ingest: false

  15. node.data: true

  16. # 本機只允行啟2個例項

  17. node.max_local_storage_nodes: 2

SSD例項/opt/elasticsearch-SSD/config/elasticsearch.yml配置

  1. cluster.name: my-application

  2. node.name: 192.168.1.51-SSD

  3. path.data: /data/SSD

  4. path.logs: /opt/logs/elasticsearch-SSD

  5. network.host: 192.168.1.51

  6. http.port: 9201

  7. transport.port: 9301

  8. # discovery.seed_hosts和cluster.initial_master_nodes 一定要帶上埠號,不然會走http.port和transport.port埠

  9. discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  10. cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  11. http.cors.enabled: true

  12. http.cors.allow-origin: "*"

  13. node.master: false

  14. node.ingest: false

  15. node.data: true

  16. # 本機只允行啟2個例項

  17. node.max_local_storage_nodes: 2

SAS例項和SSD例項啟動方式

  1. sudo -u elasticsearch /opt/elasticsearch-SAS/bin/elasticsearch

  2. sudo -u elasticsearch /opt/elasticsearch-SSD/bin/elasticsearch

確認SAS和SSD已啟2例項

  1. curl "http://192.168.1.31:9200/_cat/nodes?v"


192.168.1.52 elasticsearch-data部署雙例項

索引遷移(此步不能忽略):將192.168.1.52上的索引放到其它2臺data節點上

  1. curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'

  2. {

  3. "index.routing.allocation.include._ip": "192.168.1.51,192.168.1.53"

  4. }'

確認當前索引儲存位置:確認所有索引不在192.168.1.52節點上

  1. curl "http://192.168.1.31:9200/_cat/shards?h=n"

停掉192.168.1.52的程序,修改目錄結構及配置:請自行按SSD和SAS硬碟掛載好資料盤

  1. # 安裝包下載和部署請參考第一篇《EFK教程 - 快速入門指南》

  2. cd /opt/software/

  3. tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz

  4. mv /opt/elasticsearch /opt/elasticsearch-SAS

  5. mv elasticsearch-7.3.2 /opt/

  6. mv /opt/elasticsearch-7.3.2 /opt/elasticsearch-SSD

  7. chown elasticsearch.elasticsearch /opt/elasticsearch-* -R

  8. rm -rf /data/SAS/*

  9. chown elasticsearch.elasticsearch /data/* -R

  10. mkdir -p /opt/logs/elasticsearch-SAS

  11. mkdir -p /opt/logs/elasticsearch-SSD

  12. chown elasticsearch.elasticsearch /opt/logs/* -R

SAS例項/opt/elasticsearch-SAS/config/elasticsearch.yml配置

  1. cluster.name: my-application

  2. node.name: 192.168.1.52-SAS

  3. path.data: /data/SAS

  4. path.logs: /opt/logs/elasticsearch-SAS

  5. network.host: 192.168.1.52

  6. http.port: 9200

  7. transport.port: 9300

  8. # discovery.seed_hosts和cluster.initial_master_nodes 一定要帶上埠號,不然會走http.port和transport.port埠

  9. discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  10. cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  11. http.cors.enabled: true

  12. http.cors.allow-origin: "*"

  13. node.master: false

  14. node.ingest: false

  15. node.data: true

  16. # 本機只允行啟2個例項

  17. node.max_local_storage_nodes: 2

SSD例項/opt/elasticsearch-SSD/config/elasticsearch.yml配置

  1. cluster.name: my-application

  2. node.name: 192.168.1.52-SSD

  3. path.data: /data/SSD

  4. path.logs: /opt/logs/elasticsearch-SSD

  5. network.host: 192.168.1.52

  6. http.port: 9201

  7. transport.port: 9301

  8. # discovery.seed_hosts和cluster.initial_master_nodes 一定要帶上埠號,不然會走http.port和transport.port埠

  9. discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  10. cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  11. http.cors.enabled: true

  12. http.cors.allow-origin: "*"

  13. node.master: false

  14. node.ingest: false

  15. node.data: true

  16. # 本機只允行啟2個例項

  17. node.max_local_storage_nodes: 2

SAS例項和SSD例項啟動方式

  1. sudo -u elasticsearch /opt/elasticsearch-SAS/bin/elasticsearch

  2. sudo -u elasticsearch /opt/elasticsearch-SSD/bin/elasticsearch

確認SAS和SSD已啟2例項

  1. curl "http://192.168.1.31:9200/_cat/nodes?v"


192.168.1.53 elasticsearch-data部署雙例項

索引遷移(此步不能忽略):一定要做這步,將192.168.1.53上的索引放到其它2臺data節點上

  1. curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'

  2. {

  3. "index.routing.allocation.include._ip": "192.168.1.51,192.168.1.52"

  4. }'

確認當前索引儲存位置:確認所有索引不在192.168.1.52節點上

  1. curl "http://192.168.1.31:9200/_cat/shards?h=n"

停掉192.168.1.53的程序,修改目錄結構及配置:請自行按SSD和SAS硬碟掛載好資料盤

  1. # 安裝包下載和部署請參考第一篇《EFK教程 - 快速入門指南》

  2. cd /opt/software/

  3. tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz

  4. mv /opt/elasticsearch /opt/elasticsearch-SAS

  5. mv elasticsearch-7.3.2 /opt/

  6. mv /opt/elasticsearch-7.3.2 /opt/elasticsearch-SSD

  7. chown elasticsearch.elasticsearch /opt/elasticsearch-* -R

  8. rm -rf /data/SAS/*

  9. chown elasticsearch.elasticsearch /data/* -R

  10. mkdir -p /opt/logs/elasticsearch-SAS

  11. mkdir -p /opt/logs/elasticsearch-SSD

  12. chown elasticsearch.elasticsearch /opt/logs/* -R

SAS例項/opt/elasticsearch-SAS/config/elasticsearch.yml配置

  1. cluster.name: my-application

  2. node.name: 192.168.1.53-SAS

  3. path.data: /data/SAS

  4. path.logs: /opt/logs/elasticsearch-SAS

  5. network.host: 192.168.1.53

  6. http.port: 9200

  7. transport.port: 9300

  8. # discovery.seed_hosts和cluster.initial_master_nodes 一定要帶上埠號,不然會走http.port和transport.port埠

  9. discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  10. cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  11. http.cors.enabled: true

  12. http.cors.allow-origin: "*"

  13. node.master: false

  14. node.ingest: false

  15. node.data: true

  16. # 本機只允行啟2個例項

  17. node.max_local_storage_nodes: 2

SSD例項/opt/elasticsearch-SSD/config/elasticsearch.yml配置

  1. cluster.name: my-application

  2. node.name: 192.168.1.53-SSD

  3. path.data: /data/SSD

  4. path.logs: /opt/logs/elasticsearch-SSD

  5. network.host: 192.168.1.53

  6. http.port: 9201

  7. transport.port: 9301

  8. # discovery.seed_hosts和cluster.initial_master_nodes 一定要帶上埠號,不然會走http.port和transport.port埠

  9. discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  10. cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]

  11. http.cors.enabled: true

  12. http.cors.allow-origin: "*"

  13. node.master: false

  14. node.ingest: false

  15. node.data: true

  16. # 本機只允行啟2個例項

  17. node.max_local_storage_nodes: 2

SAS例項和SSD例項啟動方式

  1. sudo -u elasticsearch /opt/elasticsearch-SAS/bin/elasticsearch

  2. sudo -u elasticsearch /opt/elasticsearch-SSD/bin/elasticsearch

確認SAS和SSD已啟2例項

  1. curl "http://192.168.1.31:9200/_cat/nodes?v"


測試

將所有索引移到SSD硬碟上

  1. # 下面的引數會在後面的文章講解,此處照抄即可

  2. curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'

  3. {

  4. "index.routing.allocation.include._host_ip": "",

  5. "index.routing.allocation.include._host": "",

  6. "index.routing.allocation.include._name": "",

  7. "index.routing.allocation.include._ip": "",

  8. "index.routing.allocation.require._name": "*-SSD"

  9. }'

確認所有索引全在SSD硬碟上

  1. curl "http://192.168.1.31:9200/_cat/shards?h=n"

將nginx9月份的日誌索引遷移到SAS硬碟上

  1. curl -X PUT "192.168.1.31:9200/nginx_*_2019.09/_settings?pretty" -H 'Content-Type: application/json' -d'

  2. {

  3. "index.routing.allocation.require._name": "*-SAS"

  4. }'

確認nginx9月份的日誌索引遷移到SAS硬碟上

  1. curl "http://192.168.1.31:9200/_cat/shards"

轉載自小漫哥公眾號

螃蟹在剝我的殼,筆記本在寫我,漫天的我落在楓葉上雪花上,而你在想我。 --章懷柔