Elasticsearch是一种先进的,高性能的,可扩展的开源搜索引擎,提供全文搜索和实时分析的结构化和非结构化的数据。
它的特定是可以通过HTTP使用 RESTful API,很容易的融入现有的web架构。因此在高并发的情况下,采用nginx反向代理负载均衡到多台Elasticsearch 服务器上。
架构图:
这种架构的优点是:
下表比较Elasticsearch 、Elasticsearch + nginx F/OSS、Elasticsearch + NGINX Plus 的功能:
Elasticsearch client | nginx F/OSS | NGINX Plus | |
Horizontal scalability | Y | Y | Y |
Keepalive optimization | Y | Y | |
Centralized HTTP access logs | Y | Y | |
Queuing and concurrency control | Y | ||
Response caching | Y | Y | |
Failover of failed connections | Y | Y | Y |
Active monitoring of Elasticsearch nodes | Y (some clients) | Y | |
Advanced load balancing methods | Y | Y | |
Weighted load balancing | Y | Y | |
Dynamic reconfiguration | Y | ||
Status monitoring | Y | ||
General-purpose HTTP load balancing | Y | Y |
当使用NGINX Plus高可用性主动或被动配置负载均衡的Elasticsearch 服务器集群时,Elasticsearch 客户端通过nginx plus请求,而不是直接连接到Elasticsearch服务器,可以根据实际情况任意的扩展Elasticsearch服务器不用更新客户端。
部署NGINX Plus + Elasticsearch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | proxy_cache_path / var / cache / nginx / cache keys_zone = elasticsearch : 10m inactive = 60m ; upstream elasticsearch_servers { zone elasticsearch _servers 64K ; server 192.168.187.132 : 9200 ; server 192.168.187.133 : 9200 ; } match statusok { status 200 ; header Content – Type ~ “application/json” ; body ~ ‘”status” : 200’ ; } server { listen 9200 ; status_zone elasticsearch ; location / { proxy_pass http : //elasticsearch_servers; proxy_http _version 1.1 ; proxy_set_header Connection “” ; proxy_cache elasticsearch ; proxy_cache _valid 200 302 10m ; proxy_cache _valid 404 1m ; proxy_connect _timeout 5s ; proxy_read _timeout 10s ; health_check interval = 5s fails = 1 passes = 1 uri = / match = statusok ; } # redirect server error pages to the static page /50x.html error _page 500 502 503 504 / 50x.html ; location = / 50x.html { root / usr / share / nginx / html ; } access_log logs / es_access . log combined ; } server { listen 8080 ; root / usr / share / nginx / html ; location / { index status . html ; } location = / status { status ; } } |
负载均衡、对有效的请求缓存10分钟、主动的健康监测、状态收集。
Elasticsearch是一个强大而灵活的搜索引擎,与nginx完美构建成一个可扩展高性能高可用性架构。
文章转载来自:trustauth.cn
上一篇:MySQL管理工具MySQL Utilities — mysqluserclone (30)
下一篇:Received empty response from Zabbix Agent问题解决