[关闭]
@zhangyy 2021-01-28T16:37:40.000000Z 字数 5357 阅读 144

ElasticSearch 分布式集群架构的特性

ElasticSearch系列



一:ElasticSearch 分布式集群架构的特性

1.1 ES集群:

image_1et1kbips97pfh1hdp1kjkn1s9.png-314.1kB

image_1et1kdi3ubivr36114m6i614kdm.png-272kB

image_1et1kh6skpusib2s5emb2kor13.png-374.1kB

image_1et1kmucg8u01i8r651omd1pjf1g.png-247.1kB

image_1et1kp3rr174u1da6ucn9fvd61t.png-226kB

image_1et1krrk111a2u4fkk93g9154j2a.png-337.3kB

image_1et1l4q9n1ipah61126j13sjjpr2n.png-192.6kB

image_1et1l5cr312afcg1l8ds7jd8734.png-237.3kB

image_1et1lb8vj1p1p1u07hp1jlr1tnm3h.png-222.2kB

image_1et1lcmlsk5s123r18rt1mdf1lkp3u.png-233.9kB

  1. ES的分片

image_1et1lishd1hmn10nq1mgv17e71dvh4b.png-264.1kB

image_1et1lvfe01ttabl31o1c1bha13to4o.png-322.8kB

image_1et1m6n7l4ethfa2rmgvg1l2755.png-271.7kB

  1. ES 的路由

image_1et1mbjkecq71bfe96d3fg19pv5v.png-152.5kB

image_1et1majj658qs6chbmets9f45i.png-238.1kB

image_1et1mdot01tc9o5v3sving1lrb6c.png-419.5kB

image_1et1mglfj1njthbs3u1fa2nju6p.png-318.4kB

image_1et1mj1nn1tsr5a01pcuah91m9n76.png-411.4kB

  1. ES 怎么存放文档

image_1et1msj0l15101k11177d1es6olv7j.png-378.2kB

  1. ES 怎么搜索文档

image_1et3qv1e41i07nh7leaclj1kk39.png-927.3kB

image_1et3r6lomj361s4vee41b3aputm.png-999kB


二:ES的伪集群部署

2.1 安装单机的ES集群

  1. mkdir -p /esdb
  2. mkdir -p /esdb/soft
  3. 将所有的软件传到/esdb/soft 软件下面
  4. chown esadmin:esadmin -R /esdb/

image_1et3s3k3uqlv7ah1n1b1ann10p113.png-96.4kB

  1. 配置jdk
  2. su - esadmin
  3. cd /esdb/
  4. tar zxvf soft/jdk-14.0.2_linux-x64_bin.tar.gz
  5. export LANG=en_US.UTF8
  6. cat >> ~/.bash_profile << EOF
  7. export JAVA_HOME=/esdb/jdk-14.0.2
  8. export PATH=/esdb/jdk-14.0.2/bin:$PATH
  9. export LANG=en_US.UTF8
  10. EOF
  11. source ~/.bash_profile
  12. java -version

image_1et3s7so845t50f1f8c1jopj9e1g.png-153.3kB


  1. mkdir -p /esdb/esapp/esapp9201
  2. mkdir -p /esdb/esapp/esapp9202
  3. mkdir -p /esdb/esapp/esapp9203
  4. mkdir -p /esdb/esdata/esdata9201
  5. mkdir -p /esdb/esdata/esdata9202
  6. mkdir -p /esdb/esdata/esdata9203
  7. mkdir -p /esdb/eslog/eslog9201
  8. mkdir -p /esdb/eslog/eslog9202
  9. mkdir -p /esdb/eslog/eslog9203

image_1et3sabgg1ehi401md7ukn3sc1t.png-142.8kB


  1. cd /esdb/soft
  2. tar -zxvf /esdb/soft/elasticsearch-7.9.0-linux-x86_64.tar.gz
  3. cp -ap /esdb/soft/elasticsearch-7.9.0/* /esdb/esapp/esapp9201/
  4. cp -ap /esdb/soft/elasticsearch-7.9.0/* /esdb/esapp/esapp9202/
  5. cp -ap /esdb/soft/elasticsearch-7.9.0/* /esdb/esapp/esapp9203/

image_1et3sgu6d1h6ml9lk7d1aq66652a.png-137.5kB


  1. vim /esdb/esapp/esapp9201/config/elasticsearch.yml
  2. ----
  3. cluster.name: flyfishescluster1
  4. node.name: flyfish01-node-1
  5. path.data: /esdb/esdata/esdata9201
  6. path.logs: /esdb/eslog/eslog9201
  7. node.master: true
  8. node.data: true
  9. cluster.remote.connect: false
  10. bootstrap.memory_lock: true
  11. bootstrap.system_call_filter: false
  12. network.host: 192.168.100.31
  13. http.port: 9201
  14. transport.tcp.port: 9301
  15. http.cors.enabled: true
  16. http.cors.allow-origin: "*"
  17. discovery.seed_hosts: ["192.168.100.31:9301","192.168.100.31:9302","192.168.100.31:9303"]
  18. discovery.zen.fd.ping_timeout: 60s
  19. discovery.zen.fd.ping_retries: 5
  20. cluster.initial_master_nodes: ["flyfish01-node-1","flyfish01-node-2","flyfish01-node-3"]
  21. ----

  1. vim /esdb/esapp/esapp9202/config/elasticsearch.yml
  2. ----
  3. cluster.name: flyfishescluster1
  4. node.name: flyfish01-node-2
  5. path.data: /esdb/esdata/esdata9202
  6. path.logs: /esdb/eslog/eslog9202
  7. node.master: true
  8. node.data: true
  9. cluster.remote.connect: false
  10. bootstrap.memory_lock: true
  11. bootstrap.system_call_filter: false
  12. network.host: 192.168.100.31
  13. http.port: 9202
  14. transport.tcp.port: 9302
  15. http.cors.enabled: true
  16. http.cors.allow-origin: "*"
  17. discovery.seed_hosts: ["192.168.100.31:9301", "192.168.100.31:9302", "192.168.100.31:9303"]
  18. discovery.zen.fd.ping_timeout: 60s
  19. discovery.zen.fd.ping_retries: 5
  20. cluster.initial_master_nodes: ["flyfish01-node-1", "flyfish01-node-2",
  21. "flyfish01-node-3"]
  22. -----

  1. vim /esdb/esapp/esapp9203/config/elasticsearch.yml
  2. -----
  3. cluster.name: flyfishescluster1
  4. node.name: flyfish01-node-3
  5. path.data: /esdb/esdata/esdata9203
  6. path.logs: /esdb/eslog/eslog9203
  7. node.master: true
  8. node.data: true
  9. cluster.remote.connect: false
  10. bootstrap.memory_lock: true
  11. bootstrap.system_call_filter: false
  12. network.host: 192.168.100.31
  13. http.port: 9203
  14. transport.tcp.port: 9303
  15. http.cors.enabled: true
  16. http.cors.allow-origin: "*"
  17. discovery.seed_hosts: ["192.168.100.31:9300","192.168.100.31:9301","192.168.100.31:9302"]
  18. discovery.zen.fd.ping_timeout: 60s
  19. discovery.zen.fd.ping_retries: 5
  20. cluster.initial_master_nodes: ["flyfish01-node-1", "flyfish01-node-2",
  21. "flyfish01-node-3"]
  22. -----

  1. vim /esdb/esapp/esapp9201/bin/elasticsearch-env
  2. vim /esdb/esapp/esapp9202/bin/elasticsearch-env
  3. vim /esdb/esapp/esapp9203/bin/elasticsearch-env
  4. 都加上:
  5. ----
  6. export JAVA_HOME=/esdb/jdk-14.0.2
  7. export PATH=$JAVA_HOME/bin:$PATH
  8. ----

  1. vim /esdb/esapp/esapp9201/config/jvm.options
  2. ----
  3. -Xms512m
  4. -Xmx512m
  5. -Xmn256km
  6. -Xss228K
  7. -XX:+DisableExplicitGC
  8. -XX:HeapDumpPath=/esdb/eslog/eslog9201
  9. -XX:ErrorFile=/esdb/eslog/eslog9201/hs_err_pid%p.log
  10. 9-:-Xlog:gc*,gc+age=trace,safepoint:file=/esdb/eslog/eslog9201/gc.log:utctime,pid,tags:filecount=32,filesize=64m
  11. ----
  12. vim /esdb/esapp/esapp9202/config/jvm.options
  13. ----
  14. -Xms512m
  15. -Xmx512m
  16. -Xmn256km
  17. -Xss228K
  18. -XX:+DisableExplicitGC
  19. -XX:HeapDumpPath=/esdb/eslog/eslog9202
  20. -XX:ErrorFile=/esdb/eslog/eslog9202/hs_err_pid%p.log
  21. 9-:-Xlog:gc*,gc+age=trace,safepoint:file=/esdb/eslog/eslog9202/gc.log:utctime,pid,tags:filecount=32,filesize=64m
  22. ----
  23. vim /esdb/esapp/esapp9203/config/jvm.options
  24. -----
  25. -Xms512m
  26. -Xmx512m
  27. -Xmn256km
  28. -Xss228K
  29. -XX:+DisableExplicitGC
  30. -XX:HeapDumpPath=/esdb/eslog/eslog9203
  31. -XX:ErrorFile=/esdb/eslog/eslog9203/hs_err_pid%p.log
  32. 9-:-Xlog:gc*,gc+age=trace,safepoint:file=/esdb/eslog/eslog9203/gc.log:utctime,pid,tags:filecount=32,filesize=64m
  33. ----

  1. 启动:
  2. /esdb/esapp/esapp9201/bin/elasticsearch
  3. /esdb/esapp/esapp9202/bin/elasticsearch
  4. /esdb/esapp/esapp9203/bin/elasticsearch
  5. 测试:
  6. curl http://192.168.100.31:9201/_cat/nodes
  7. curl http://192.168.100.31:9202/_cat/nodes
  8. curl http://192.168.100.31:9203/_cat/nodes

image_1et3ui3qdvcqoq81gfb1tln12382n.png-354.5kB

image_1et3uj850141rls2jc99av7h734.png-126.5kB

image_1et3ukl2hc9218eujn8111nde53h.png-129.8kB

image_1et3ulr851u4pdokbk1vlu1hjp3u.png-128.8kB

image_1et3umomg13q51o0arh3q8q1af64b.png-172kB


  1. 后台启动:
  2. nohup /esdb/esapp/esapp9201/bin/elasticsearch > /esdb/eslog/eslog9201/esapp9201.nohup &
  3. nohup /esdb/esapp/esapp9202/bin/elasticsearch > /esdb/eslog/eslog9202/esapp9202.nohup &
  4. nohup /esdb/esapp/esapp9203/bin/elasticsearch > /esdb/eslog/eslog9203/esapp9203.nohup &

image_1et3v59v2umn1nnr14t41j1t1nq14o.png-164.8kB


  1. 查看集群的状态:
  2. curl http://192.168.100.31:9203/_cat/health?pretty -H 'Content-Type: application/json'

image_1et3vau9d1vkn6ik13h31b271ng95l.png-213.2kB


  1. 插入数据
  2. curl -XPOST http://192.168.100.31:9201/itpuxdb/_doc/?pretty -H 'Content-Type:application/json' -d '
  3. {
  4. "id" : "1",
  5. "name" : "itpux001",
  6. "city" : "深圳",
  7. "course" : "oracle",
  8. "teacher" : "风哥",
  9. "pxdate": "20200829"
  10. }'

image_1et40rse8uj21hvr1tvicresbr62.png-146.2kB

  1. curl -XPOST http://192.168.100.31:9201/itpuxdb/_doc/?pretty -H 'Content-Type:application/json' -d '
  2. {
  3. "id" : "1",
  4. "name" : "itpux001",
  5. "city" : "上海",
  6. "course" : "bigdata",
  7. "teacher" : "flyfish",
  8. "pxdate": "20200829"
  9. }'

image_1et40sllfp6l1hi4ar31r8m1rr26f.png-141.1kB

  1. 查找:
  2. curl -XPOST 'http://192.168.100.31:9201/itpuxdb/_search?pretty' -H 'Content-Type:application/json'
  3. curl -XPOST 'http://192.168.100.31:9202/itpuxdb/_search?pretty' -H 'Content-Type:application/json'
  4. curl -XPOST 'http://192.168.100.31:9203/itpuxdb/_search?pretty' -H 'Content-Type:application/json'

image_1et40u1sgm8u10391ut113nf2fc6s.png-159.6kB

image_1et40v37jgmfuvepl4mnu1ab07p.png-65.4kB

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注