Home > OS >  Girls understand the Linux open file setting principles
Girls understand the Linux open file setting principles

Time:09-26

We have learned that want to solve the user in "many open files" problem need to modify the user at the same time level parameter file limits. Conf and file system level parameters sysctl. Conf, how reasonable to change then? How to change to be on the safe side? Article began, I mentioned in the first appeared "many open files" problem, we just simple and crude in nofiles defaults and fs file - Max default values a zero even after several zero, why can appear sometimes will solve the problem, sometimes no use case? I according to the daily maintenance experience summed up the parameter value set to follow the following principles:
? 1, according to the limits. The soft in the conf nofiles and hard nofiles definition: soft effect refers to the current system Settings; Hard shows that the system can set the maximum value, it can be seen that soft nofiles must be less than or equal to hard nofiles value,
? Nofiles level 2, the user opens the file number of parameters must be less than or equal to system level fs. Open the file number parameter file - Max, X86 Linux the default nofiles are now a 5000, fs. File - Max is 4096, in our simple and crude after nofiles default values, add a few zero once nofiles value is greater than the fs. File - Max value, the number of open file will still be in fs. The file - Max value shall prevail, or 4096, still less than the application need to open the file number, it's reasonable explains why already expanded nofiles value but still can't solve "many open files",
? . 3, the fs file - Max * 4 k must be smaller than the memory (in bytes), and see the formula you might some dizzy, so I'll take 4 gb of memory to a simple example, such as virtual machine memory to 4 g (4 * 1024 * 1024 bytes), according to the formula to calculate the fs. File - Max must be smaller than 1024 * 1024, 1 million, that is to say, with a 4 gb of memory for the virtual machine, the fs. The file - Max value below 1 million is based on the reasonable numerical hardware condition; If set beyond the value of 1 million is equal to the number of the open file to the system without limit, without warning mechanism, when the system is of more than 1 million open the file, the system would die rammer, in other words, if the maximum allowable under the current memory file to open the number still can't meet the application requirements, can only use more memory to improve performance,
? 4, a maximum nofiles shall not set up more than 1.02 million, more than 1.02 million words will cause users cannot log in, this principle from red hat oral system engineer, senior people remember,

CodePudding user response:

Good......

CodePudding user response:

Thank you so much!

CodePudding user response:

Reprint share

refer to the second floor heroesray response:
good...
  • Related