Linux knowledge - constantly updated 2

In order to see more clearly their own, and to constantly sum up, after each update will be issued for one.

Encountered in the work of a folder is not enough disk space, of course, every time to clean up the log, and eventually found or is not OK, not expansion, can only find a way to migrate directories avoid this problem, but before that I chose another way to reduce the reserved space again, of course, this is the most direct way to general Linux system will default 5% of the space in order to prevent the alarm or run under extreme conditions does not affect the application. Next is operating

First check disk space: df -h to see it in the system directory location

CC180824S02P:~ # df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                     3.8G     0  3.8G   0% /dev
tmpfs                        3.9G   80K  3.9G   1% /dev/shm
tmpfs                        3.9G  395M  3.5G  11% /run
tmpfs                        3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/system-root       11G  4.4G  5.8G  44% /
/dev/sda1                    485M  113M  347M  25% /boot
/dev/mapper/appvg-app         59G 1016M   55G   2% /app
/dev/mapper/system-usrlocal  4.8G   11M  4.6G   1% /usr/local
/dev/mapper/system-srv       4.8G   11M  4.6G   1% /srv
/dev/mapper/system-home      4.8G  1.7G  2.9G  37% /home
/ dev / Mapper / 481M System 4.8G-4.1G. 11% tmp / tmp
/ dev / Mapper / 315M System 4.8G-4.3G var. 7% / var
/ dev / Mapper / System 4.8G-3.8G 795m 83% opt / opt
tmpfs 780M 20K 780M 1% / RUN / the User / 483
tmpfs 780M 0 780M 0% / RUN / the User / 1000
tmpfs 780M 0 780M 0% / RUN / the User / 0
I want to select is / opt executed next

CC180824S02P:~ # tune2fs -m 2 /dev/mapper/system-opt
tune2fs 1.42.11 (09-Jul-2014)
Setting reserved blocks percentage to 2% (26214 blocks)

Check again found reduced, I've set aside to 2% 0 course, we are not recommended.

CC180824S02P:~ # df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                     3.8G     0  3.8G   0% /dev
tmpfs                        3.9G   80K  3.9G   1% /dev/shm
tmpfs                        3.9G  395M  3.5G  11% /run
tmpfs                        3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/system-root       11G  4.4G  5.8G  44% /
/dev/sda1                    485M  113M  347M  25% /boot
/dev/mapper/appvg-app         59G 1016M   55G   2% /app
/dev/mapper/system-usrlocal  4.8G   11M  4.6G   1% /usr/local
/dev/mapper/system-srv       4.8G   11M  4.6G   1% /srv
/dev/mapper/system-home      4.8G  1.7G  2.9G  37% /home
/dev/mapper/system-tmp       4.8G  481M  4.1G  11% /tmp
/dev/mapper/system-var       4.8G  315M  4.3G   7% /var
/dev/mapper/system-opt       4.8G  3.8G  948M  81% /opt
tmpfs                        780M   20K  780M   1% /run/user/483
tmpfs                        780M     0  780M   0% /run/user/1000
tmpfs                        780M     0  780M   0% /run/user/0

Linux disk space is exhausted unknown resources

In linux, when we use rm to delete a large file on linux, but if this process is opened up large files, but did not close the file handle, then the linux kernel is still not free up disk space in this document, the final result in disk 100% occupied space, the whole system can not function properly. In this case, df and du command to find disk space, the two are not matched, may df show disk 100%, while du directory to find the disk capacity is very small footprint.

In such cases, the basic can be concluded that some large files are taking up some programs, and these large files have been deleted, but the corresponding file handle is not closed some programs, resulting in the kernel can not recover these files take up space.

So, how to find those files it is occupied some programs, the following command

lsof -n | grep deleted
COMMAND     PID      USER   FD      TYPE             DEVICE        SIZE       NODE NAME
dd        31708      higkoo    1w      REG                8,2 5523705856     429590 /data/filetest (deleted)

Command to fight lsof -n | grep deleted print all deleted files for read and write operations, such operations are not valid, it is also inexplicable disappearance of disk space the root cause

After the removal process with kill -9 pid can free up space

CC180824S02P:~ # lsof -n |grep deleted
nscd       1381             nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381             nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1392       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1392       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1393       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1393       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1394       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1394       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1395       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1395       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1396       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1396       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1397       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1397       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1398       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1398       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1399       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1399       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1400       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1400       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1401       nscd   10u      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
nscd       1381  1401       nscd   11r      REG               0,20   217032      17665 /run/nscd/dbjC6wwK (deleted)
CC180824S02P:~ # df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                     3.8G     0  3.8G   0% /dev
tmpfs                        3.9G   80K  3.9G   1% /dev/shm
tmpfs                        3.9G  402M  3.5G  11% /run
tmpfs                        3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/system-root       11G  4.4G  5.8G  44% /
/dev/sda1                    485M  113M  347M  25% /boot
/dev/mapper/appvg-app         59G 1016M   55G   2% /app
/dev/mapper/system-usrlocal  4.8G   11M  4.6G   1% /usr/local
/dev/mapper/system-srv       4.8G   11M  4.6G   1% /srv
/dev/mapper/system-home      4.8G  1.7G  2.9G  37% /home
/dev/mapper/system-tmp       4.8G  481M  4.1G  11% /tmp
/dev/mapper/system-var       4.8G  316M  4.3G   7% /var
/dev/mapper/system-opt       4.8G  1.1G  3.7G  23% /opt
tmpfs                        780M   20K  780M   1% /run/user/483
tmpfs                        780M     0  780M   0% /run/user/1000
tmpfs 780M 0 780M 0% / run / user / 0
operation and maintenance is to continue troubleshooting to find a final settlement issues.

supplement:

`lsof Which httpd` // the process is using the apache executable files 
lsof / etc / passwd  // that process in the occupied / etc / passwd 
lsof / dev / hda6 // that process in the occupied hda6 
lsof / dev / cdrom // in that process take up drive 
lsof -c sendmail // Check sendmail process file usage 
lsof -c -u ^ courier Zahn // show those files is to open the process starts with the courier, but does not belong to the user Zahn 
lsof -p 30297  // display files that are open process pid to 30297 
lsof -D / tmp show all / process open tmp folders and files in the instance. But the symbol file is not in the column 

lsof -u1000 // View uid is the user's file usage process 100 
lsof -utony // View user tony process of file usage
-u ^ tony lsof // View tony process is not user's file usage (^ is the inverse of the meaning) 
lsof -i // show all open ports 
lsof -i: 80  // show all 80 ports open process 
lsof -U -i // show all open ports and UNIX domain files 
lsof -i UDP @ [url] www.akadia.com: 123  // display those processes open to www.akadia.com of the UDP 123 (ntp) port link 
lsof -i [email protected]: ftp -r // continue to see the current situation ftp connections (-r, lsof will always continue to execute until it receives an interrupt signal, + r, lsof will execute until no files are displayed, default is 15s refresh) 
lsof -i [email protected]: the FTP -n // lsof -n not be converted to IP hostname, default is not to add - n parameters
lsof usage

 

The scene before meeting colleagues deleted the mysql table, but the file is executed rm table in the shell, rather than drop table like the command to delete a table, then mysql will handle these tables have been occupied by files, last resulting in 100% of disk space, in this case, do not restart mysql, mysql client performs just go flush tables on the line

Guess you like

Origin www.cnblogs.com/john4415/p/11697865.html