笔记 by 车东

服务器硬盘故障恢复备忘

大概是从上周四晚上开始,托管的服务器就无法访问。周五请机房重启后,仍然无法登录,干脆拔掉网线,过一个不插电的周末。

周六中午,赶到机房,尝试重启几次,发现硬盘已经无法引导了(grub error 17)。联系机器的提供商提供了块新硬盘(才用了半年),在机房现刻安装光盘,重新安装系统……这就是大概的经过了。虽然平时做了完整的apache和mysql的备份,但是恢复还是花了半天的时间。这就是用虚拟主机的好处:虽然DreamHost偶尔有掉链子的时候,可是至少不用跑机房啊……

新系统使用的是Fedora Core 4。回家学习使用了一下yum,和debian的apt-get差不多了:而且软件包的依赖关系整理的比较好。

以下是应用的安装备忘:2006年7月30日 星期日 00时18分

用awk生成关闭服务的脚本:关闭不需要的服务 sudo /sbin/chkconfig –list| grep 3:on | awk ‘{print “/sbin/chkconfig “$1” off”}’ /sbin/chkconfig acpid off /sbin/chkconfig anacron off /sbin/chkconfig apmd off /sbin/chkconfig auditd off /sbin/chkconfig autofs off /sbin/chkconfig bluetooth off /sbin/chkconfig cpuspeed off /sbin/chkconfig cups off /sbin/chkconfig gpm off /sbin/chkconfig haldaemon off /sbin/chkconfig iptables off /sbin/chkconfig isdn off /sbin/chkconfig kudzu off /sbin/chkconfig mDNSResponder off /sbin/chkconfig mdmonitor off /sbin/chkconfig messagebus off /sbin/chkconfig netfs off /sbin/chkconfig nfslock off /sbin/chkconfig nifd off /sbin/chkconfig pcmcia off /sbin/chkconfig portmap off /sbin/chkconfig rhnsd off /sbin/chkconfig rpcgssd off /sbin/chkconfig rpcidmapd off /sbin/chkconfig sendmail off /sbin/chkconfig xfs off

安装gcc(居然忘记了……) sudo yum install gcc sudo yum install gcc-c++ sudo yum install flex zlib curl zlib-devel curl-devel bzip2 bzip2-devel

apache的安装: ./configure –prefix=/home/apache –enable-shared=max –enable-module=most mysql的安装: ./configure –prefix=/home/mysql –without-innodb –with-mysqld-user=apache php的安装: ./configure –with-apxs=/home/apache/bin/apxs –enable-track-vars –with-mysql=/home/mysql –with-curl –enable-iconv –enable-mbstring
cronolog: wget http://cronolog.org/download/cronolog-1.6.2.tar.gz

安装MT需要的perl模块 sudo yum install mysql-devel sudo yum install perl-DBI sudo yum install perl-DBD-mysql

安装awstats需要的GeoIP模块: perl -MCPAN -e ‘install GeoIP’ sudo yum install GeoIP 安装awstats需要的GeoIP数据包: wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz wget http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz

sudo yum install xinetd 启用rsync

下次要把root的crontab和用户的crontab也一起备份下来,还有/etc/的一些设置

time sync

0 5 * * 1 (/usr/bin/rdate -s 202.106.196.19)

awstats

5 0 * * * (cd /home/apache/chedong.com/cgi-bin/awstats; ./awstats_updateall.pl -configdir=./ now )

remove old logs

2 2 * * * (/usr/bin/find /home/apache/logs -mtime +7 -name “log.” |/usr/bin/xargs rm -f)

backup

12 2 * * * (cd /home; tar czf /home/backup/apache.date +\%w.tgz apache) 13 2 * * * (/home/mysql/bin/mysqldump –all-databases -u*** -p*** -S/tmp/mysql.sock | gzip -f > /home/backup/mysql.date +\%w.gz)