#模拟他的场景,防火墙关闭,SELinux关闭 安装Apache服务 [root@localhost /]# yum -y install httpd #yum安装Apache服务 [root@localhost /]# service httpd restart #重启apache服务 [root@localhost /]# grep -i "^#Cu" /etc/httpd/conf/httpd.conf #CustomLog logs/access_log common #CustomLog logs/referer_log referer #CustomLog logs/agent_log agent #CustomLog logs/referer_log referer #CustomLog logs/agent_log agent [root@localhost /]# sed -i "s@#CustomLog logs/access_log common@CustomLog /app/logs/access_log common@g" /etc/httpd/conf/httpd.conf #修改一下日志的存放路径 [root@localhost /]# grep -i "^#Cu" /etc/httpd/conf/httpd.conf #CustomLog /app/logs/access_log common #CustomLog logs/referer_log referer #CustomLog logs/agent_log agent
模拟创建一个小磁盘 [root@localhost /]# dd if\=/dev/mapper/VolGroup-lv_root of\=/dev/sdb1 bs\=8k count\=10 10+0 records in 10+0 records out 81920 bytes (82 kB) copied, 0.000201325 s, 407 MB/s #dd模拟创建一个磁盘,if输入,of输出,bs:blocks大小,count:block的数量
[root@localhost /]# mkfs.ext4 /dev/sdb1 #格式化分区 mke2fs 1.41.12 (17-May-2010) /dev/sdb1 is not a block special device. Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 16 inodes, 80 blocks 4 blocks (5.00%) reserved for the super user First data block=1 1 block group 8192 blocks per group, 8192 fragments per group 16 inodes per group
Writing inode tables: done
Filesystem too small for a journal Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
#挂载分区 [root@localhost /]# mkdir -p /app/logs/ [root@localhost /]# mount /dev/sdb1 /app/logs/ #这样挂载不成功,需要特使挂载,方法在下 mount: /dev/sdb1 is not a block device (maybe try `-o loop'?) [root@localhost /]# mount -o loop /dev/sdb1 /app/logs/ [root@localhost /]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 18G 990M 16G 6% / tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 ext4 485M 33M 427M 8% /boot /dev/sdb1 ext4 73K 14K 55K 21% /app/logs #一个循环访问的脚本,1.sh #!/usr/bin/bash for n in `seq 1000000` #循环执行多少次 do curl 12.1.1.13 &>/dev/null #把访问这个网站的结果不管 对错全部放到/dev/null done [root@localhost /]# sh /tmp/1.sh & #把这个脚本放到后台执行 [root@localhost /]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 18G 995M 16G 6% / tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 ext4 485M 33M 427M 8% /boot /dev/sdb1 ext4 73K 68K 1.0K 99% /app/logs
#解决方法一:删除日志文件,重启服务 [root@localhost /]# rm -rf /app/logs/access_log #删除网站访问的日志文件 [root@localhost /]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 18G 995M 16G 6% / tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 ext4 485M 33M 427M 8% /boot /dev/sdb1 ext4 73K 68K 1.0K 99% /app/logs #把日志文件删除之后发现磁盘还是满的,这时候是因为删除文件的原理是:硬链接数(i_linke)为0,进程占用(i_count)为0,这个时候虽然硬链接数为0,。但是进程占用数不为0,所以这个文件还时存在的 [root@localhost /]#/etc/init.d/httpd restart #重启服务 Stopping httpd: [ OK ] Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 12.1.1.13 for ServerName [ OK ] [root@localhost /]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 18G 995M 16G 6% / tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 ext4 485M 33M 427M 8% /boot /dev/sdb1 ext4 73K 15K 54K 22% /app/logs #把这个进程关闭在重启,然后进程占用为0,所以磁盘空间下来了。
#解决办法2,直接清空配置文件而不删除 [root@localhost /]# echo " " > /app/logs/access_log #清空文件内容 [root@localhost /]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 18G 996M 16G 6% / tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/sda1 ext4 485M 33M 427M 8% /boot /dev/sdb1 ext4 73K 16K 53K 24% /app/logs |
报错的解决办法:
#如果报一下错误,说明模拟的分区磁盘过小,不足以创建文件系统,我们只需要在dd指令的bs参数后面加上单位,给他大一点就行 [root@localhost /]# mkfs.ext4 /dev/sdc1 mke2fs 1.41.12 (17-May-2010) /dev/sdc1 is not a block special device. Proceed anyway? (y,n) y mkfs.ext4: Device size reported to be zero. Invalid partition specified, or partition table wasn't reread after running fdisk, due to a modified partition being busy and in use. You may need to reboot to re-read your partition table. |
原文地址:http://blog.51cto.com/13447608/2090133