服务器使用时间长了,XenServer产生了很多日志,甚至有些人因为日志占满了空间,导致系统出现问题:xapi崩溃,或者系统卡死,重启也无效。所以我们要时常看看日志是否占的空间的,清理下日志
先查看系统盘的使用情况(XenServer默认是4G系统空间)
[iyunv@xenserver-shptahqk log]# df -hal 复制代码 Filesystem Size Used Avail Use% Mounted on
/dev/sda1 4.0G 4.0G 0G 100% /
none 0 0 0 - /proc
none 0 0 0 - /sys
............
可以看到,/dev/sda1的空间已经满了,在系统中与很多目录,可能某个目录都占了大量的空间,那么我们可以找出来,清理下
先列出系统中有哪些目录
cd /
ls 复制代码 bin dev home media opt root srv usr
boot etc lib mnt proc sbin sys var
cli-rt EULA lost+found myiso Read_Me_First.html selinux tmp
查下 / 目录里所有文件大小
du -sh *
这里我们看那个目录的空间大就进去删除,我看var 文件夹大 du -hcs var 复制代码 2G var
2G total
可以看到var这个目录下占用了系统看哦你就2G,那么我们在切换到这个目录看看是根目录下那个占用了空间
cd /var
ls 复制代码 cache db games local log nis patch run swap xapi yp
crash empty lib lock mail opt preserve spool tmp xen
日志目录就在这个:log,检查下它
du -hcs log 复制代码 1.9G log
1.9G total
看到og目录占用的空间是最大的,这个是日志目录我们可以把下面的文件都删除了
cd log
ls 复制代码 然后我们就可以删除下面全部文件了,你怕操作失误的话,就一个个删除 rm -rf 文件名 复制代码 删除后,需要重启下xapi service xapi restart 复制代码
You can remove old log files with this command: ----
rm -f /var/log/*.? /var/log/*.??
----
Also, you can search the filesystem for large files. For instance, to search for files that are 10 Megabytes or larger:
----
find / -xdev -size 10M -print
---- If you've uploaded large files to the root filesystem (such as uploading ISO images and placing them outside of the /iso_import/images directory) you should see them in the output from the above "find" command. Please let us know if you have any further questions. Kind Regards.
|