Intel core 2笔记本上成功安装mac osx86
Filed under: linux, virtualization
今天按照下面链接的步骤,在windows 7 x64上,使用virtual box 4.0.6版本成功安装了mac osx86.
http://lifehacker.com/#!5583650/run-mac-os-x-in-virtualbox-on-windows
安装的时候要注意几点:
1.使用动态分配大小的虚拟磁盘比固定大小的虚拟磁盘要慢很多,最好使用固定大小的,能节省将近1个小时的安装时间。
2.mac装起来比较大,安装完就站8G多的磁盘空间。因此分配的空间要大于8G,我分的是12G。
3.安装的时候进到:Select a Destination界面前,可以看到屏幕的最上面有一个菜单, 需要点击”Disk Utility”,清理掉找到的虚拟磁盘。这步很快。若没有使用Disk Utility来清理磁盘,那么在select a destination的时候看不到能选择的目标磁盘。
4.选择destination, 点击continue后,一点要点击“customize”来选择boot loader和kernel, 我的boot loader选择的是功能比较少的一个Chameleon,kernel选择的是最新的一个。注意boot loader, kernel都只能选择一个, 多选了服务启动不了。
5.安装前的磁盘校验可以skip掉,但第1次最好做下检查。
6.第1次启动的时候,我安装安装前的说明,加了-f参数启动,不知道不加这个参数能否启动。
Running sonar in Jenkins/hudson: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
When we run sonar:sonar in Jenkins/hudson with maven, we get the following error:
org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception:
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
I googled the message, and find it is a known problem for running jenkins with sonar:
https://issues.jenkins-ci.org/browse/JENKINS-8327
But the bug is closed without fixing. I compared the binary class of DocumentFactory in jars in maven’s repository and the one in hudson’s WEB-INF/lib directory, there are almost identical, so I believe it should be a problem caused by classloading, object created by a different classloader could not be cast to object of the same class (will raise ClassCastException).
After a little hacking, I fixed the problem by modified 2 source files in dom4j. You can fix the problem by download my modified version of dom4j-1.6.1.jar , just download it and replace hudson’s dom4j-1.6.1-hudson-3.jar with the new one (modified java source code is included within the jar):
wget http://www.beyondlinux.com/files/dom4j-1.6.1.jar
mv /home/hudson/tomcat/webapps/hudson/WEB-INF/lib/dom4j-1.6.1-hudson-3.jar /home/hudson/dom4j-1.6.1-hudson-3.jar
mv dom4j-1.6.1.jar /home/hudson/tomcat/webapps/hudson/WEB-INF/lib/dom4j-1.6.1-hudson-3.jar
ps, if error still occur, please replace the dom4j-1.6.1.jar in your .m2 repository with the modifed dom4j-1.6.1.jar .
wget批量下载文件详解:如何下载qcon,tcon 2011,oscon 2009/2010的所有slides
Filed under: design
1.下载 qcon beijing 2011的所有pdf文件
wget `curl -s http://www.qconbeijing.com/schedule.html | sed ‘s/<\/a>/\n/g’ | sed ‘s/.*href=”\([^”]*\)”.*$/\1/’ | grep download | sed ‘s/download/http:\/\/www.qconbeijing.com\/download/g’ `
命令详解:
curl下载到schedule.html,内容输出到stdout,
第1个sed把链接的结束标签替换为换行, </a>替换为换行, 以确保每行只有一个链接。
第2个sed找到所有的href=””中间的内容,并输出;
grep download 找到所有的 download/xxxx.pdf的链接,
最后一个sed把download替换为文件的全路径, 比如 网页中的 download/panxiaoliang.pdf 链接会被替换为 http://www.qconbeijing.com/download/panxiaoliang.pdf
举例,schedule.html网页中有这样的一行,其中第2个href的地址是需要提取出来,并且补充baseurl的:
<td><p align=”center”><a href=”ShowNews.aspx?id=35″>构建高性能的微博系统——再谈新浪微博架构</a><a target=”_blank” href=”download/yangweihua.pdf”>(幻灯片下载)</a><a href=”ShowNews.aspx?id=37″></a><br />
2. 下载Qcon San Francisco 2008-2011的所有slides
wget `curl http://qconsf.com/sf2008/schedule/wednesday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2008#http://qconsf.com/sf2008#’`
wget `curl http://qconsf.com/sf2008/schedule/thursday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2008#http://qconsf.com/sf2008#’`
wget `curl http://qconsf.com/sf2008/schedule/friday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2008#http://qconsf.com/sf2008#’`
重命名下载的文件为文件名中%2F后面的名字:
ls | awk -F%2F ‘{print “mv ” “\””$0″\””, “\””$5″\””}’ > ../a.sh
source ../a.sh
wget -c `curl http://qconsf.com/sf2009/schedule/wednesday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2009#http://qconsf.com/sf2009#’`
wget -c `curl http://qconsf.com/sf2009/schedule/thursday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2009#http://qconsf.com/sf2009#’`
wget -c `curl http://qconsf.com/sf2009/schedule/friday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2009#http://qconsf.com/sf2009#’`
重命名下载的文件为文件名中%2F后面的名字:
ls | awk -F%2F ‘{print “mv ” “\””$0″\””, “\””$4″\””}’ > ../a.sh
source ../a.sh
wget -c `curl http://qconsf.com/sf2010/schedule/wednesday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2010#http://qconsf.com/sf2010#’`
wget -c `curl http://qconsf.com/sf2010/schedule/thursday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2010#http://qconsf.com/sf2010#’`
wget -c `curl http://qconsf.com/sf2010/schedule/friday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/sf2010#http://qconsf.com/sf2010#’`
重命名下载的文件为文件名中%2F后面的名字:
ls | awk -F%2F ‘{print “mv ” “\””$0″\””, “\””$4″\””}’ > ../a.sh
source ../a.sh
3.下载Qcon London 2010-2011的slides
wget `curl http://qconlondon.com/london-2010/schedule/wednesday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/london-2010#http://qconlondon.com/london-2010#’`
wget `curl http://qconlondon.com/london-2011/schedule/wednesday.jsp -s | grep pdf | sed ‘s”<a href=””‘ | sed ‘s#”##’ | sed ‘s#”>##’ | sed ‘s#/london-2011#http://qconlondon.com/london-2011#’`
2010,2011年的还有如下thrusday, friday两个jsp页面中文件的下载命令上面未列出,直接替换上面的wednesday为thrusday, friday即可。
http://qconlondon.com/london-2011/schedule/thursday.jsp
http://qconlondon.com/london-2011/schedule/friday.jsp
重命名下载的文件为文件名中%2F后面的名字:
ls | awk -F%2F ‘{print “mv ” $0, $4}’ > ../a.sh
source ../a.sh
2011/07更新:
4.下载淘宝嘉年华2011 (Tcon 2011)所有slides
wget http://developerclub.taobao.com/schedule/ -O tcon2011.txt wget `grep ppts tcon2011.txt | sed 's/.*href="\([^"]*\)".*$/\1/' | sed 's#/ppts#http://developerclub.taobao.com/ppts#g'`
里面的wget下载到schedule页面的内容
grep ppts找到所有包含下载链接的行并输出到标准输出;
第1个sed找到所有href中的链接地址(相对链接地址),如 /ppts/魏子均More_Weapons_More_Power.pdf。
第2个sed将上面的相对路径替换成绝对路径, 如:
http://developerclub.taobao.com/ppts/魏子均More_Weapons_More_Power.pdf
外面的wget下载所有的链接。
5.下载oscon 2009/2010的所有slides
download oscon 2009 slides:
wget http://www.oscon.com/oscon2009/public/schedule/proceedings -O oscon2009.txt grep "Presentation File:" -A 6 oscon2009.txt | grep "a href" | sed 's/.*href="\([^"]*\)".*$/wget "\1"/' > download-oscon2009.sh source download-oscon2009.sh
第1个grep找到包含Presentation File:的行,及其后的6行并输出到控制台;
第2个grep找到包含href链接的行;
sed命令产生一条条的wget命令, 如:
wget “http://assets.en.oreilly.com/1/event/27/Django in the Real World Presentation.pdf”
然后输出到download-oscon2009.sh,并执行这个文件。
download oscon 2010 slides:
wget http://www.oscon.com/oscon2010/public/schedule/proceedings -O oscon2010.txt grep "Presentation:" -A 6 oscon2010.txt | grep "a href" | sed 's/.*href="\([^"]*\)".*$/wget "\1"/' > download-oscon2010.sh download-oscon2010.sh
具体参数与上面的类同。
debian 6.0(Squeeze)硬盘安装
在linode上搭起来了服务器,根据淘宝朋友的推荐,选了debian操作系统。考虑到软件的多样性,os对网络的依赖度,在笔记本上选择装上debian发行版,下载了debian的8张DVD,这样就不用基于网络安装软件了, 直接挂载iso。 原本debian的网络安装很方便,谁让我们在TG。
由于光驱不太好用,就试着从硬盘安装squeeze, squeeze比原先的woody,etch好装了不少, 从windows安装还是不如ubuntu,自动的iso挂载也只能挂载fat32分区的, 由于fat32分区存不了4G的dvd iso,只能放安装的CD ISO,debian里面的第1张CD里面没有gnome/kde,我安装时选了X window,装X Window是从网络安装的,花了1个多小时,还是宽带是5M的,不然不可想象要花多长时间。 如果能用光驱,建议用刻盘来安装。 总结一下安装步骤:
1. 准备好grub。由于我的操作系统是windows 7, grub用起来不如XP方便,就先装了Maxdos 8,然后把grub4dos解压后放到fat32分区。
如果是Windows NT/2000/XP直接修改C:\boot.ini,增加这样一行:
C:\GRLDR=”Start GRUB”
把grub的引导菜单加入到启动项中很方便。
2. 准备一个fat32分区,把安装的iso cd拷贝到某个fat32分区的根目录。 iso cd可以从任一一个镜像下载,如:
http://ftp.nl.debian.org/debian-cd/6.0.1a/amd64/iso-cd/
http://mirrors.sohu.com/debian-cd/6.0.1a/amd64/iso-cd/ (中国访问这个比较快)
http://mirrors.163.com/debian-cd/6.0.1a/amd64/iso-cd/ (中国访问这个比较快)
由于硬盘上都是ntfs分区,我就拿usb的分区(fat32)来访iso cd。
同时下载 debian硬盘安装需要的3个引导文件(这步很重要)vmlinuz, initrd.gz, boot.img.gz,拷贝到c:\盘根目录
我用的是amd64,从这里取:
http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/hd-media/
也可以从debian的mirror站点中取到这几个文件,比如:
http://mirrors.sohu.com/debian/dists/squeeze/main/installer-amd64/current/images/hd-media/
如果你的cpu是32位的,取这里的:
http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-i386/current/images/hd-media/
或
http://mirrors.sohu.com/debian/dists/squeeze/main/installer-i386/current/images/hd-media/
3.编辑前面解压的grub2dos中的menu.lst, 加入如下内容
###########
title hd – Install Debian
root (hd0,0)
kernel /vmlinuz
initrd /initrd.gz
###########
这一步骤可省略, 若省略,后面启动grub后,手工进入grub的command交互控制台,输入对应的root, kernel, initrd几个命令,再输入boot回车来启动debian安装界面。
4. 引导进入grub:启动机器,进入maxdos,再选择进入纯dos。 然后cd 到grub所在目录,运行grub.exe进入grub引导界面。
5.在grub引导界面选择”Install Debian”启动debian安装过程。若第3步没有编辑menu.lst,则可以手工输入grub命令来引导。
6.安装的过程中,会自动从fat32分区查找iso文件。 找到后根据提示执行安装即可。 如果网络状况不好,用iso cd装就不要选择X Window图形界面了, 装好了基本系统启动后再通过命令安装X Window,因为第1张iso cd里面没有X Window。
Hash tree (tiger tree)在大量文件实时同步中的应用
大型集群系统常需要进行多个服务器的大量文件的内容同步。
传统的文件同步方案有rsync(单向) 和 unison(双向)等,它们需要扫描所有文件后进行比对,差量传输。文件扫描计算摘要是非常耗时的,我用rsync同步maven中央仓库的内容,每次同步都要花至少几十分钟的时间计算本地的文件摘要后,才会开始从远程取新的内容。
在受控的服务器(有权限管理)的环境中,可以通过Hash Tree,就是tiger tree来实现变化文件的同步。 Sun的ZFS,Amazon的Dynamo中都有用到这种结构。
可参考
http://en.wikipedia.org/wiki/Hash_tree
http://blog.daviesliu.net/2008/04/24/sync/
简言之,Hash Tree是将所有数据的摘要信息存储成树状结构,每个节点的Hash是其所有子节点的Hash的Hash,叶子节点的Hash是其内容的Hash。这样一旦某个节点发生变化,其Hash的变化会迅速传播到根节点。需要同步的系统只需要不断查询根节点的hash,一旦有变化,顺着树状结构就能够在logN级别的时间找到发生变化的内容,马上同步。
Linux下可利用2.6内核的新特性inotify来自动感知某个目录内文件发生变化的信息,当应用程序感知到变化时,更新Hash tree的所有父节点。Windows下可使用文件系统的hook来感知文件的变化。
在需要同步时,若发现根目录的Hash值有变化,顺着目录结构往下找即可有变化的文件,再做同步。











