Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elasticsearchに入門してチューニングや監視をした話 #elasticsearchj...

Elasticsearchに入門してチューニングや監視をした話 #elasticsearchjp /elasticsearch-fukuoka-2017

Elasticsearch勉強会 in 福岡 2017の発表資料です

Manabu Matsuzaki

October 06, 2017
Tweet

More Decks by Manabu Matsuzaki

Other Decks in Technology

Transcript

  1. ެࣜplaybook಺ͷॏཁͦ͏ͳม਺ es_version es_instance_name es_heap_size es_config.cluster.name es_config.node.name → "${HOSTNAME}" ͕ྑ͍ es_config.discovery.zen.ping.unicast.hosts

    es_config.node.master es_config.node.data es_config.bootstrap.memory_lock → true ͕ྑ͍ es_config.network.host → 0.0.0.0 es_jvm_custom_parameters → ௥Ճ͍ͨ͠JVM OptionΛࢦఆ es_plugins → analysis-icu΍analysis-kuromojiͳͲΛࢦఆՄೳ es_enable_xpack → X-PackΛ࢖͏৔߹͸true es_xpack_features → monitoringͳͲΛΠϯετʔϧՄೳ https://github.com/elastic/ansible-elasticsearch/blob/master/README.md
  2. ࢖༻͍ͯ͠Δόʔδϣϯ • CentOS 7.3
 (ެࣜͷAnsible playbook͸CentOS 6Λαϙʔτ͍ͯ͠ͳ͍) • Oracle JDK

    1.8.0 • Elastic stack 5.5.1 • Elasticsearch • Kibana
 (X-Pack MonitoringͷμογϡϘʔυΛݟΔͨΊʹಋೖ) • X-Pack Monitoring ※Slideͷ࠷ޙʹัଊ͋Γ
 (ӡ༻ʹ໾ཱͭ৘ใ͕͋Δ͔ݟͯΈ͔ͨͬͨͷͰಋೖ) • Cerebro 0.6.6
  3. • Cacheؔ࿈ • indices.fielddata.cache.size • indices.queries.cache.size • indices.requests.cache.size • Thread

    poolؔ࿈ ※Slideͷ࠷ޙʹัଊ͋Γ • thread_pool.index.queue_size • thread_pool.bulk.queue_size elasticsearch.ymlͰߦ͏Ϋϥελશମͷઃఆ ʢಈతʹมߋͰ͖ͳ͍ʣ
  4. • Circuit Breakerؔ࿈ • indices.breaker.total.limit • indices.breaker.fielddata.limit • indices.breaker.request.limit •

    Segments and Mergingؔ࿈ ※Slideͷ࠷ޙʹัଊ͋Γ • indices.store.throttle.max_bytes_per_sec
 σϑΥϧτ஋͸HDD޲͚ʹͳ͍ͬͯΔͷͰɺ
 SSDΛ࢖͏৔߹͸มߋ͢ΔΑ͏ʹDefinitive Guideʹॻ͍ͯ͋Δ APIͰߦ͏Ϋϥελશମͷઃఆ
 ʢಈతʹมߋͰ͖Δʣ
  5. • number_of_shards • number_of_replicas
 bulk indexingத͸0ʹઃఆɻऴΘͬͨΒ໭͢ • _allΛແޮԽ • dynamic:

    strict • index.indexing.slowlogؔ࿈ • index.search.slowlogؔ࿈ APIͰߦ͏index/index templateຖͷઃఆ ʢಈతʹมߋͰ͖Δʣ
  6. • Transport ClientͰbulkॲཧ͢Δ৔߹͸ɺ
 BulkProcessorΛ࢖͏ͱྑ͍ɻҎԼͷύϥϝʔλ͕ઃఆՄೳ • bulkActions • bulkSize • flushInterval

    • concurrentRequests • backoffPolicy https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-bulk-processor.html Transport Client
  7. ϞχλϦϯά • ࢖͍ͬͯΔPrometheus exporter • node_exporter • jmx_exporter • elasticsearch_exporter

    • άάΔͱ͍͔ͭ͘ݟ͔ͭΔ͕ɺݱࡏ࢖͍ͬͯΔͷ͸͜Ε
 https://github.com/justwatchcom/elasticsearch_exporter • authorͱcontributorୡ͕ඞཁͳϝτϦΫε͔͠export͞Εͯ ͍ͳ͍ͷͰɺࣗ෼͕ඞཁͳϝτϦΫε͕ແ͚Ε͹PR͠Α͏
  8. • Load Avg • CPU࢖༻཰ • Disk I/O • network

    trafic node_exporterͰऩूͰ͖Δ OSʹؔ͢ΔϝτϦΫεͷҰྫ
  9. • cluster health • Document count(primary shardͷΈ) • Document size(primary

    shardͷΈ) • Thread pool queue count • Thread pool rejected count • Circuit Breaker tripped count elasticsearch_exporterͰऩूͰ͖Δ Elasticsearchʹؔ͢ΔϝτϦΫεͷҰྫ
  10. • Fielddata cache size • Query cache size • Query

    cache ώοτ཰ (hit / total) • Request cache size elasticsearch_exporterͰऩूͰ͖Δ Elasticsearchʹؔ͢ΔϝτϦΫεͷҰྫ
  11. • ϦΫΤετճ਺ • ྫ֎ൃੜճ਺ • Search latency percentile (0.5, 0.75,

    0.98, 0.99, 0.999) prometheus_clientΛαʔόαΠυΞϓϦʹ૊ΈࠐΜͰ DropWizard MetricsͰऩू͍ͯ͠ΔϝτϦΫε
  12. • Slow logൃੜճ਺ • NorikraͰूܭ • Raw slow log •

    Elasticsearchʹอଘ • Elasticsearchʹอଘͨ͠σʔλ͸KibanaͰݟΔͷ͕Ұൠత ͩͱࢥ͏͕ɺ࢖͍׳Ε͍ͯΔGrafanaͰҰ୴ݟΔࣄʹͨ͠ slow logΛFluentdͰऩू
  13. • ެࣜυΩϡϝϯτΛಡ΋͏ • ެࣜAnsible playbook͓͢͢Ί • ύϥϝʔλͷઃఆมߋ͸ɺAPIͰಈతʹग़དྷΔ΋ͷͱग़དྷͳ͍ ΋ͷ͕͋Δ • elasticsearch_exporter͚ͩͰ͸ऩूͰ͖ͳ͍ϝτϦΫε͸ผͷ

    ํ๏Ͱɻ • αʔόαΠυΞϓϦʹDropWizard MetricsΛ૊ΈࠐΜͰܭଌ • slow logΛऩूͯ͠NorikraͰूܭ • Raw slow log͸ผͷElasticsearchʹอଘ
  14. ิ଍ • X-Pack MonitoringΛΠϯετʔϧ͢ΔͱɺϝτϦΫεσʔλ Λอଘ͢Δઐ༻ͷΠϯσοΫε͕ग़དྷΔɻΠϯσοΫεͷอ ଘઌ͸ผͷElasticsearchΫϥελʹ͠·͠ΐ͏ • Thread poolؔ࿈ͷύϥϝʔλνϡʔχϯάɺqueue_size͚ͩ ૿΍ͯ͠΋ύϑΥʔϚϯε͸্͕ΒͣΩϡʔ଴͕ͪ૿͑Δ͚ͩ

    ͳͷͰɺsize΋߹Θͤͯνϡʔχϯά͠·͠ΐ͏
 https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-threadpool.html • indices.store.throttle.max_bytes_per_sec ͸Elasticsearch 6.0 Ͱഇࢭ͞Ε·͢
 https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_settings_changes.html