ubuntu 12.04 163 apt source list

  1. deb http://mirrors.163.com/ubuntu/ precise main restricted
  2. deb-src http://mirrors.163.com/ubuntu/ precise main restricted
  3.  
  4. ## Major bug fix updates produced after the final release of the
  5. ## distribution.
  6. deb http://mirrors.163.com/ubuntu/ precise-updates main restricted
  7. deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted
  8.  
  9. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  10. ## team. Also, please note that software in universe WILL NOT receive any
  11. ## review or updates from the Ubuntu security team.
  12. deb http://mirrors.163.com/ubuntu/ precise universe
  13. deb-src http://mirrors.163.com/ubuntu/ precise universe
  14. deb http://mirrors.163.com/ubuntu/ precise-updates universe
  15. deb-src http://mirrors.163.com/ubuntu/ precise-updates universe
  16.  
  17. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  18. ## team, and may not be under a free licence. Please satisfy yourself as to
  19. ## your rights to use the software. Also, please note that software in
  20. ## multiverse WILL NOT receive any review or updates from the Ubuntu
  21. ## security team.
  22. deb http://mirrors.163.com/ubuntu/ precise multiverse
  23. deb-src http://mirrors.163.com/ubuntu/ precise multiverse
  24. deb http://mirrors.163.com/ubuntu/ precise-updates multiverse
  25. deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse

u盘安装ubuntu server系统

在网上找了很多教程,都不起效,提示:“从光盘上读取数据出错”。
总结出了几个关键点。
首先,版本,Ubuntu 12.04 Server,一般的U盘安装都会报:“从光盘上读取数据出错”。如果是桌面版(Desktop),则可以正常安装。
其次,ISO转化成U盘的安装工具,选择win32diskimager,其他工具都会转化的时候可以正常制作成功,但是在安装过程会报:“从光盘上读取数据出错”。在这两个点上面,我折腾了很久,用了很多尝试方法,包括:
无光驱U盘安装 ubuntu server 12.04.1 跳过光驱检测的方法
完成之后打开U盘目录下的isolinuxsyslinux.cfg,将default vesamenu.c32注释为 # default vesamenu.c32
按了F6后面有启动参数添加栏,在后方输入:install cdrom-detect/try-usb=true 并回车,进入安装
以上这些方法都是坑爹的。
只需要选择win32diskimager制作U盘安装程序,就可以正常安装Ubuntu 12.04 Server。
win32diskimager是一款绿色软件,无需安装。解压后运行exe文件即可,界面如下:
Ubuntu
文本框用来输入文件完整地址,后面的文件夹图标是浏览窗口,默认只能识别img文件。只需要将iso文件全路径输入在Image File中。
填好镜像的完整地址后右边有个下拉列表用来选择移动设备,千万别选错了!建议只插一个U盘,以免误操作。
之后点击Wirte按钮就开始写入了。写入后重启,从U盘启动就可以进入Ubuntu 12.04 Server安装程序了!
转自:http://www.xiaoyaochong.net/wordpress/?p=137

设置centos6 yum源为光盘

1、挂载光盘

  1. mount /dev/cdrom /media/cdrom

2、设置CentOS-Media.repo

检查/etc/yum.repos.d/目录是否存在里文件,如存在,此步略过,如果不存在,手动建立,代码如下:

  1. [c6-media]
  2. name=CentOS-$releasever – Media
  3. baseurl=file:///media/CentOS/
  4.         file:///media/cdrom/
  5.         file:///media/cdrecorder/
  6. gpgcheck=1
  7. enabled=0
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

3、开始安装软件

  1. yum –disablerepo=* –enablerepo=c6-media install kernel-devel

grub rescue下手动引导系统

今天把测试服务器的另外两块硬盘撤下,不能开机,又装上,发现启动不了ubuntu系统了,出现grub rescue的画面。现在让我们来学习手动来引导系统。
1、执行ls命令会出现所有的系统分区,如下

  1. grub rescue> ls
  2. (hd0,1),(hd0,2),(hd1,1),(hd2,1)

2、一个人ls查看,看能否看到/boot分区

  1. grub rescue> ls (hd0,1)/
  2.    grub      lost+found    memtest86+_multiboot.bin     vmlinuz-3.2.0-29-generic
  3. config-3.2.0-29-generic  initrd.img-3.2.0-29-generic  memtest86+.bin  System.map-3.2.0-29-generic

如果出现类似如上文件列表,表明此hd0,1为boot分区;如果出现unkonw system,继续ls下一分区。
3、设置root和prefix

  1. grub rescue>set root=(hd0,1)
  2. grub rescue>set root=(hd0,1)/grub

4、载入模块并启动

  1. grub rescue>insmod /grub/normal.mod
  2. grub rescue>normal

5、这时候顺利的话会成功引导进系统,下一步就是正常的修复grub了。
进入系统后,执行如下命令修复(以ubuntu为例)

  1. sudo update-grub
  2. sudo grub-install /dev/sda

注:/dev/sda根据bios设置的第一硬盘设置。如果重启之后还出现grub rescue,重复以上步骤,把sda换成其它硬盘,直到成功为止。
centos的grub修复请参考http://devops.webres.wang/2012/06/centos-install-repair-grub/

使用rrdtool统计网站PV和IP

现在网站服务器已经使用snmp进行监控,已经对CPU,内存,流量等进行了监控,但觉得还需要加一项监控,就是网站的PV和IP的监控,这样可以快速知道服务器负载上升是否是网站访问量增加的原因。这几天初学rrdtool,这个工具既能存储数据,又能画图,非常的方便。
下面是统计近一天的pv和ip图。
监控

1、安装rrdtool

  1. centos: yum install rrdtool
  2. ubuntu: sudo apt-get install rrdtool

2、创建rrdtool数据库

  1. rrdtool create /var/www/test.rrd             
  2. -s 300     
  3. DS:pv:GAUGE:600:U:U   
  4. DS:ip:GAUGE:600:U:U   
  5. RRA:AVERAGE:0.5:1:288

这里创建一个test.rrd数据文件,相关参数说明如下:
-s 300 300秒存储一次数据
DS:pv:GAUGE:600:U:U
DS:ip:GAUGE:600:U:U 指定两个数据源DS,字段分别为pv和ip
RRA:AVERAGE:0.5:1:288 指定RRA,相当于数据表,存储一天的数据。

3、创建更新脚本

  1. #!/bin/bash
  2. becur=`date -d "5 minute ago" +%H%M%S`
  3. list=`tac /var/log/apache2/access.log |  awk  -v a="$becur"  -F [‘ ‘:] ‘{t=$5$6$7;if (t>=a) {print;} else {exit;} }’ | egrep -v ".(gif|jpg|jpeg|png|css|js)" `
  4. #获取五分钟内PV
  5. pv=`echo "$list" | wc -l`
  6. #获取五分钟内IP
  7. ip=`echo "$list" | awk ‘{print $1}’ | sort | uniq | wc -l `
  8. #每五分钟更新数据库
  9. rrdtool update /var/www/test.rrd N:${pv}:${ip}
  10. #每五分钟更新图片
  11. rrdtool graph /var/www/1h-pv.png
  12. -t "PV and IP statistics in an hour" 
  13. –start now-3600
  14. –watermark "`date`"
  15. –no-gridfit
  16. –slope-mode
  17. -l 0
  18. -y 1000:5
  19. -X 0 
  20. DEF:mypv=/var/www/test.rrd:pv:AVERAGE
  21. DEF:myip=/var/www/test.rrd:ip:AVERAGE
  22. AREA:mypv#9F35FF:"PV Num" 
  23. AREA:myip#00DB00:"IP Num"

把此脚本添加进计划任务,每五分钟执行一次。
这是一个包含数据更新和图片生成的脚本,相关参数说明如下:
-t “PV and IP statistics in an hour” 指定图表标题
–start now-3600 获取近一小时数据
-l 0 Y轴从0开始
-y 1000:5 定义y轴分隔线为1000,5条显示一刻度
-X 0 以原值显示y轴

rrdtool相关教程:http://oss.oetiker.ch/rrdtool/