1 Linux default core file size is 0
What is a core file? When a program crashes, the storage image of the process is copied in the core file in the current working directory of the process. The core file is just a memory image (plus debugging information), mainly used for debugging. The core file is a binary file, and corresponding tools need to be used to analyze the memory image when the program crashes.
The system default core file size is 0, so it is not created. You can use the ulimit command to view and modify the size of the core file.
$ulimit -c
0
$ ulimit -c 1000
$ulimit-c
1000
-c specifies to modify the core file size, 1000 specifies the core file size. You can also set no limit on the size of the core file, such as:
# ulimit -c unlimited
#ulimit -c
Unlimited
If you want the changes to take effect permanently, you need to modify the configuration file
In Vim /etc/profile:
ulimit -S -c 0 > /dev/null 2>&1
change into
ulimit -S -c 1000 > /dev/null 2>&1
Reference: http://hi.baidu.com/jrckkyy/blog/item/2562320a5bdbc534b1351d95.html
2 The default value of linux open files and max user processes is 1024
#ulimit -n
1024
#ulimit –u
1024
Problem description: Description: The server only allows 1024 files to be opened at the same time and handles 1024 user processes.
Use ulimit -a to view all limit values of the current system, and use ulimit -n to view the current maximum number of open files.
The newly installed Linux only has 1024 by default. When used as a server with a heavy load, it is easy to encounter error: too many open files. Therefore, it needs to be made larger.
Solution:
Use ulimit –n 65535 to modify it immediately, but it will be invalid after restarting. (Note that ulimit -SHn 65535 is equivalent to ulimit -n 65535, -S refers to soft, and -H refers to hard)
There are three modification methods:
1. Add a line ulimit -SHn 65535
to /etc/rc.local
2. Add a line ulimit -SHn 65535
to /etc/profile
3. Add at the end of /etc/security/limits.conf:
*soft nofile 65535
*hard nofile 65535
* soft nproc 65535
*hard nproc 65535
Which one to use specifically? The first method has no effect in CentOS, the third method has an effect, and the second method has an effect in Debian.
# ulimit -n
65535
# ulimit -u
65535
Note: The ulimit command itself has soft and hard settings. Add -H for hard, add -S for soft. The default display is soft limit.
The soft limit refers to the setting value in effect on the current system. The hard limit value can be lowered by ordinary users. But it cannot be increased. The soft limit cannot be set higher than the hard limit. Only the root user can increase the hard limit value.
3 Found that there are a large number of connections in TIME_WAIT state
Problem description: A large number of connections in time_wait state were found, sometimes even reaching more than 7000
netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"t",state[key]}'
Find more time_wait connections
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
It was found that the mysql and memcache of the DB server were not released.
Solution: For applications that use a large number of tcp connections, the parameters in /etc/sysctl.conf also need to be optimized accordingly:
vim /etc/sysctl.conf
Edit the file and add the following content:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
Then execute /sbin/sysctl -p to make the parameters take effect.
Optimized:
It was found that a large number of TIME_WAIT no longer existed, and the occupancy rate of the mysql process quickly dropped.
The above has introduced nginx server system optimization, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.