DZone
Integration Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Integration Zone > Increase Max Open Files in Elastic Search (OSX)

Increase Max Open Files in Elastic Search (OSX)

Jamie Craane provides insight into increasing the maximum open files within Elasticsearch.

Jamie Craane user avatar by
Jamie Craane
·
Mar. 15, 16 · Integration Zone · Tutorial
Like (2)
Save
Tweet
5.29K Views

Join the DZone community and get the full member experience.

Join For Free

Elastic Search, Logstash and Kibana (ELK) is an end-to-end stack which provides real-time analytics for almost any type of structured or unstructured data. 

When importing large amounts of data using Logstash to Elasticsearch (ES), the chances are that ES hit the limits of the maximum files it can open. This limit is seen as an error in the ES logs with the following description: (Too many open files)

To deal with this you can increase the maximum files ES (or any process) may open using the following steps:

1. First step: start ES with the following option: ./elasticsearch -Des.max-open-files. This will show the maximum number of files ES is allowed to open, for example: [2016-02-22 06:44:09,558][INFO ][bootstrap] max_open_files [10240]

2. Now execute the following commands to increase the maximum number of files a process may open:

sudo sysctl -w kern.maxfiles=32000 

sudo sysctl -w kern.maxfilesperproc=32000

3. Execute the following commands to set the file limit for the terminal process (this is the terminal window to launch ES in)

ulimit -Sn 32000

ulimit -Hn 32000

For ES 1.7:Start Elastic Search with the following command: ./elasticsearch -Des.max-open-files -XX:-MaxFDLimit=true

For ES 2.2 Execute the following commands:

export ES_JAVA_OPTS=-XX:-MaxFDLimit (this increases the maximum files the JVM is allowed to open by default, see JVM configuration for more information)

and then start ES with the following command: ./elasticsearch -Des.max-open-files (max_open_files should be 32000 now)

Heap Sizes

You may also need to increase the heap size of both Logstash and Elastic Search. 

To increase the heap of LogStash execute the following command before launching Logstash: export LS_HEAP_SIZE=2g

To increase the heap of Elastic Search execute the following command before launching ES: export ES_HEAP_SIZE=8g

When importing large files using Logstash, it may benefit to increase the number of workers to speed up the importing process. The default is 1. See the following example of the Elasticsearch output plugin in Logstash:

elasticsearch {
     action => "index"
     hosts => ["localhost"]
     index => "logstash-%{+YYYY.MM.dd}"
     workers => 4
     flush_size => 1000
}

Published at DZone with permission of Jamie Craane, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • An Overview of DTrace and strace
  • SRE: From Theory to Practice: What’s Difficult About Tech Debt?
  • Comparing Approaches to Durability in Low Latency Messaging Queues
  • How Do You Know If a Graph Database Solves the Problem?

Comments

Integration Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo