2008-02-27-how-to-increase-total-file-descriptors-count-on-linux.md 1.35 KB
Newer Older
Danesh Manoharan's avatar
Danesh Manoharan committed
1
2
---
title: How to increase file descriptors max limit on Linux
3
author: Danesh Manoharan
Danesh Manoharan's avatar
Danesh Manoharan committed
4
5
6
7
8
9
10
date: 2008-02-27T11:55:32+00:00
pvc_views:
  - 67569
dsq_thread_id:
  - 889806578

---
11
Today my DBA reported that the server she was working on was spitting out "too many open files" errors and no new processes could be started.
Danesh Manoharan's avatar
Danesh Manoharan committed
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
43

This is a common problem with DB servers with heavy transactions. In my environment there are 6 DB instances running on the server. No quite the optimized setup I would say.

The fix was to increase the total file descriptors kernel parameter count in the /etc/sysctl.conf file. I doubled my limit from 8192 to 16384.

The walk through,

1. Find out what the current open file descriptor limit is.

    ~# more /proc/sys/fs/file-max
    
    ~# 8192
    

or

    ~# sysctl -a | grep fs.file-max
    
    ~# fs.file-max = 8192

2. View how many open file descriptors are currently being used.

    ~# more /proc/sys/fs/file-nr
    
    ~# 8191

3. View how many files are open. The number returned might defer as 1 file descriptor can have multiple open files attached to it.

    ~# lsof | wc -l
    
    ~# 10325

44
4. Edit the kernel paramneter file /etc/sysctl.conf and add line "fs.file-max=[new value]" to it.
Danesh Manoharan's avatar
Danesh Manoharan committed
45
46
47
48
49
50
51
52
53
54
55

    ~# vi /etc/sysctl.conf
    
    fs.file-max = 331287

5. Apply the changes.

    ~# sysctl -p
    ~# fs.file-max = 331287

Problem fixed.