In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to solve the Toomanyopenfiles problem in MongoDB, I believe many inexperienced people are helpless about this, for this reason this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.
Linux cannot open /dev/urrandom Too many open files. In fact, Linux has file handle restrictions, and Linux defaults to 1024 (Alibaba Cloud host defaults to 65535). It is easy to reach this value in production environment, so it will become the bottleneck of the system. For MongoDB, the default number of open files is generally not enough. You need to use ulimit to set it. The following is a common error when the maximum number of open files in MongoDB is insufficient.
-server: log pre-alloc server error: Too many open files2019-01-31T22:18:26.744+0800 E STORAGE [thread1] WiredTiger (24) [1548944306:744242][5485:0x7f03b00ea700], log-server: log server error: Too many open files2019-01-31T22:18:27.518+0800 E - [conn51828] cannot open /dev/urandom Too many open files
1. ulimt command usage
1. The ulimit command can be used to control the availability of resources. The maximum number of open files in Linux system (the maximum number of file handles opened by the process) is set.
2. The-H option and the-S option set hard and soft limits, respectively, for a given resource.
3. Hard limits, once set, cannot be modified by non-root users, and soft limits can grow to hard limits.
4. If neither the-H nor the-S option is specified, both the hard limit and the soft limit are set.
5. The value of limit can be a numerical value or some specific values, such as hard, soft, unlimited, which represent the current hardware limit, the current software limit, and no limit, respectively.
6. If the limit parameter is omitted, the resource's current soft limit will be printed unless the-H option is specified.
2. View file maximum open limit
1 [root@redis-mysql ~]# cat /proc/sys/fs/file-max file-max (system level) is the maximum number of files that can be opened by all processes in the system. Some programs can also set per-process limits by calling setrlimit. If you get an error message that a large number of file handles have been used up, you should increase this value 2 184337 3 [root@redis-mysql ~]# ulimit -n View user-level restrictions. Ali Cloud Virtual Machine is generally 65535 4 65535 5 5 [root@redis-mysql ~]# ulimit -a View current user process restrictions 6 core file size (blocks, -c) 0 7 data seg size (kbytes, -d) unlimited 8 scheduling priority (-e) 0 9 file size (blocks, -f) unlimited10 pending signals (-i) 728211 max locked memory (kbytes, -l) 6412 max memory size (kbytes, -m) unlimited13 open files (-n)65535 Linux operating system limit on the number of file handles open by a process (also includes the number of open sockets), user-level limit only 14 pipe size (512 bytes, -p) 815 POSIX message queues (bytes, -q) 81920016 real-time priority (-r) 017 stack size (kbytes, -s) 819218 cpu time (seconds, -t) unlimited19 max user processes (-u) 728220 virtual memory (kbytes, -v) unlimited21 file locks (-x) unlimited
3. View the number of files a process has opened
[root@hotcoin-mongodb-primary ~]# ps -ef|grep -i "[m]ongod"> 4. Temporary modification ulimit file limit ulimit -SHn 10000 In fact, ulimit command body is divided into soft limit and hard limit, plus-H is hard limit, plus-S is soft limit. By default, soft limits are displayed. If you run ulimit without adding-H or-S, both parameters change together. What is the difference between soft and hard limits? A hard limit is an actual limit, while a soft limit is a warning limit, which only gives warnings. 5. To make ulimits permanent, you must modify the configuration file/etc/security/limits.conf by adding 1 * soft nofile 655352 * hard nofile 655353 echo "* soft nofile 65535"> 6. In fact, the above modifications are all restrictions on the number of file handles open by a process. We also need to set the total limit of the system. Suppose we set the number of open file handles for processes to be 1024, but the system bus is only 500, so all processes can open up to 500 file handles. From here we can see that it is not enough to set the number of open file handles for a process. So you need to modify the total limit of the system. echo 6553560 > /proc/sys/fs/file-max The above is a temporary effective method, which will expire after restarting the machine; permanent effective method: modify/etc/sysctl.conf, add fs.file-max = 6553560 Restart effective 7. Settings in MongoDB-Production (nproc and nofile need to be set at the same time, 1 [root@hotcoin-mongodb-primary ~]# tail -10 /etc/security/limits.conf 2 3 # End of file 4 root soft nofile 655350 5 root hard nofile 655350 6 * soft nofile 655350 7 * hard nofile 655350 8 * soft nproc 655350 9 * hard nproc 65535010 mongod soft nofile 65535011 mongod soft nproc 65535012 [root@hotcoin-mongodb-primary ~]# cat /proc/sys/fs/file-max13 1610694 Description: * For all users, noproc represents the maximum number of processes, nofile represents the maximum number of files opened,"mongod soft nofile 655350" simple point understanding is that the maximum number of files that mongod users can open is 655350. 8. MongoDB requires the maximum number of open files calculation-WiredTiger engine MongoDB WiredTiger works differently from MMAPv1, a collection of a file, an index of a file. So how many collections are there, at least the number of collections x 2 open files (calculated as 1 collection file +1 index file) are occupied. Considering the number of network connections, ensure that the open files value is large enough. After reading the above, do you know how to solve the Toomanyopenfiles problem in MongoDB? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.