csatblogspotdotcom

Wednesday, December 31, 2008

启动PV的ubuntu时出现的错误及其解决

首先同样是缺少modules.dep,把Domain0中的modules.dep拷贝到DomainU相应目录就可以了;
第二个错误是
error: "kernel.maps_protect" is an unknown key
error: "vm.mmap_min_addr" is an unknown key
后来搜了一下,在DomainU的/etc/sysctl.conf中把相应的两行注释掉就可以了,据说这两个错误可以安全的被忽略;

后面还有几个错误明天解决

后记:
今天解决了
modprobe: FATAL: Could not open '/lib/modules/2.6.18.8-xen/kernel/net/ipv6/ipv6.ko': No such file or directory
这个问题,直接把Domain0的文件拷贝到DomainU对应的目录即可

还有另外一个问题
Couldnt get a file descriptor referring to the console
这个在配置文件中加上extra="xencons=xvc0"后用vnc或sdl去连就没问题了

最后一个问题
Unable to set System Clock to: Sat Jan 3 06:10:59 UTC 2009
没解决,但这并不影响启动和运行,事实上登录后系统时间并没问题(和Domain0是一致的)。

Labels: ,

Tuesday, December 30, 2008

终于理解ps(postscript)了

以前一直以为p.s.和BTW差不多的意思,代表“补充说明”之类的。今天想使用“后记”时才发现p.s.原来就是后记的意思(同时还有附笔的意思)。以下是freedictionary的解释:
1. A message appended at the end of a letter after the writer's signature.
2. Additional information appended to the manuscript, as of a book or article.

Labels:

chm格式难压缩

刚才想用bzip2压缩一本chm格式的书,用tar命令的-j参数压缩,结果基本没压缩,于是干脆用bzip2命令,结果还是基本没压缩;换用rar的最大压缩比,最后根本没压缩。看来chm格式本来就是压缩过的,根本就压缩不了。

Labels:

连不上网卡导致DomainU不能正常启动的解决

今天启动DomainU时出现错误:
error: device 0 (vif) could not be connected. hotplug scripts not working
后来发现是eth0连不上,把eth0改为eth1(双网卡)后即可,或者干脆去掉,只留vif=[ 'type=ioemu' ]也可以(把eth0改为xenbr0会提示:Error: Device 0 (vif) could not be connected. Could not find bridge device xenbr0)

后记:今天发现服务器上只有peth1(MAC和eth1相同),而没有peth0,于是猜测pethN映射到了ethN上。于是在/etc/xen/xend-config.sxp中添加(network-script 'network-bridge netdev=eth0'),强行将peth1改为peth0,这样重启后ifconfig,果然没了peth1,只有peth0,这时把vif设置改为vif = [ 'type=ioemu, bridge=eth0' ]后可以正常启动了,没有出现昨天的错误,但是还是不能上网。
分析其原因:由于以前eth0对应的IP可以上网,于是xen启动时默认把peth和eth0关联,虚拟机可以正常启动;但后来估计是由于eth0对应的IP需要认证才能上网,没认证时不能上网,于是xen启动检查时自动把peth关联到了eth1上(peth0换成了peth1,eth1可以上网),vif = [ 'type=ioemu, bridge=eth0' ]这个配置就有问题了,虚拟机就不能正常启动了,改为vif = [ 'type=ioemu' ]就可以了;后来在xen的配置文件中强制改为peth0后,使用配置vif = [ 'type=ioemu, bridge=eth0' ]就可以正常启动虚拟机了,但虚拟机通过eth0不能正常上网,即使是认证上之后也是有时启动的虚拟机能上网有时启动的又不能,而使用配置vif = [ 'type=ioemu' ]也是有时启动的能有时启动的又不能,但如果显示的使用eth1:vif = [ 'type=ioemu, bridge=eth1' ]则可以正常上网。

后记:
刚才发现半虚拟化配置文件中也可以像全虚拟化一样配置vif,如vif = [ 'type=ioemu, bridge=xenbr0' ],其中ioemu指定NIC是一个ioemu设备而不是netfront,但发现这样配置后启动,再看过程,和vif = [ '' ]时的运行结果一样。看来type=ioemu一句不起作用,网络在半虚拟化方式下还是以前后端方式实现。

Labels: ,

Monday, December 29, 2008

myxrgsu曾经遇到的问题

曾经装过myxrgsu,当时装的时候出了问题,后来一个很牛的师兄帮我搞定了,具体原因我已记不清了,但大概情况如下:
这个软件的安装就是把文件夹下bin/和lib/两个包的内容分别拷贝到/usr/bin/和/usr/lib/中就可以了,但拷贝过之后还是不行,后来发现lib/中文件的版本比现有系统上的还要低,于是干脆没有用软件包中的lib文件,而是直接做了个同名软链接,直接链到本系统新版本的lib文件上,这样,bin/里的文件需要用到lib文件时,还是按原来的文件名去找,找到这个软链接后转向新版本的lib文件,结果可以正常运行。

Labels: ,

Sunday, December 28, 2008

DomainU启动时出现的问题及其解决

从jailtime下载了一个Debian4.0(64位)的镜像启动后出现错误,启动过程如下:
Using config file "/home/cs/xen/cfg/pv.deb.4-0.64.cfg".
Started domain cs.pv.deb.4-0.64
Calibrating delay using timer specific routine.. 3193.14 BogoMIPS (lpj=15965730)
Security Framework v1.0.0 initialized
Capability LSM initialized
Mount-cache hash table entries: 256
, L1 D cache: 32K
CPU: Physical Processor ID: 1
CPU: Processor Core ID: 1
SMP alternatives: switching to UP code
Brought up 1 CPUs
migration_cost=0
checking if image is initramfs... it is
Freeing initrd memory: 3960k freed
NET: Registered protocol family 16
SMP alternatives: switching to SMP code
Initializing CPU#1
migration_cost=11444
Brought up 2 CPUs
PCI: setting up Xen PCI frontend stub
ACPI: Interpreter disabled.
Linux Plug and Play Support v0.97 (c) Adam Belay
pnp: PnP ACPI: disabled
xen_mem: Initialising balloon driver.
PCI: System does not support PCI
PCI: System does not support PCI
NET: Registered protocol family 2
IP route cache hash table entries: 32768 (order: 6, 262144 bytes)
TCP established hash table entries: 131072 (order: 9, 2097152 bytes)
TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
TCP: Hash tables configured (established 131072 bind 65536)
TCP reno registered
IA-32 Microcode Update Driver: v1.14a-xen
audit: initializing netlink socket (disabled)
audit(1230455412.105:1): initialized
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
Initializing Cryptographic API
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
rtc: IRQ 8 is not free.
Non-volatile memory driver v1.2
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize
Xen virtual console successfully installed as xvc0
Event-channel device installed.
netfront: Initialising virtual ethernet driver.
Console: switching to colour frame buffer device 100x37
input: Xen Virtual Keyboard as /class/input/input0
input: Xen Virtual Pointer as /class/input/input1
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
PNP: No PS/2 controller found. Probing ports directly.
i8042.c: No controller found.
mice: PS/2 mouse device common for all mice
md: md driver 0.90.3 MAX_MD_DEVS=256, MD_SB_DISKS=27
md: bitmap version 4.39
NET: Registered protocol family 1
NET: Registered protocol family 17
xen-vbd: registered block device major 8
blkfront: sda1: barriers enabled
XENBUS: Device with no driver: device/console/0
IP-Config: Complete:
device=eth0, addr=192.168.205.49, mask=255.255.255.0, gw=192.168.205.1,
host=192.168.205.49, domain=, nis-domain=(none),
bootserver=127.0.255.255, rootserver=127.0.255.255, rootpath=
Freeing unused kernel memory: 172k freed
usbcore: registered new driver usbfs
usbcore: registered new driver hub
USB Universal Host Controller Interface driver v3.0
SCSI subsystem initialized
register_blkdev: cannot get major 8 for sd
Adaptec aacraid driver (1.1-5[2409]-mh2)
ext3: No journal on filesystem on sda1
Kernel panic - not syncing: Attempted to kill init!
奇怪的是之前同样从jailtime下了个Debian3.1(32位)的镜像,可以正常使用。开始不知道怎么回事,以为是64位系统的缘故,于是下了个Debian4.0的64位的镜像,但还是出现了同样的问题。
上网搜了下,用命令tune2fs -j pv.deb.4-0.img(其中的-j选项可以“Add an ext3 journal to the filesystem”),输出:
tune2fs 1.39 (29-May-2006)
Creating journal inode: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
重新启动DomainU问题依旧;后来怀疑是镜像中的fstab的问题,于是挂载镜像,发现根文件夹对应的一行最后一个是0,于是将之改为1,重启后问题依旧;
最后怀疑是文件系统格式原因,把镜像重新解压后file了一下,原来是ext2格式!于是在fstab中把格式改为ext2但还是不行,最后不得不自己做了个镜像并格式化为ext3,这样就可以启动了,但启动过程还是出现了错误提示:
FATAL: Could not load /lib/modules/2.6.18.8-xen/modules.dep: No such file or directory
而且整个启动过程出现了不止一次,我试着把Domain0的/lib/modules/2.6.18.8-xen/文件夹拷贝到镜像中,再启动,终于OK了。

但最后还有个小问题:fdisk -l时提示:
Disk /dev/sda1 doesn't contain a valid partition table
后来发现之前可以正常启动的Debian3.1也有同样问题。
感觉整个就是磁盘格式的原因,ext2和ext3混了。后来又创建了ext2格式的镜像,把下载的磁盘镜像中的文件全部拷贝到其中后不能启动,问题和开始时一样,看来只有这一个方法了:自己建个ext3的镜像,把下载镜像的所有内容拷贝到其中,以及Domain0中/lib/modules/2.6.18.8-xen/modules.dep拷贝到镜像中,用自己的镜像启动。












下面是我的几个配置文件:
1. cat pv.deb.3-1.cfg:
kernel = "/boot/vmlinuz-2.6-xen"
ramdisk = "/boot/initrd-2.6.18.8-xen.img"
vcpus=2
memory = 512
name = "cs.pv.deb.3-1"
vif = [ '' ]
ip = "192.168.205.47"
netmask = "255.255.255.0"
gateway = "192.168.205.1"
#disk = ['file:/home/cs/xen/img/deb/pv.deb.3-1.img,sda1,w', 'file:/home/cs/xen/img/deb/debian.swap,sda2,w']
disk = ['file:/home/cs/xen/img/deb/pv.deb.3-1.img,sda1,w']
root = "/dev/sda1 ro"

#vfb = [ 'type=sdl' ]
vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncdisplay=47' ]
extra="xencons=xvc0"




2. cat pv.deb.4-0.cfg:
kernel = "/boot/vmlinuz-2.6-xen"
ramdisk = "/boot/initrd-2.6.18.8-xen.img"
vcpus=2
memory = 512
name = "cs.pv.deb.4-0"
vif = [ '' ]
ip = "192.168.205.48"
netmask = "255.255.255.0"
gateway = "192.168.205.1"
#disk = ['file:/home/cs/xen/img/deb/pv.deb.4-0.img,sda1,w', 'file:/home/cs/xen/img/deb/debian.swap,sda2,w']
disk = ['file:/home/cs/xen/img/deb/pv.deb.4-0.img,sda1,w']
root = "/dev/sda1 ro"

#vfb = [ 'type=sdl' ]
vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncdisplay=48' ]
extra="xencons=xvc0"




3. cat pv.deb.4-0.64.cfg:
kernel = "/boot/vmlinuz-2.6-xen"
ramdisk = "/boot/initrd-2.6.18.8-xen.img"
vcpus=2
memory = 512
name = "cs.pv.deb.4-0.64"
vif = [ '' ]
ip = "192.168.205.49"
netmask = "255.255.255.0"
gateway = "192.168.205.1"
disk = ['file:/home/cs/xen/img/deb/pv.deb.4-0.64.img,sda1,w']
root = "/dev/sda1 ro"

#vfb = [ 'type=sdl' ]
vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncdisplay=49' ]
extra="xencons=xvc0"

Labels: ,

Saturday, December 27, 2008

所有网站ping得通但所有软件都上不了网的解决

一台比较老的机子,灰尘比较多
偶尔会出现这样的情况:
除了ping,还有w3m等文本浏览器可以正常使用之外
其它的软件都连接不了网络,web、qq、邮件客户端等都不行
DNS没问题,局域网内其它人的机子都可以正常上网,把自己的网线给别人用时别人的机子也能正常上网
而且Windows和Linux下都这样,
每次都是重启好多次才又重新可以上网
有时还换网卡插槽

最后终于发现网卡有点松,把网卡往上抬一下后重启就好了(插槽在侧边,网卡平放,拿住网卡的另一侧往上抬),估计是网卡的接触问题。

Labels:

关于tar命令

tar用于文件的打包解包以及压缩和解压,常用的参数有:
-c,打包
-x,解包
-v,打包解包时把正在打(解)包的文件的信息打印出来
-f,对哪个文件进行打(解)包
-j,进行bzip2压缩或解压
-z,进行gzip压缩或解压
-C或--directory,把包解到指定目录
-t,列出包中文件
-X或--exclude,排除指定目录

p.s.
若是只解压其中的某个文件,则在命令后面加上该文件的名字,如:
tar jxf name.tar.bz2 name/dir/filename
若是只解压其中某个文件到指定目录,则加-C选项:
tar jxf name.tar.bz2 -C to/which/dir/ name/dir/filename
或者是
tar jxf name.tar.bz2 name/dir/filename -C to/which/dir/
注意:解压时,当前所在的文件夹必须是有权限操作的,因为解压时会产生一个临时文件放在当前目录,如果没有当前目录的读写权限则会报错。

后记20170101:
例如,将alex目录打包压缩为tar.bz2格式:
tar jcf alex.tar.bz2 alex
将alex.tar.bz2解压到tmp目录
tar jxf alex.tar.bz2 -C ./tmp/

后记20170428:
tar jcf打包默认相对路径,如果后面跟的是绝对路径如:
tar jcf /**/** /**/**
会提示 tar: Removing leading `/' from member names
解压的时候会解压出全路径,例如打包/home/**/**,解压的时候会解压出完整的/home/**/**一串目录
所以建议打包的时候先cd到需要打包的目标所在的目录,再打包,这样解压的时候就不包含绝对路径信息

Labels: ,

查看系统是64位还是32位的方法

uname -a
cat /etc/issue
cat /proc/version
cat /proc/cpuinfo
file /bin/ls
ldd /usr/bin/nano
getconf WORD_BIT
dmesg|head
看文件夹:64位系统除了/lib/外还有/lib64/文件夹

此外用这段程序也可以识别:
#include
using namespace std;

int main(int argc, char ** argv)
{
cout << sizeof(long) << endl;
return 0;
}
如果是32位机器输出4,64位则输出8.

p.s.
在xen的Domain0中用dmesg|head好像不行;
参见 http://cjs0550.blog.hexun.com/23618532_d.html
1. file 检查的是文件格式种类,不是 "CPU" 位数。
2. ldd 检查的是 library 相依性状态,看这个信息不准的原因是相依性讯息只有在 64/32 混用时才会特别标示出来是连结到那一组函式库的
3. uname可显示机器硬件信息例如在64位机器上uname -m后显示x86_64;用uname -a可以把所以信息显示出来。
4. getconf WORD_BIT 有人说可以识别,但也有人说其实要看的是 LONG_BIT 的值才对。

Labels: ,

vi时键盘映射出错的问题

有时候在使用vi时碰到这样的情况:按了a或i或o后,本来是想插入,但结果把某行给删除了,感觉键盘上的a字符已不是以前的a,好像键盘重新被映射了,我碰到过并解决的有两次。
一次是Virtual PC中装了个redhat,用Virtual PC自带的共享方式共享了一个文件夹(似乎是NFS),结果文件夹被误挂两次,导致虚拟机中键盘映射错误,vi根本没法用,最后重启虚拟机就OK了。
另外一次(就是刚才 :-)),在Windows上用putty去连linux服务器,突然发现VI不好用了(以前都好好的),怀疑是字符编码不一致问题,于是locale:
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh:en_US:en
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
接着把putty的编码改为UTF-8,立马就好了,果然是两边编码不一致的问题!

p.s. 虽然现在的vi都是vim的一个软链接,但有时用vi还是有可能运行vi,这是也要注意了,有些键是不能用的,最好只用主键盘区的键,否则也有可能让人感觉是键盘映射出了问题。

Labels: ,

PV的DomainU的sdl和vnc显示

下面是关于SDL方式启动:
在原有的配置文件中加上 vfb = [ 'type=sdl' ]后启动,卡死在
ext3 fs on sda1, internal journal
此时用xm console DomID可以登录到该Domain,说明机器已经启动,只是在窗口中不能显示,于是Google之。
开始加上extra="xencons=tty"或extra="xencons=tty1"都不行,后来加上extra="console=xvc0 xencons=xvc0"即可,但开机加载项和关机时的信息都没显示,于是试了下,只要加上
extra="xencons=xvc0"
即可

注意:在用这种方法启动时,屏幕刚出来时会显示QEMU的信息,说明这种半虚拟化也用到了QEMU。
p.s. extra="2"时可以把启动的runlevel设为2.

当用到vnc方式时,试了下没有extra="xencons=xvc0"的情况,结果和SDL方式一样,加上后正常;后来启动时特意注意了下,果然在最开始的界面上有QEMU的语句,看来整个过程和sdl一样。

下面来贴一下我的配置文件:
kernel = "/boot/vmlinuz-2.6-xen"
ramdisk = "/boot/initrd-2.6.18.8-xen.img"
vcpus=2
memory = 512
name = "cs.pv.deb.3"
vif = [ '' ]
ip = "192.168.205.47"
netmask = "255.255.255.0"
gateway = "192.168.205.1"
disk = ['file:/home/cs/xen/img/deb/debian.3-1.img,sda1,w', 'file:/home/cs/xen/img/deb/debian.swap,sda2,w']
root = "/dev/sda1 ro"

#vfb = [ 'type=sdl' ]
vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncdisplay=47' ]
extra="xencons=xvc0"

Labels: ,

用rdp连接DomainU的Windows

在Windows上可以装个vnc server后用vnc viewer去连,但这还是不如Windows自带的远程桌面好用,于是试着使用远程桌面。
以前用远程桌面没能连上HVM的Windows,估计是iptables的原因,于是打开了3389端口(rdp协议),果然能连上。

p.s.
1. 这种方法和在操作系统上装个vnc server类似,都是应用层的软件,看不到开机启动过程,不同于xen提供的vnc机制。
2. 后来发现远程桌面还不能修改桌面背景图片,虽然网上说在组策略gpedit.msc中可以修改,但我修改后还是不管用;更可笑的是在某用户登录到该Windows之前,远程桌面是连不上这台机子的,这就是说,必须先通过xen的vnc登到主机(登录进去之后),然后才能使用远程桌面登录。看来还是xen自带的vnc最好用。

Labels: ,

HVM的sdl连接

在配置文件中设置sdl=1,出现了一点问题。
本来应该是一个鼠标,但还是出现了两个鼠标的问题,虽然两个鼠标基本重合,但还是感觉不好。
更重要的是其颜色很怪,就好像彩色电视机的另一种制式,色调反常。
看来sdl方式还是不好用。以后多用vnc

Labels: ,

Friday, December 26, 2008

vnc连接HVM的DomainU时鼠标指针的问题

通过Xen自带的vnc server连接HVM的DomainU时,会出现两个鼠标指针的现象。其中的一个黑点是vnc传过来的绝对坐标确定的鼠标,而另一个指针是HVM中真实的鼠标。两个鼠标指针不是问题,问题是二者并不同步,使用起来很不方便。(参见Users' Manual。)其中的一个解决方法是在配置文件中将显示方式改为sdl,这样只会显示一个鼠标指针(但我装的一个Debian仍然显示两个,估计是bug);另外一个是将vnc的设置做一些改动:首先是将usb=1加上,然后再加上usbdevice='tablet',这样虽然仍显示两个,移动一个时,鼠标指针比起黑点有一些延时,但鼠标停下来后鼠标指针会定位到黑点,总的效果还可以(调整鼠标精确度后,似乎对鼠标没任何影响)。

p.s.
1. 如果同时加上usbdevice=mouse和usbdevice=tablet效果和只加usbdevice=tablet基本一样;而如果只加usbdevice=mouse,效果和没加一样,而且有时鼠标指针不能移动(黑点可以移动),整个屏幕没反应,等好一会儿才恢复正常。(只有usbdevice=tablet时也可能出现鼠标暂时失效的问题,仅在usbdevice=mouse和usbdevice=tablet同时出现时尚未发现此问题。)
2. 在Debian系统中,不需要设置usb选项,只需在系统设置中把鼠标精确度调整一下就可以了,黑点和鼠标指针始终重合,效果比设置了usb选项还好;但是在Windows系统中,设置了鼠标灵敏度后还是不行,其加速效果太明显:例如缓慢移动时鼠标指针比黑点慢,而快速移动时又比黑点快。
3. 以上都是在HVM中,而对于PV,也有相应的选项,以后再试试。
4. 下面来贴一下Debian和Windows系统的配置文件:

下面是Debian系统的:
# -*- mode: python; -*-

arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------
# hvmloader in place of a kernel image

kernel = "/usr/lib/xen/boot/hvmloader"

# guest domain build function (for HVM guests we use 'hvm')
builder='hvm'

device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

# memory allocation at boot in MB
memory = 512

# shadow pagetable memory,
#should be at least 2KB per MB of memory plus a few MB per vcpu
shadow_memory = 8

name = "cs.fv.deb" # name for the domain

# number of CPUs guest has available (default=1)
vcpus=2

# HVM guest PAE support (default=0 disabled)
#pae=0

# HVM guest ACPI support (default=0 disabled)
#acpi=0

# HVM guest APIC support (default=0 disabled)
#apic=0

#----------------------------------------------------------------

# 1 NIC, auto-assigned MAC address
vif = [ 'type=ioemu, bridge=eth0' ]

# first device is LVM partition to use as hard disk,
# second device is an image of an installation CD-ROM
#disk = ['phy:/dev/XenGuests/hvm1,hda,w', 'tap:aio:/root/winxp.iso,hdc:cdrom,r']
#disk = ['file:/home/cs/xen/img/deb/fv.deb.img,hda,w', 'file:/home/cs/Desktop/mini.iso,hdc:cdrom,r']
disk = ['file:/home/cs/xen/img/deb/fv.deb.img,hda,w']

# boot order (a=floppy, c=hard disk, d=CD-ROM; default=cda)
boot="cda"

# function to execute when guest wishes to power off
#on_poweroff = 'destroy'

# function to execute when guest wishes to reboot
#on_reboot = 'restart'

# function to execute if guest crashes
#on_crash = 'restart'
#----------------------------------------------------------------
# SDL library support for graphics (default=0 disabled)
sdl=0

# VNC library support for graphics (default=0 disabled)
vnc=1

#------------------------VNC-------------------------------------
# address for VNC server to listen on,
# (default is to use the 'vnc-listen'
# setting in /etc/xen/xend-config.sxp)
vnclisten="0.0.0.0"

# set the VNC display number (default=domid)
vncdisplay=46

# find an unused port for the VNC server (default=1 enabled)
vncunused=1

# spawn vncviewer for domain's console (default=0 disabled)
#vncconsole=0

#------------------------VGA-------------------------------------
# no graphics, only serial (do not enable for Windows guests)
#nographic=0

# stdvga (cirrus logic model, default=0 disabled)
stdvga=0

# start in full screen (default=0 no)
#full-screen=1

#------------------------USB-------------------------------------
# USB support
#(devices may be specified through the monitor window)
#usb=1

# normal/relative mouse
#usbdevice='mouse'

# tablet/absolute mouse
#usbdevice='tablet'

#------------------------MISC------------------------------------
# serial port re-direct to pty device,
# allows xm console or minicom to connect
#serial='pty'

# sound card support (sb16, es1370, all; default none)
#soundhw='sb16'

# set real time clock to local time (default=0 UTC)
localtime=1










下面是Windows系统的:
# -*- mode: python; -*-

arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------
# hvmloader in place of a kernel image

kernel = "/usr/lib/xen/boot/hvmloader"

# guest domain build function (for HVM guests we use 'hvm')
builder='hvm'

device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

# memory allocation at boot in MB
memory = 512

# shadow pagetable memory,
#should be at least 2KB per MB of memory plus a few MB per vcpu
shadow_memory = 8

name = "cs.fv.win" # name for the domain

# number of CPUs guest has available (default=1)
vcpus=2

# HVM guest PAE support (default=0 disabled)
#pae=0

# HVM guest ACPI support (default=0 disabled)
#acpi=0

# HVM guest APIC support (default=0 disabled)
#apic=0

#----------------------------------------------------------------

# 1 NIC, auto-assigned MAC address
vif = [ 'type=ioemu, bridge=eth0' ]

# first device is LVM partition to use as hard disk,
# second device is an image of an installation CD-ROM
#disk = ['phy:/dev/XenGuests/hvm1,hda,w', 'tap:aio:/root/winxp.iso,hdc:cdrom,r']
#disk = ['file:/home/cs/xen/img/win/winxp.img,hda,w', 'file:/mount/vfat/WindowsXP.iso,hdc:cdrom,r']
disk = ['file:/home/cs/xen/img/win/winxp.img,hda,w']

# boot order (a=floppy, c=hard disk, d=CD-ROM; default=cda)
#boot="cda"
boot="cda"

# function to execute when guest wishes to power off
#on_poweroff = 'destroy'

# function to execute when guest wishes to reboot
#on_reboot = 'restart'

# function to execute if guest crashes
#on_crash = 'restart'
#----------------------------------------------------------------
# SDL library support for graphics (default=0 disabled)
sdl=0

# VNC library support for graphics (default=0 disabled)
vnc=1

#------------------------VNC-------------------------------------
# address for VNC server to listen on,
# (default is to use the 'vnc-listen'
# setting in /etc/xen/xend-config.sxp)
vnclisten="0.0.0.0"

# set the VNC display number (default=domid)
vncdisplay=45

# find an unused port for the VNC server (default=1 enabled)
vncunused=1

# spawn vncviewer for domain's console (default=0 disabled)
#vncconsole=0

#------------------------VGA-------------------------------------
# no graphics, only serial (do not enable for Windows guests)
#nographic=0

# stdvga (cirrus logic model, default=0 disabled)
stdvga=0

# start in full screen (default=0 no)
#full-screen=1

#------------------------USB-------------------------------------
# USB support
#(devices may be specified through the monitor window)
usb=1

# normal/relative mouse
#usbdevice='mouse'

# tablet/absolute mouse
usbdevice='tablet'

#------------------------MISC------------------------------------
# serial port re-direct to pty device,
# allows xm console or minicom to connect
#serial='pty'

# sound card support (sb16, es1370, all; default none)
#soundhw='sb16'

# set real time clock to local time (default=0 UTC)
localtime=1



后记:
今天突然发现Debian的鼠标没问题了(VNC方式),配置也没改啊(如下所示),真奇怪。

# -*- mode: python; -*-

arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------
# hvmloader in place of a kernel image

kernel = "/usr/lib/xen/boot/hvmloader"

# guest domain build function (for HVM guests we use 'hvm')
builder='hvm'

device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

# memory allocation at boot in MB
memory = 512

# shadow pagetable memory,
#should be at least 2KB per MB of memory plus a few MB per vcpu
shadow_memory = 8

name = "cs.fv.deb.5-0" # name for the domain

# number of CPUs guest has available (default=1)
vcpus=2

# HVM guest PAE support (default=0 disabled)
#pae=0

# HVM guest ACPI support (default=0 disabled)
#acpi=0

# HVM guest APIC support (default=0 disabled)
#apic=0

#----------------------------------------------------------------

# 1 NIC, auto-assigned MAC address
vif = [ 'type=ioemu, bridge=eth1' ]
#vif = [ 'type=ioemu' ]

# first device is LVM partition to use as hard disk,
# second device is an image of an installation CD-ROM
#disk = ['phy:/dev/XenGuests/hvm1,hda,w', 'tap:aio:/root/winxp.iso,hdc:cdrom,r']
#disk = ['file:/home/cs/xen/img/deb/fv.deb.5.0.img,hda,w', 'file:/home/cs/Desktop/mini.iso,hdc:cdrom,r']
disk = ['file:/home/cs/xen/img/deb/fv.deb.5-0.img,hda,w']

# boot order (a=floppy, c=hard disk, d=CD-ROM; default=cda)
boot="cda"

# function to execute when guest wishes to power off
#on_poweroff = 'destroy'

# function to execute when guest wishes to reboot
#on_reboot = 'restart'

# function to execute if guest crashes
#on_crash = 'restart'
#----------------------------------------------------------------
# SDL library support for graphics (default=0 disabled)
sdl=0

# VNC library support for graphics (default=0 disabled)
vnc=1

#------------------------VNC-------------------------------------
# address for VNC server to listen on,
# (default is to use the 'vnc-listen'
# setting in /etc/xen/xend-config.sxp)
vnclisten="0.0.0.0"

# set the VNC display number (default=domid)
vncdisplay=46

# find an unused port for the VNC server (default=1 enabled)
vncunused=1

# spawn vncviewer for domain's console (default=0 disabled)
#vncconsole=0

#------------------------VGA-------------------------------------
# no graphics, only serial (do not enable for Windows guests)
#nographic=0

# stdvga (cirrus logic model, default=0 disabled)
stdvga=0

# start in full screen (default=0 no)
#full-screen=1

#------------------------USB-------------------------------------
# USB support
#(devices may be specified through the monitor window)
#usb=1

# normal/relative mouse
#usbdevice='mouse'

# tablet/absolute mouse
#usbdevice='tablet'

#------------------------MISC------------------------------------
# serial port re-direct to pty device,
# allows xm console or minicom to connect
#serial='pty'

# sound card support (sb16, es1370, all; default none)
#soundhw='sb16'

# set real time clock to local time (default=0 UTC)
localtime=1

Labels: ,

关于HVM的vnc连接

Xen本身实现了一套vnc的机制,与应用层的vnc server不同,这套机制是Xen工具集里的工具,源代码在tools/文件夹中,它可以把DomainU的启动过程都显示出来,就像我们在物理显示器上看到的那样,而不是只能看到图形界面初始化好后的桌面。这套机制和普通vnc server都把图像扔到了590N端口,所以对vnc viewer来说,二者没什么区别。

使用Xen的vnc时,在配置文件中设置sdl=0,vnc=1,vncdisplay=45,虚拟机开启后,对应了Domain0的一个端口,例如45,如何连接这个vnc端口呢?有两种方法:
第一种可以用应用软件vnc viewer连接,不管是在哪台机子上(本地或远程),直接用vncviewer去连IP:45即可(本地的话可以用127.0.0.1:45也可IP:45);
第二种,在Domain0用命令xm vncviewer DomID(DomID为DomainU的ID号),注意,如果在其它机子上是连不上的,这只针对于本地。
这两种方法的一个区别就是后者少了一个vncviewer进程(在Domain0中用ps -u命令查看),而后者估计是消耗的Xen的资源,总的来说,后者消耗的资源应该比前者少。

在DomainU的应用层使用vnc时,和物理机上一样,可以直接把DomainU当成一个物理机。

p.s. 以上都是针对HVM的

Labels: ,

Wednesday, December 24, 2008

linux系统增加loop设备

把一个磁盘镜像或光盘镜像(iso文件)挂载到某目录下时,需要用到loop设备,linux系统默认有8个(/dev/loop0-/dev/loop1),这样需要启动多个虚拟机时,loop设备就有可能不够用,需要增加loop设备。

当loop设备部分被直接编译进内核时,好像直接在grub中加入max_loop=64(应该可以在kernel一行中/boot/vmlinuz后添加)重启或者直接在启动时向grub加入max_loop=64即可,但我没实验成功。

当loop设备部分被以模块形式编译时,在/etc/modprobe.conf中加入options loop max_loop=64,配置就完成了。重启后在/dev/下面只发现了8个loop设备,还以为没配好,但开启多个虚拟机后(loop设备超过8个),loop设备自动的增加到了64个(/dev/loop0 - /dev/loop63)。后来又试了下:重启机器,此时/dev/中有8个loop设备,rmmod loop后报错:ERROR: Module loop does not exist in /proc/modules,接着modprobe loop,没输出,应该是成功加载了loop模块,此时再到/dev/下看,有64个loop设备,看来超过64个shi时系统自动加载了loop模块。

p.s.
1. 对于模块来说,不需重启整个系统,只需要先卸载模块然后加载即可。对于loop设备来说,配置更改后先rmmod loop再modprobe loop即可。
2. 要想在系统启动时自动加载某模块,需要在/etc/rc.d/rc.sysinit或/etc/rc.sysinit(其实是/etc/rc.d/rc.sysinit的一个软链接)中修改配置。

后记:在xenXXX/buildYYY/.config中修改CONFIG_BLK_DEV_LOOP为CONFIG_BLK_DEV_LOOP=m;
而当用menuconfig时,修改Device Drivers ---> Block devices ---> Loopback device support为M即可。

Labels: ,

firefox不能正常打开网页的解决

有时候碰到这样的情况:IE能正常打开网页,但firefox打开后是一片空白。比如cs.hust.edu.cn
后来听说加个webroot即可,于是试了下,果然,用cs.hust.edu.cn/webroot可以在firefox中正常浏览,然后在IE中打开cs.hust.edu.cn,发现该URL被自动解析为cs.hust.edu.cn/webroot,现在终于清楚了:IE可以自动跳转到cs.hust.edu.cn/webroot,而firefox不能自动跳转,于是显示出一片空白。
以后可以这样:先在IE中看真实的有效的URL是多少,然后在firefox中打开。

Labels: ,

Tuesday, December 23, 2008

DomainU镜像文件的重复挂载

开始把镜像文件挂载到/mnt/img/下面,在没有卸载的情况下直接启动了虚拟机(半虚拟),结果一点事都没有。在/root/里面创建了一个文件,但是在/mnt/img/root/目录中看不到这个文件,紧接着再继续把磁盘镜像挂载一次,到/mnt/iso/中,可以看到在/mnt/iso/root/中确实有刚才创建的文件,只不过是红底白字,ls一下出现:ls:aaa:Input/output error,file一下出现:aaa:ERROR:cannot open 'aaa' (Input/output error),但vi之没问题;关掉虚拟机后再次启动出现错误,然后把/mnt/iso/里的umount掉后(此时/mnt/img/还没umount)就可以启动了,此时文件还在,ls和file都出现error,而且也是vi之没问题,此时再把镜像挂载到/mnt/iso/中(此时镜像被挂载了两次,外加虚拟机使用一次),也可以看到该文件。

很奇怪。。。

但是创建另外一个文件bbb后却很正常(在/mnt/img/中能被识别为正常文件),可能这种重复挂载很容易出现问题吧。。。

后记:用命令losetup配置和控制loop设备,如losetup /dev/loop0查看loop0的信息

Labels: ,

Monday, December 22, 2008

在Xen的Domain U上安装OpenSolaris2008.11

前两天在Xen 3.3上以全虚拟化方式安装了OpenSolaris操作系统,具体过程如下:
首先把OpenSolaris的安装光盘下载到本地目录~/OpenSolaris/iso/。
第二步,用命令dd if=/dev/zero of=~/OpenSolaris/OpenSolaris.img bs=1k seek=40M count=1创建一个磁盘镜像,该磁盘镜像被虚拟机当作硬盘使用。磁盘文件的名字为OpenSolaris.img,大小为40G。(注意:用该命令创建的磁盘镜像文件的大小是随着磁盘内容的增加而动态增长的,刚创建好磁盘镜像时用ls –l命令查看到的大小40G并不是真实占用的空间,用du –sh命令可以看到刚创建好的磁盘镜像占用空间只有16K)
第三步,写一个配置文件~/OpenSolaris/OpenSolaris.cfg,内容如下:
#-----------------------------------------------------------------------------
import os, re
arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/usr/lib/xen/boot/hvmloader"

#-----------------------------------------------------------------------------
# The domain build function. HVM domain uses 'hvm'.
builder='hvm'

#-----------------------------------------------------------------------------
# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
#内存大小设置为1G
memory = 1024

#-----------------------------------------------------------------------------
# A name for your domain. All domains must have different names.
#虚拟机的名字为OpenSolaris
name = "OpenSolaris"

#-----------------------------------------------------------------------------
# The number of cpus guest platform has, default=1
#虚拟CPU的个数为2
vcpus=2

#-----------------------------------------------------------------------------
# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.
#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ]
# type=ioemu specify the NIC is an ioemu device not netfront
#vif = [ 'type=ioemu, bridge=xenbr0' ]
#网卡使用eth0物理网卡
vif = [ 'type=ioemu, bridge=eth0' ]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.
#磁盘镜像文件使用file:/home/cs/OpenSolaris/OpenSolaris.img,同时把file:/home/cs/OpenSolaris/iso/OpenSolaris.iso当作光驱使用。
disk = [ 'file:/home/cs/OpenSolaris/OpenSolaris.img,hda,w', 'file:/home/cs/OpenSolaris/iso/OpenSolaris.iso,hdc:cdrom,r' ]

#----------------------------------------------------------------------------
# Device Model to be used
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

#-----------------------------------------------------------------------------
# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
#boot="cda"
#设置为从光驱启动
boot="d"

#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=0

#----------------------------------------------------------------------------
# enable OpenGL for texture rendering inside the SDL window, default = 1
# valid only if sdl is enabled.
opengl=1

#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
#启动后通过vnc连接访问其图形界面
vnc=1

#----------------------------------------------------------------------------
# address that should be listened on for the VNC server if vnc is set.
# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
#允许任何IP使用vnc服务
vnclisten="0.0.0.0"

#----------------------------------------------------------------------------
# set VNC display number, default = domid
#vncdisplay=1

#----------------------------------------------------------------------------
# try to find an unused port for the VNC server, default = 1
#vncunused=1

#----------------------------------------------------------------------------
# set password for domain's VNC console
# default is depents on vncpasswd in xend-config.sxp
#没有设置vnc密码
vncpasswd=''

#----------------------------------------------------------------------------
# enable stdvga, default = 0 (use cirrus logic device model)
stdvga=0

#-----------------------------------------------------------------------------
# serial port re-direct to pty deivce, /dev/pts/n
# then xm console or minicom can connect
serial='pty'
第四步,使用命令sudo xm create ~/OpenSolaris/OpenSolaris.cfg来启动虚拟机,并用命令sudo xm list来查看相应状态。
第五步,通过命令vncviewer 127.0.0.1命令来访问其图形界面。注意:有时端口被其它虚拟机占用时需要用IP:1、IP:2(依此类推)来访问。接下来就和在物理机上安装OpenSolaris一样了。
最后在安装好系统后,将配置文件稍作修改:一个是将disk设置改为disk = [ 'file:/home/cs/OpenSolaris/OpenSolaris.img,hda,w' ],因为不再需要光驱;另一个是将boot=d改为boot=c,不再从光驱启动,而是从硬盘启动。

p.s. 在安装好OpenSolaris后,发现不能上网,怀疑是域名解析设置问题,于是在/etc/nsswitch.conf中查看配置,果然在hosts一行是hosts:file,于是将其修改为hosts:file dns;但是重启网络后发现还是上不了网,更奇怪的是所有的IP都ping的通,但就是ping不同URL,于是怀疑是iptables的原因,试探性的用iptables –F将iptables禁掉,就可以上网了,果然是iptables的问题;最后在/etc/sysconfig/iptables文件中加上两行:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT
重启iptables后就可以正常上网了。

Labels: ,

Sunday, December 21, 2008

在vi中转换UNIX和DOS格式(行尾的^M)

刚才从Windows下把一个文件拷贝到Linux服务器下,然后又从服务器拷贝到另外一台Debian的机子上,打开后每行的行尾都多了一个“^M”。这次不同于以往情况:在vi中查看fileformat:set ff,确实是unix。
首先,Windows和Linux换行的区别:\r\n(< CR > < LF >)和\n(< LF >),从Windows拷贝到Linux时,\r被认为是一个单独的字符 ^M ( ^M这个字符用Ctrl+V后回车或者Ctrl+V后Ctrl+M可以输入),而从Linux到Windows,由于没有\r,\n就被认为是一个字符,在notepad中显示就是一个黑色的方块,而且整个文件很有可能只有一行。
接下来这里的情况,先从Windows拷贝到Linux上,估计系统认为是从Windows传过来的,于是认为是DOS格式(是根据文件从哪个系统传过来来判断文件格式,而不是文件本身的附加信息),于是可以正常显示;当从Linux又拷贝到另一台Linux(Debian)上时,估计是系统认为文件是从Linux传过来的,于是是unix格式,所以按unix格式文件来显示,这样把每行结尾的\r\n中的\n认为是换行符,而\r忽略了,导致\r被显示出来(^M),同时格式还被认为是unix格式。
这样的话,就不能用set ff=unix来解决了,只能用vi的s命令来解决。通过 %s/^M$// 或 %s/.$// 或 %s/\r$// 替换,其中%(或1,$)表示对整个文档所有的行进行替换,而.$或^M$中的$表示行尾(行首对应 ^ )。

p.s.
现在的vi命令基本上都是vim的一个软链接,而古老的vi在使用时,也常常会出现行尾^M的现象,个人认为这是由于vi不能识别DOS格式的文件造成的。

Labels: ,

Saturday, December 20, 2008

制作DomainU时碰到的一些问题

这两天制作了hvm,其中碰到了一些问题。
首先是启动不起来,后来发现是自己改错了配置
本来是:
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
结果我画蛇添足改成了:
device_model = '/usr/' + arch_libdir + '/usr/lib64/xen/bin/qemu-dm'
后来才看懂,arch_libdir在本地其实就是lib64,所以device_model本来就是
/usr/lib64/xen/bin/qemu-dm,加入/usr/lib64就使结果变为:
/usr/lib64/usr/lib64/xen/bin/qemu-dm
解决这个问题后就可以正常启动了。
下面show一下我的第一个hvm的配置:
# -*- mode: python; -*-

arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------
# hvmloader in place of a kernel image

kernel = "/usr/lib/xen/boot/hvmloader"

# guest domain build function (for HVM guests we use 'hvm')
builder='hvm'

device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

# memory allocation at boot in MB
memory = 512

# shadow pagetable memory,
#should be at least 2KB per MB of memory plus a few MB per vcpu
shadow_memory = 8

name = "cs.fv.win" # name for the domain

# number of CPUs guest has available (default=1)
vcpus=2

# HVM guest PAE support (default=0 disabled)
#pae=0

# HVM guest ACPI support (default=0 disabled)
#acpi=0

# HVM guest APIC support (default=0 disabled)
#apic=0

#----------------------------------------------------------------

# 1 NIC, auto-assigned MAC address
vif = [ 'type=ioemu, bridge=eth0' ]

# first device is LVM partition to use as hard disk,
# second device is an image of an installation CD-ROM
#disk = ['phy:/dev/XenGuests/hvm1,hda,w', 'tap:aio:/root/winxp.iso,hdc:cdrom,r']
disk = ['file:/home/cs/xen/images/win/winxp.img,hda,w', 'file:/home/cs/Desktop/WindowsXP.iso,hdc:cdrom,r']

# boot order (a=floppy, c=hard disk, d=CD-ROM; default=cda)
#boot="cda"
boot="d"

# function to execute when guest wishes to power off
#on_poweroff = 'destroy'

# function to execute when guest wishes to reboot
#on_reboot = 'restart'

# function to execute if guest crashes
#on_crash = 'restart'
#----------------------------------------------------------------
# SDL library support for graphics (default=0 disabled)
sdl=0

# VNC library support for graphics (default=0 disabled)
vnc=1

#------------------------VNC-------------------------------------
# address for VNC server to listen on,
# (default is to use the 'vnc-listen'
# setting in /etc/xen/xend-config.sxp)
vnclisten="0.0.0.0"

# set the VNC display number (default=domid)
vncdisplay=44

# find an unused port for the VNC server (default=1 enabled)
vncunused=1

# spawn vncviewer for domain's console (default=0 disabled)
#vncconsole=0

#------------------------VGA-------------------------------------
# no graphics, only serial (do not enable for Windows guests)
#nographic=0

# stdvga (cirrus logic model, default=0 disabled)
stdvga=0

# start in full screen (default=0 no)
#full-screen=1

#------------------------USB-------------------------------------
# USB support
#(devices may be specified through the monitor window)
#usb=1

# normal/relative mouse
#usbdevice='mouse'

# tablet/absolute mouse
#usbdevice='tablet'

#------------------------MISC------------------------------------
# serial port re-direct to pty device,
# allows xm console or minicom to connect
#serial='pty'

# sound card support (sb16, es1370, all; default none)
#soundhw='sb16'

# set real time clock to local time (default=0 UTC)
localtime=1


后来装了个Debian,先创建一个磁盘镜像(一个文件对应一个硬盘),不必格式化,把iso文件当作光驱,从iso文件启动,接下来像在物理机上安装一样。我从网络安装Debian,有几种方式,可以用grub引导linux和initrd.gz后安装,也可以从mini.iso(估计就是linux和initrd.gz的集成)启动安装。安装时选择一个速度快的站点,从上面下载安装文件。整个过程在很大程度上取决于网速,装好后在虚拟机配置文件中改为从硬盘启动,重新启动虚拟机即可。
进入fv的Debian后,居然只有update-rc.d,没有sysvconfig也没sysv-rc-conf,所以干脆手动改。其间把avahi服务给mv掉了(在前面加了个点),结果上不了网,最后mv回去就号好了。
其间还查了下umask,一般设置文件中umask 22,表示创建的文件默认属性为755(022取反)。



后记1:
# -*- mode: python; -*-

arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------
# hvmloader in place of a kernel image

kernel = "/usr/lib/xen/boot/hvmloader"

# guest domain build function (for HVM guests we use 'hvm')
builder='hvm'

device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

# memory allocation at boot in MB
memory = 512

# shadow pagetable memory,
#should be at least 2KB per MB of memory plus a few MB per vcpu
shadow_memory = 8

name = "cs.fv.deb" # name for the domain

# number of CPUs guest has available (default=1)
vcpus=2

# HVM guest PAE support (default=0 disabled)
#pae=0

# HVM guest ACPI support (default=0 disabled)
#acpi=0

# HVM guest APIC support (default=0 disabled)
#apic=0

#----------------------------------------------------------------

# 1 NIC, auto-assigned MAC address
vif = [ 'type=ioemu, bridge=eth0' ]

# first device is LVM partition to use as hard disk,
# second device is an image of an installation CD-ROM
#disk = ['phy:/dev/XenGuests/hvm1,hda,w', 'tap:aio:/root/winxp.iso,hdc:cdrom,r']
#disk = ['file:/home/cs/xen/images/debian/fv.deb.img,hda,w', 'file:/home/cs/Desktop/mini.iso,hdc:cdrom,r']
disk = ['file:/home/cs/xen/images/debian/fv.deb.img,hda,w']

# boot order (a=floppy, c=hard disk, d=CD-ROM; default=cda)
boot="cda"

# function to execute when guest wishes to power off
#on_poweroff = 'destroy'

# function to execute when guest wishes to reboot
#on_reboot = 'restart'

# function to execute if guest crashes
#on_crash = 'restart'
#----------------------------------------------------------------
# SDL library support for graphics (default=0 disabled)
sdl=0

# VNC library support for graphics (default=0 disabled)
vnc=1

#------------------------VNC-------------------------------------
# address for VNC server to listen on,
# (default is to use the 'vnc-listen'
# setting in /etc/xen/xend-config.sxp)
vnclisten="0.0.0.0"

# set the VNC display number (default=domid)
vncdisplay=46

# find an unused port for the VNC server (default=1 enabled)
vncunused=1

# spawn vncviewer for domain's console (default=0 disabled)
#vncconsole=0

#------------------------VGA-------------------------------------
# no graphics, only serial (do not enable for Windows guests)
#nographic=0

# stdvga (cirrus logic model, default=0 disabled)
stdvga=0

# start in full screen (default=0 no)
#full-screen=1

#------------------------USB-------------------------------------
# USB support
#(devices may be specified through the monitor window)
usb=1

# normal/relative mouse
usbdevice='mouse'

# tablet/absolute mouse
usbdevice='tablet'

#------------------------MISC------------------------------------
# serial port re-direct to pty device,
# allows xm console or minicom to connect
#serial='pty'

# sound card support (sb16, es1370, all; default none)
#soundhw='sb16'

# set real time clock to local time (default=0 UTC)
localtime=1


以上是可以从46号端口用vnc连接的配置






后记2:
在连接时碰到过
read/select connection aborted 10053
的问题
查了下,网上有的说是客户端或防火墙或网络之类的问题,于是把vncviewer换成了tightvnc,一连接就可以了,果然是本地的vncviewer的问题!



后记3:
对了,除了10053错误之外,还有一个现象:有一个屏幕一闪而过,看不清楚是什么。估计是传过来一帧之后就断开了

后记4:
今天装rhel5的全虚拟化镜像虚拟机,结果不管咋样都卡在安装过程中,最后据说是vcpu的原因:不能用多核,只能设置成单核,于是试了一下,果然。

后记5:
今天通过全虚拟化镜像制作半虚拟化镜像,启动后系统只读,后来发现是fstab没正确配置的原因,最后在/etc/fstab中只留下这一行就ok了:
/dev/sda1 / ext3 defaults 1 1

Labels: ,

Friday, December 19, 2008

Xen的几个DomainU配置文件示例

第一个配置文件是《Running Xen》这本书上的:
# -*- mode: python; -*-

arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------
# hvmloader in place of a kernel image

kernel = "/usr/lib/xen/boot/hvmloader"

# guest domain build function (for HVM guests we use 'hvm')
builder='hvm'

device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

# memory allocation at boot in MB
memory = 128

# shadow pagetable memory,
#should be at least 2KB per MB of memory plus a few MB per vcpu
shadow_memory = 8

name = "hvmexample1" # name for the domain

# number of CPUs guest has available (default=1)
vcpus=1

# HVM guest PAE support (default=0 disabled)
#pae=0

# HVM guest ACPI support (default=0 disabled)
#acpi=0

# HVM guest APIC support (default=0 disabled)
#apic=0

#----------------------------------------------------------------

# 1 NIC, auto-assigned MAC address
vif = [ 'type=ioemu, bridge=xenbr0' ]

# first device is LVM partition to use as hard disk,
# second device is an image of an installation CD-ROM
disk = ['phy:/dev/XenGuests/hvm1,hda,w', 'tap:aio:/root/winxp.iso,hdc:cdrom,r']

# boot order (a=floppy, c=hard disk, d=CD-ROM; default=cda)
boot="cda"

# function to execute when guest wishes to power off
#on_poweroff = 'destroy'

# function to execute when guest wishes to reboot
#on_reboot = 'restart'

# function to execute if guest crashes
#on_crash = 'restart'
#----------------------------------------------------------------
# SDL library support for graphics (default=0 disabled)
sdl=1

# VNC library support for graphics (default=0 disabled)
vnc=0

#------------------------VNC-------------------------------------
# address for VNC server to listen on,
# (default is to use the 'vnc-listen'
# setting in /etc/xen/xend-config.sxp)
#vnclisten="10.0.0.20"

# set the VNC display number (default=domid)
#vncdisplay=1

# find an unused port for the VNC server (default=1 enabled)
#vncunused=1

# spawn vncviewer for domain's console (default=0 disabled)
#vncconsole=0

#------------------------VGA-------------------------------------
# no graphics, only serial (do not enable for Windows guests)
#nographic=0

# stdvga (cirrus logic model, default=0 disabled)
stdvga=0

# start in full screen (default=0 no)
#full-screen=1

#------------------------USB-------------------------------------
# USB support
#(devices may be specified through the monitor window)
#usb=1

# normal/relative mouse
#usbdevice='mouse'

# tablet/absolute mouse
#usbdevice='tablet'

#------------------------MISC------------------------------------
# serial port re-direct to pty device,
# allows xm console or minicom to connect
#serial='pty'

# sound card support (sb16, es1370, all; default none)
#soundhw='sb16'

# set real time clock to local time (default=0 UTC)
localtime=1


























以下几个文件都是Xen3的配置文件示例(全部都在/etc/xen/文件夹下面):
xmexample1:
# -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================

#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/boot/vmlinuz-2.6.10-xenU"

# Optional ramdisk.
#ramdisk = "/boot/initrd.gz"

# The domain build function. Default is 'linux'.
#builder='linux'

# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 64

# A name for your domain. All domains must have different names.
name = "ExampleDomain"

# 128-bit UUID for the domain. The default behavior is to generate a new UUID
# on each call to 'xm create'.
#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"

# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5
#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3

# Number of Virtual CPUS to use, default is 1
#vcpus = 1

#----------------------------------------------------------------------------
# Define network interfaces.

# By default, no network interfaces are configured. You may have one created
# with sensible defaults using an empty vif clause:
#
# vif = [ '' ]
#
# or optionally override backend, bridge, ip, mac, script, type, or vifname:
#
# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
#
# or more than one interface may be configured:
#
# vif = [ '', 'bridge=xenbr1' ]

vif = [ '' ]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.

disk = [ 'phy:hda1,hda1,w' ]

#----------------------------------------------------------------------------
# Define frame buffer device.
#
# By default, no frame buffer device is configured.
#
# To create one using the SDL backend and sensible defaults:
#
# vfb = [ 'type=sdl' ]
#
# This uses environment variables XAUTHORITY and DISPLAY. You
# can override that:
#
# vfb = [ 'type=sdl,xauthority=/home/bozo/.Xauthority,display=:1' ]
#
# To create one using the VNC backend and sensible defaults:
#
# vfb = [ 'type=vnc' ]
#
# The backend listens on 127.0.0.1 port 5900+N by default, where N is
# the domain ID. You can override both address and N:
#
# vfb = [ 'type=vnc,vnclisten=127.0.0.1,vncdisplay=1' ]
#
# Or you can bind the first unused port above 5900:
#
# vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncunused=1' ]
#
# You can override the password:
#
# vfb = [ 'type=vnc,vncpasswd=MYPASSWD' ]
#
# Empty password disables authentication. Defaults to the vncpasswd
# configured in xend-config.sxp.

#----------------------------------------------------------------------------
# Define to which TPM instance the user domain should communicate.
# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM'
# where INSTANCE indicates the instance number of the TPM the VM
# should be talking to and DOM provides the domain where the backend
# is located.
# Note that no two virtual machines should try to connect to the same
# TPM instance. The handling of all TPM instances does require
# some management effort in so far that VM configration files (and thus
# a VM) should be associated with a TPM instance throughout the lifetime
# of the VM / VM configuration file. The instance number must be
# greater or equal to 1.
#vtpm = [ 'instance=1,backend=0' ]

#----------------------------------------------------------------------------
# Set the kernel command line for the new domain.
# You only need to define the IP parameters and hostname if the domain's
# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
# You can use 'extra' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= ).

# Set if you want dhcp to allocate the IP address.
#dhcp="dhcp"
# Set netmask.
#netmask=
# Set default gateway.
#gateway=
# Set the hostname.
#hostname= "vm%d" % vmid

# Set root device.
root = "/dev/hda1 ro"

# Root device for nfs.
#root = "/dev/nfs"
# The nfs server.
#nfs_server = '192.0.2.1'
# Root directory on the nfs server.
#nfs_root = '/full/path/to/root/directory'

# Sets runlevel 4.
extra = "4"

#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# In the event a domain stops due to a crash, you have the additional options:
#
# "coredump-destroy", meaning dump the crashed domain's core and then destroy;
# "coredump-restart', meaning dump the crashed domain's core and the restart.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'

#on_poweroff = 'destroy'
#on_reboot = 'restart'
#on_crash = 'restart'

#-----------------------------------------------------------------------------
# Configure PVSCSI devices:
#
#vscsi=[ 'PDEV, VDEV' ]
#
# PDEV gives physical SCSI device to be attached to specified guest
# domain by one of the following identifier format.
# - XX:XX:XX:XX (4-tuples with decimal notation which shows
# "host:channel:target:lun")
# - /dev/sdxx or sdx
# - /dev/stxx or stx
# - /dev/sgxx or sgx
# - result of 'scsi_id -gu -s'.
# ex. # scsi_id -gu -s /block/sdb
# 36000b5d0006a0000006a0257004c0000
#
# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as
# which the specified guest domain recognize.
#

#vscsi = [ '/dev/sdx, 0:0:0:0' ]

#============================================================================





































xmexample2:
# -*- mode: python; -*-
#============================================================================
# Example Python setup script for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
#
# This is a relatively advanced script that uses a parameter, vmid, to control
# the settings. So this script can be used to start a set of domains by
# setting the vmid parameter on the 'xm create' command line. For example:
#
# xm create vmid=1
# xm create vmid=2
# xm create vmid=3
#
# The vmid is purely a script variable, and has no effect on the the domain
# id assigned to the new domain.
#============================================================================

# Define script variables here.
# xm_vars is defined automatically, use xm_vars.var() to define a variable.

# This function checks that 'vmid' has been given a valid value.
# It is called automatically by 'xm create'.
def vmid_check(var, val):
val = int(val)
if val <= 0:
raise ValueError
return val

# Define the 'vmid' variable so that 'xm create' knows about it.
xm_vars.var('vmid',
use="Virtual machine id. Integer greater than 0.",
check=vmid_check)

# Check the defined variables have valid values..
xm_vars.check()

#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/boot/vmlinuz-2.6.10-xenU"

# Optional ramdisk.
#ramdisk = "/boot/initrd.gz"

# The domain build function. Default is 'linux'.
#builder='linux'

# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 64

# A name for the new domain. All domains have to have different names,
# so we use the vmid to create a name.
name = "VM%d" % vmid

# 128-bit UUID for the domain. The default behavior is to generate a new UUID
# on each call to 'xm create'.
#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"

# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5
#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3
#cpus = "%s" % vmid # set based on vmid (mod number of CPUs)

# Number of Virtual CPUS to use, default is 1
#vcpus = 1
vcpus = 4 # make your domain a 4-way

#----------------------------------------------------------------------------
# Define network interfaces.

# By default, no network interfaces are configured. You may have one created
# with sensible defaults using an empty vif clause:
#
# vif = [ '' ]
#
# or optionally override backend, bridge, ip, mac, script, type, or vifname:
#
# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
#
# or more than one interface may be configured:
#
# vif = [ '', 'bridge=xenbr1' ]

vif = [ '' ]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.

# This makes the disk device depend on the vmid - assuming
# that devices sda7, sda8 etc. exist. The device is exported
# to all domains as sda1.
# All domains get sda6 read-only (to use for /usr, see below).
disk = [ 'phy:sda%d,sda1,w' % (7+vmid),
'phy:sda6,sda6,r' ]

#----------------------------------------------------------------------------
# Define frame buffer device.
#
# By default, no frame buffer device is configured.
#
# To create one using the SDL backend and sensible defaults:
#
# vfb = [ 'type=sdl' ]
#
# This uses environment variables XAUTHORITY and DISPLAY. You
# can override that:
#
# vfb = [ 'type=sdl,xauthority=/home/bozo/.Xauthority,display=:1' ]
#
# To create one using the VNC backend and sensible defaults:
#
# vfb = [ 'type=vnc' ]
#
# The backend listens on 127.0.0.1 port 5900+N by default, where N is
# the domain ID. You can override both address and N:
#
# vfb = [ 'type=vnc,vnclisten=127.0.0.1,vncdisplay=%d' % vmid ]
#
# Or you can bind the first unused port above 5900:
#
# vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncunused=1' ]
#
# You can override the password:
#
# vfb = [ 'type=vnc,vncpasswd=MYPASSWD' ]
#
# Empty password disables authentication. Defaults to the vncpasswd
# configured in xend-config.sxp.

#----------------------------------------------------------------------------
# Define to which TPM instance the user domain should communicate.
# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM'
# where INSTANCE indicates the instance number of the TPM the VM
# should be talking to and DOM provides the domain where the backend
# is located.
# Note that no two virtual machines should try to connect to the same
# TPM instance. The handling of all TPM instances does require
# some management effort in so far that VM configration files (and thus
# a VM) should be associated with a TPM instance throughout the lifetime
# of the VM / VM configuration file. The instance number must be
# greater or equal to 1.
#vtpm = ['instance=%d,backend=0' % (vmid) ]

#----------------------------------------------------------------------------
# Set the kernel command line for the new domain.
# You only need to define the IP parameters and hostname if the domain's
# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
# You can use 'extra' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= ).

# Set if you want dhcp to allocate the IP address.
#dhcp="dhcp"
# Set netmask.
#netmask=
# Set default gateway.
#gateway=
# Set the hostname.
#hostname= "vm%d" % vmid

# Set root device.
root = "/dev/sda1 ro"

# Root device for nfs.
#root = "/dev/nfs"
# The nfs server.
#nfs_server = '192.0.2.1'
# Root directory on the nfs server.
#nfs_root = '/full/path/to/root/directory'

# Sets runlevel 4 and the device for /usr.
extra = "4 VMID=%d usr=/dev/sda6" % vmid

#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# In the event a domain stops due to a crash, you have the additional options:
#
# "coredump-destroy", meaning dump the crashed domain's core and then destroy;
# "coredump-restart', meaning dump the crashed domain's core and the restart.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'

#on_poweroff = 'destroy'
#on_reboot = 'restart'
#on_crash = 'restart'

#-----------------------------------------------------------------------------
# Configure PVSCSI devices:
#
#vscsi=[ 'PDEV, VDEV' ]
#
# PDEV gives physical SCSI device to be attached to specified guest
# domain by one of the following identifier format.
# - XX:XX:XX:XX (4-tuples with decimal notation which shows
# "host:channel:target:lun")
# - /dev/sdxx or sdx
# - /dev/stxx or stx
# - /dev/sgxx or sgx
# - result of 'scsi_id -gu -s'.
# ex. # scsi_id -gu -s /block/sdb
# 36000b5d0006a0000006a0257004c0000
#
# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as
# which the specified guest domain recognize.
#

#vscsi = [ '/dev/sdx, 0:0:0:0' ]

#============================================================================













































xmexample3:
# -*- mode: python; -*-
#============================================================================
# Example Python setup script for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
#
# This is a relatively advanced script that uses a parameter, vmid, to control
# the settings. So this script can be used to start a set of domains by
# setting the vmid parameter on the 'xm create' command line. For example:
#
# xm create vmid=1
# xm create vmid=2
# xm create vmid=3
#
# The vmid is purely a script variable, and has no effect on the the domain
# id assigned to the new domain.
#============================================================================

# Define script variables here.
# xm_vars is defined automatically, use xm_vars.var() to define a variable.

# This function checks that 'vmid' has been given a valid value.
# It is called automatically by 'xm create'.
def vmid_check(var, val):
val = int(val)
if val <= 0:
raise ValueError
return val

# Define the 'vmid' variable so that 'xm create' knows about it.
xm_vars.var('vmid',
use="Virtual machine id. Integer greater than 0.",
check=vmid_check)

# Check the defined variables have valid values..
xm_vars.check()

#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/path/to/domU/kernel"

# Optional ramdisk.
#ramdisk = "/boot/initrd.gz"

# The domain build function. Default is 'linux'.
#builder='linux'

# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 64

# A name for the new domain. All domains have to have different names,
# so we use the vmid to create a name.
name = "VM%d" % vmid

# 128-bit UUID for the domain. The default behavior is to generate a new UUID
# on each call to 'xm create'.
#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"

# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5
#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3
cpus = "%s" % vmid # set based on vmid (mod number of CPUs)

#----------------------------------------------------------------------------
# Define network interfaces.

# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.

vif = [ 'ip=192.168.%d.1/24' % (vmid)]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.

# This makes the disk device depend on the vmid - assuming
# tHat devices sda7, sda8 etc. exist. The device is exported
# to all domains as sda1.
# All domains get sda6 read-only (to use for /usr, see below).
disk = [ 'phy:hda%d,hda1,w' % (vmid)]

#----------------------------------------------------------------------------
# Define frame buffer device.
#
# By default, no frame buffer device is configured.
#
# To create one using the SDL backend and sensible defaults:
#
# vfb = [ 'type=sdl' ]
#
# This uses environment variables XAUTHORITY and DISPLAY. You
# can override that:
#
# vfb = [ 'type=sdl,xauthority=/home/bozo/.Xauthority,display=:1' ]
#
# To create one using the VNC backend and sensible defaults:
#
# vfb = [ 'type=vnc' ]
#
# The backend listens on 127.0.0.1 port 5900+N by default, where N is
# the domain ID. You can override both address and N:
#
# vfb = [ 'type=vnc,vnclisten=127.0.0.1,vncdisplay=%d' % vmid ]
#
# Or you can bind the first unused port above 5900:
#
# vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncunused=1' ]
#
# You can override the password:
#
# vfb = [ 'type=vnc,vncpasswd=MYPASSWD' ]
#
# Empty password disables authentication. Defaults to the vncpasswd
# configured in xend-config.sxp.

#----------------------------------------------------------------------------
# Define to which TPM instance the user domain should communicate.
# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM'
# where INSTANCE indicates the instance number of the TPM the VM
# should be talking to and DOM provides the domain where the backend
# is located.
# Note that no two virtual machines should try to connect to the same
# TPM instance. The handling of all TPM instances does require
# some management effort in so far that VM configration files (and thus
# a VM) should be associated with a TPM instance throughout the lifetime
# of the VM / VM configuration file. The instance number must be
# greater or equal to 1.
#vtpm = ['instance=%d,backend=0' % (vmid) ]

#----------------------------------------------------------------------------
# Set the kernel command line for the new domain.
# You only need to define the IP parameters and hostname if the domain's
# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
# You can use 'extra' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= ).

# Set if you want dhcp to allocate the IP address.
dhcp="off"
ip="192.168.%d.2" % (vmid)
# Set netmask.
netmask="255.255.255.0"
# Set default gateway.
gateway="192.168.%d.1" % (vmid)
# Set the hostname.
hostname= "domain-%d.xeno" % vmid

# Set root device.
root = "/dev/hda1 ro"

# Root device for nfs.
#root = "/dev/nfs"
# The nfs server.
#nfs_server = "10.212.4.103"
# Root directory on the nfs server.
#nfs_root = "/path/to/root/filesystem"

# Sets runlevel 4 and the device for /usr.
extra = "4 VMID=%d" % vmid

#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# In the event a domain stops due to a crash, you have the additional options:
#
# "coredump-destroy", meaning dump the crashed domain's core and then destroy;
# "coredump-restart', meaning dump the crashed domain's core and the restart.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'

#on_poweroff = 'destroy'
#on_reboot = 'restart'
#on_crash = 'restart'

#-----------------------------------------------------------------------------
# Configure PVSCSI devices:
#
#vscsi=[ 'PDEV, VDEV' ]
#
# PDEV gives physical SCSI device to be attached to specified guest
# domain by one of the following identifier format.
# - XX:XX:XX:XX (4-tuples with decimal notation which shows
# "host:channel:target:lun")
# - /dev/sdxx or sdx
# - /dev/stxx or stx
# - /dev/sgxx or sgx
# - result of 'scsi_id -gu -s'.
# ex. # scsi_id -gu -s /block/sdb
# 36000b5d0006a0000006a0257004c0000
#
# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as
# which the specified guest domain recognize.
#

#vscsi = [ '/dev/sdx, 0:0:0:0' ]

#============================================================================













































xmexample.hvm:
# -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================

import os, re
arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/usr/lib/xen/boot/hvmloader"

# The domain build function. HVM domain uses 'hvm'.
builder='hvm'

# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 128

# Shadow pagetable memory for the domain, in MB.
# If not explicictly set, xend will pick an appropriate value.
# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
# shadow_memory = 8

# A name for your domain. All domains must have different names.
name = "ExampleHVMDomain"

# 128-bit UUID for the domain. The default behavior is to generate a new UUID
# on each call to 'xm create'.
#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"

#-----------------------------------------------------------------------------
# The number of cpus guest platform has, default=1
#vcpus=1

# Enable/disable HVM guest PAE, default=1 (enabled)
#pae=1

# Enable/disable HVM guest ACPI, default=1 (enabled)
#acpi=1

# Enable/disable HVM APIC mode, default=1 (enabled)
# Note that this option is ignored if vcpus > 1
#apic=1

# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5
#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3

# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.
#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ]
# type=ioemu specify the NIC is an ioemu device not netfront
vif = [ 'type=ioemu, bridge=xenbr0' ]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.

#disk = [ 'phy:hda1,hda1,r' ]
disk = [ 'file:/var/images/min-el3-i386.img,hda,w', ',hdc:cdrom,r' ]

#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# In the event a domain stops due to a crash, you have the additional options:
#
# "coredump-destroy", meaning dump the crashed domain's core and then destroy;
# "coredump-restart', meaning dump the crashed domain's core and the restart.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'

#on_poweroff = 'destroy'
#on_reboot = 'restart'
#on_crash = 'restart'

#============================================================================

# Device Model to be used
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

#-----------------------------------------------------------------------------
# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
#boot="cda"

#-----------------------------------------------------------------------------
# write to temporary files instead of disk image files
#snapshot=1

#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=0

#----------------------------------------------------------------------------
# enable OpenGL for texture rendering inside the SDL window, default = 1
# valid only if sdl is enabled.
opengl=1

#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
vnc=1

#----------------------------------------------------------------------------
# address that should be listened on for the VNC server if vnc is set.
# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
#vnclisten="127.0.0.1"

#----------------------------------------------------------------------------
# set VNC display number, default = domid
#vncdisplay=1

#----------------------------------------------------------------------------
# try to find an unused port for the VNC server, default = 1
#vncunused=1

#----------------------------------------------------------------------------
# set password for domain's VNC console
# default is depents on vncpasswd in xend-config.sxp
vncpasswd=''

#----------------------------------------------------------------------------
# no graphics, use serial port
#nographic=0

#----------------------------------------------------------------------------
# enable stdvga, default = 0 (use cirrus logic device model)
stdvga=0

#-----------------------------------------------------------------------------
# serial port re-direct to pty deivce, /dev/pts/n
# then xm console or minicom can connect
serial='pty'


#-----------------------------------------------------------------------------
# Qemu Monitor, default is disable
# Use ctrl-alt-2 to connect
#monitor=1


#-----------------------------------------------------------------------------
# enable sound card support, [sb16|es1370|all|..,..], default none
#soundhw='sb16'


#-----------------------------------------------------------------------------
# set the real time clock to local time [default=0 i.e. set to utc]
#localtime=1


#-----------------------------------------------------------------------------
# set the real time clock offset in seconds [default=0 i.e. same as dom0]
#rtc_timeoffset=3600

#-----------------------------------------------------------------------------
# start in full screen
#full-screen=1


#-----------------------------------------------------------------------------
# Enable USB support (specific devices specified at runtime through the
# monitor window)
#usb=1

# Enable USB mouse support (only enable one of the following, `mouse' for
# PS/2 protocol relative mouse, `tablet' for
# absolute mouse)
#usbdevice='mouse'
#usbdevice='tablet'

#-----------------------------------------------------------------------------
# Set keyboard layout, default is en-us keyboard.
#keymap='ja'

#-----------------------------------------------------------------------------
# Configure guest CPUID responses:
#
#cpuid=[ '1:ecx=xxxxxxxxxxx00xxxxxxxxxxxxxxxxxxx,
# eax=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ]
# - Unset the SSE4 features (CPUID.1[ECX][20-19])
# - Default behaviour for all other bits in ECX And EAX registers.
#
# Each successive character represent a lesser-significant bit:
# '1' -> force the corresponding bit to 1
# '0' -> force to 0
# 'x' -> Get a safe value (pass through and mask with the default policy)
# 'k' -> pass through the host bit value
# 's' -> as 'k' but preserve across save/restore and migration
#
# Expose to the guest multi-core cpu instead of multiple processors
# Example for intel, expose a 8-core processor :
#cpuid=['1:edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx,
# ebx=xxxxxxxx00010000xxxxxxxxxxxxxxxx',
# '4,0:eax=001111xxxxxxxxxxxxxxxxxxxxxxxxxx']
# - CPUID.1[EDX][HT] : Enable HT
# - CPUID.1[EBX] : Number of vcpus * 2
# - CPUID.4,0[EAX] : Number of vcpus * 2 - 1
#vcpus=8
#
# Example for amd, expose a 5-core processor :
# cpuid = ['1:ebx=xxxxxxxx00001010xxxxxxxxxxxxxxxx,
# edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
# '0x80000001:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1x',
# '0x80000008:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx001001']
# - CPUID.1[EBX] : Threads per Core * Cores per Socket (2 * #vcpus)
# - CPUID.1[EDX][HT] : Enable HT
# - CPUID.0x80000001[CmpLegacy] : Use legacy method
# - CPUID.0x80000008[ECX] : #vcpus * 2 - 1
#vcpus=5
#
# Downgrade the cpuid to make a better compatibility for migration :
# Look like a generic 686 :
# cpuid = [ '0:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0',
# '1:eax=0x06b1,
# ecx=xxxxxxxxxx0000xx00xxx0000000xx0,
# edx=xx00000xxxxxxx0xxxxxxxxx0xxxxxx',
# '4:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0',
# '0x80000000:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0']
# with the highest leaf
# - CPUID.0[EAX] : Set the highest leaf
# - CPUID.1[EAX] : 686
# - CPUID.1[ECX] : Mask some features
# - CPUID.1[EDX] : Mask some features
# - CPUID.4 : Reply like the highest leaf, in our case CPUID.3
# - CPUID.0x80000000 : No extension we are on a Pentium III, reply like the
# highest leaf (CPUID.3).
#
# Configure host CPUID consistency checks, which must be satisfied for this
# VM to be allowed to run on this host's processor type:
#cpuid_check=[ '1:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx1xxxxx' ]
# - Host must have VMX feature flag set
#
# The format is similar to the above for 'cpuid':
# '1' -> the bit must be '1'
# '0' -> the bit must be '0'
# 'x' -> we don't care (do not check)
# 's' -> the bit must be the same as on the host that started this VM


#-----------------------------------------------------------------------------
# Configure PVSCSI devices:
#
#vscsi=[ 'PDEV, VDEV' ]
#
# PDEV gives physical SCSI device to be attached to specified guest
# domain by one of the following identifier format.
# - XX:XX:XX:XX (4-tuples with decimal notation which shows
# "host:channel:target:lun")
# - /dev/sdxx or sdx
# - /dev/stxx or stx
# - /dev/sgxx or sgx
# - result of 'scsi_id -gu -s'.
# ex. # scsi_id -gu -s /block/sdb
# 36000b5d0006a0000006a0257004c0000
#
# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as
# which the specified guest domain recognize.
#

#vscsi = [ '/dev/sdx, 0:0:0:0' ]




















































xmexample.hvm-dm:
# Not to be started directly,
# See xmexample.hvm-stubdom and stubdom/README for more details

kernel = "/usr/lib/xen/boot/ioemu-stubdom.gz"

# Must be the same as in xmexample.hvm-stubdom, with a prepended vif for TCP/IP
# networking in the stubdomain itself, here just ''
vif = [ '', 'type=ioemu, bridge=xenbr0' ]

# Set here instead of in xmexample.hvm-stubdom
disk = [ 'file:/var/images/min-el3-i386.img,hda,w', ',hdc:cdrom,r' ]

# Actual output via PVFB
vfb = [ 'type=sdl' ]

Labels: ,

Wednesday, December 17, 2008

Google bookmarks的一个小"bug"

今天发现了Google bookmarks的一个小bug:URL为FTP站点时不能在Google工具栏的bookmarks中显示!
后来想给点反馈,点击http://www.google.com/notebook/bookmarks......页面左下角的Feedback链接(http://www.google.com/support/notebook/bin/request.py?contact_type=notebooksurvey)后,说是页面找不着:
Error 404
Not Found
这我就没办法了。。。


后记:
Google bookmarks不支持二级目录
也是一点小遗憾

Labels:

Monday, December 15, 2008

ping的通IP但解析不了域名的解决

今天又碰到ping的通IP,但解析不了域名的问题,最后发现是防火墙的问题。
先前进入物理机上的系统,可以正常上网,但从Xen启动进入Domain0后,发现上述问题。
开始怀疑是DNS配置问题,但DNS配置确实又没问题。后来想到了防火墙,看了下设置,确实没屏蔽端口,把服务器上的iptables的配置文件拷贝过来还是不行(服务器装的系统一样是rhel5,iptables的设置也差不多,只不过是64位的,而这里是32位的),但不管是服务器上的iptables配置还是原有的iptables配置,iptables -F后(清除所有规则,使iptables失效)就没问题了,这时就确定是iptables的问题了。
后来又想到了DNS,是不是iptables把DNS的端口给封了呢?于是把iptables的规则中加入了DNS端口(53端口,tcp和udp两种情况)的accept,重启iptables后果然可以!果然是iptables把DNS端口给封了。
现在搞不懂的是iptables明明没有封DNS端口的规则,为什么实际上就把它给封了呢?而且服务器同样是rhel5,只不过是64位,iptables也没封DNS的规则,也可以正常上网,换到这里的32位rhel5,就不行了。。。
可能是默认规则不一样吧:64位上的iptables默认把DNS打开,而32位机的iptables默认把DNS端口封掉。


后记:
今天碰巧又碰到了同样问题,装一个hvm的OpenSolaris,结果ping的通IP但就是解析不了域名,后来干其它事时把iptables关了,于是就可以上网了。后来在iptables中把dns的53号端口(udp和tcp)打开后也可以了。
这里有几个奇怪的地方:
1. Domain0默认可以上网,但DomainU的OpenSolaris的hvm默认上不了网,只有强制打开53端口才行;
2. 前段时间另一台机子的Domain0默认也把dns端口封了,但这里的服务器的Domain0默认却开了。

Labels: ,

Sunday, December 14, 2008

系统服务启动项管理命令

rc里的系统启动项可以手动添加、删除,但感觉这样还是不安全,于是可以用专门的管理工具来修改,例如chkconfig。chkconfig是redhat系常用工具,而在Debian系则有所不同,下面具体的讲。

有update-rc.d、sysvconfig、sysv-rc-conf、bum、rcconf等。rcconf是个小工具,就不说了;sysvconfig(Ubuntu7.04默认)比sysv-rc-conf(Ubuntu7.10默认)更强大但没有sysv-rc-conf直接,二者都是update-rc.d的功能集成,是其继承与加强,有趣的是update-rc.d的man推荐系统管理员不要用该命令,而用sysv-rc-conf和bum代替;以后有机会要好好学下sysv-rc-conf。

Labels: ,

Ctrl+S锁键盘和Ctrl+Q解锁

刚才用putty登录到服务器上时,突然发现不能输入了,第一反应是怀疑和服务器的连接断开了,但发现不是,于是想到是键盘被锁。于是搜索了一下,使用Ctrl+Q顺利解锁,这才发现,原来远程登录也可以用Ctrl+S和Ctrl+Q加解锁。
p.s.
后又用Scroll Lock键试了下,不行:还是主键盘区可靠啊!

Labels: ,

inittab文件

用inittab文件自己的话说,该文件的作用是:
This file describes how the INIT process should set up the system in a certain run-level.
在这个文件中,解释了0到6这几个不同runlevel的含义。而且定义了Ctrl+Alt+Del快捷键,定义了系统启动时启动哪几个tty(一般是6个),也定义了在哪个runlevel启动时运行xdm(X display manager,系统登录时的那个图形界面,这样在登录前就有图形界面了,不用登录后再startx)。

除此之外,它里面还定义了从哪个runlevel启动,所以需要改为从文本界面或图形界面启动时,直接在这个里面改个数字即可(当然,启动时在grub里交互式修改也行,或者直接在rcX.d文件夹中添加或删除gdm、kdm、xdm等相关选项即可,抑或用命令init 3、init 5等直接切换)。

注:redhat系有该文件,Debian、Gentoo也都用inittab,Ubuntu在6.10前也有,只是之后就用upstart包代替了initscripts包,主要脚本都在/etc/event.d/下,但仍然和inittab格式兼容。

Labels: ,

Saturday, December 13, 2008

firefox插件ubiquity

刚试用了下vimperator,很不错的;接着又试用了下ubiquity插件,感觉对于非专业人士还行,但对于学计算机的人来说不太实用。
ubiquity装上后,选择想要处理的词组或URL或一段文字,然后使用ubiquity的快捷键(默认为Ctrl+Space)启动ubiquity,这时会弹出一个菜单,下面有wikipedia、Google、Amazon等的选项,选中一个后会进行相应的处理,如选中Google会在Google中搜索前面选中的关键词,也可以直接把选中的部分email给别人,或者把在地图中搜索的结果的截图保存下来。
这个东西说白了就是把常用的一些操作又重新组织了一次,按照ubiquity的方式给用户呈现出来,让普通用户感觉更简单、更方便;但对于专业人员来说,那些操作本来就小儿科,这个便利器实属冗余,感兴趣时体验一下即可。

Labels: ,

强大的vimperator

刚装上了word的vim插件ViEmu,又想起了firefox也有vim插件,于是重新装上vimperator体验了一把,感觉确实很不错。
几乎所有的操作都可以在键盘区完成,vim原有的快捷键都可以使用,需要帮助时直接在命令模式下输入help。自带的help有好几个主题,很全。
默认没菜单栏、工具栏、书签栏,可以用命令set guioptions+=mTb(或go+=mTb)显示,其中m代表menu,T代表Tool,b代表bookmark(可用set go=来隐藏mTb)。可以在 ~/.vimperator或~/_vimperator中加上这些命令,以便在每次启动时都执行,mkvimperatorrc或mkv可以保存当前设置;而使用Ctrl+Z命令可切换到firefox快捷键模式,使vimperator的快捷键失效,按ESC后退出。
复制可用Ctrl+Ins,剪切是Shift+Del,粘贴是Shift+Ins。当然用Ctrl+Z返回以前的快捷键模式也可以用以前的快捷键进行剪切、复制和粘贴。
此外,还有快捷键o(open)和t(tabopen);而当一个页面上有很多链接时,直接f,vimperator就自动将这些链接表上号码,输入相应的号码即可跳转到相应页面,而大写F则是在后台用新标签打开页面,比f更实用;关闭页面直接d,误关可用u重新打开,这两个相当于firefox的Ctrl+W和Ctrl+Shift+T快捷键;



后记1:
vimperator确实还可以,help说明很系统很全面,而老版本vimperator的help则更直接,所有命令都在第一页,让人一目了然。
但viemu for word不怎么样,主要是中英文切换麻烦:在normal模式下想输入命令还要切换到英文输入法,vimperator就没这个麻烦,normal模式下无需切换输入法就可以进入命令模式输入命令。刚才一怒之下卸载之,如果哪一天viemu改进了再用 :-)

后记2:
今天,由于机器的原因,不得不改用一个占用内存小的浏览器,找了半天,还是决定采用一个主流浏览器,一个用顺了手的浏览器:firefox2。这样的话,vimperator只能降级到0.5.3版本,发现这个版本和viemu有个共同的缺点:输入命令时需要切换为英文输入法(firefox3下的版本即时用中文输入法也没关系),有点不方便。。。。。。

Labels: ,

Xvnc:X和vnc的结合

vnc原本只有vnc服务器端vncserver和vnc客户端vncclient以及二者之间的通信协议,服务器把framebuffer中的一帧矩形图像压缩后传给客户端(可通过ssh对其加密,有的商业vnc软件也加入了加密的插件),客户端收到并处理后在显示器上显示出来。
但是后来的vnc又发展了一步:将vncserver和Xserver绑定。

顺便说说X。X包括服务器端和客户端。X服务器端连接显示器和键盘鼠标,在用户这一边;客户端不一定在本地,每个应用程序包括网络应用程序在内都可以是一个客户端。输入输出设备,包括鼠标键盘显示器都与X server交互,而X server则和X client交互。

现在通常所说的vncserver估计就是Xvnc,是把一个vncserver和一个Xserver绑定在一起的产物。X客户端的各个应用程序和Xvnc连着,而Xvnc和vnc client连着,这里的Xvnc既充当了X server的角色,又承担着vncserver的角色。

平时碰到的vnc,有的是包括本地用户和远程用户在内的多个用户同时控制一个桌面,好比Windows里的远程桌面,而有的是每个远程用户都有自己独立的桌面,例如开启的vncserver服务。我个人认为前者应属于真正意义上的vnc,只是简单的把一个桌面的图像发送给多个远程的vnc client,而vnc client又把远程的输入传送到本地的vncserver;后者则属于Xvnc,每个vncserver都对应着一个X server,用“ps -e|grep X”查看进程信息,就可以看到有Xvnc进程存在。Xvnc的好处是对多用户操作系统来说,一台机器可以运行多个桌面,每个用户可以有自己的一个或多个桌面,用户之间互不影响;而传统vnc也有其有点:只有一个X,消耗资源少,而且多个用户可以协同操作(当然Xvnc也可以,例如vncserver,但有的好像又不行,例如商业软件RealVNC)。

Labels: ,

Friday, December 12, 2008

烦人的DHCP和dhcdbd服务

今天发现Linux服务器不能访问,发现eth1的IP被改了,于是就停掉了eth1,留下eth0继续运行。重启网络后发现还是不能访问,这才发现eth1还在,而且其IP很离谱,这才怀疑是DHCP服务对其进行了自动配置,以前也碰到过这个问题。
ps -e|grep dh后发现有个dhcdbd的进程,查了下,果然和DHCP有关,man给的解释是
dhcdbd - program to return dhcp configuration
于是查看了/etc/rc2.d/(runlevel为2),果然有S24dhcdbd,删除之,停掉eth1后重启网络
OK

Labels: ,

Thursday, December 11, 2008

面试

12月9号到浙江移动面了一下,又当了一次炮灰。
开始说要带3方协议,还以为希望很大,结果一去,情况与所想的截然相反。
有3个职位,分别有19、63、53参加,最后招了3*3。
和我同一天参加面试的有一个北大的,一个英国回来的海归,一个华南理工和纽约什么什么大学联合培养的博士,第二天面的还有个清华的。
参加面试的基本上是985,除了一个河北保定什么什么大学的。
北大的以前在大连理工,说是以第一名成绩保送到北大,后来研究生阶段又是第一,而且没见过爸妈,是养父带大的。另一个浙大软件工程的硕士说是研究生阶段第二,到IBM和网新实习过。那个海归说专门为面试回来,过两天还要会英国参加毕业典礼,其导师是什么什么会议的会长。感觉都很扯淡,都在忽悠,至少含有忽悠的成分。一个浙江移动有这么大吸引力吗?这么牛,到现在还在找工作?
浙江移动也真扯淡,就招这么几个人,把全国各地985的人搞过去当炮灰,想显示他们有多么牛吗?
这么大个公司,只对外招3*3个吗?名额都哪去了呀?

p.s.最后从酒店门口刚出来时,有一辆宝马正倒车,好像没看到后面有我们3个人,顶着我右手边一个武大的行李箱倒车,我们后退了好几步,差点就轧到人了,等我们让开后,司机若无其事的继续开。。。 杭州--有钱人的天堂。。。

Labels:

修改自己的hostname

在Linux里的命令提示符中,很多系统都会显示主机名,可以手动把主机名修改成自己想要的,看起来舒服。可以临时修改(立即生效,重启后失效)也可以永久性修改(重启之后生效)。

临时修改使用hostname命令,如“hostname cs”,重新登录后就可以看到主机名改变了。这个命令可以放在rc.local中,每次启动都运行(我不喜欢这样)。
临时修改还可以直接echo new-hostname > /proc/sys/kernel/hostname,估计hostname的原理和这个一样。

对于永久性修改,需要在文件中修改。
在Ubuntu中直接在/etc/hostname中修改即可(该文件保存的就是主机名)。
对于rhel5系统则在/etc/sysconfig/network中修改hostname一行。
修改后重启即可。

p.s.
修改该hostname只是对本地主机名进行的修改,而在/etc/hosts(该文件是作IP映射用的,只给本地系统用)中对127.0.0.1对应的行进行修改是针对域名解析的。例如在该文件中加入127.0.0.1 cs一行后,直接用ssh cs即可登录本机,因为在解析cs的时候一般是按照先本地后DNS的顺序,而本地把cs解释为127.0.0.1。

Labels: ,

命令提示符(PS1)的设置

刚才设置了一下PS1命令提示符。
在rhel5中的 ~/.bashrc 中加入了一句:
PS1="\u@\h \w\$ "
将/etc/下的全局设置覆盖掉,.或source一下就可以了
其中“\u”代表username,“\h”代表hostname,而“\w”代表workplace。(这都是我猜的)
有的系统默认的是“\W”,大写W显示的是当前所在文件夹,而小写w显示当前完整的路径。

p.s.
我的Ubuntu系统中命令提示符是这样设置的:
case "$TERM" in
xterm-color)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
;;
*)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
;;
esac

Labels: ,

Wednesday, December 3, 2008

samba服务配置尝试

以前曾经配置过samba,这次重新尝试,不太成功:Windows下可以访问,但一登录上去就不知道怎么断开了,以后就一直可以连上了,更糟糕的是Linux下怎么都访问不了。以下是配置细节:
在/etc/samba/smb.conf中按照示例添加几行:
注意:要是没有/etc/samba/smb.conf这个文件,则输入smb相关的所有命令都不管用了
[sharename] ;显示的文件夹名
comment = Insert a comment here
path = /home/share/ ;文件夹路径
valid users = tfox carole ;用户名
public = no
writable = yes ;是否可写
printable = no
create mask = 0765 ;只有writable设置了这一步才有效
创建密码文件并修改读写权限
cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd
chmod 600 /etc/samba/smbpasswd
接下来可以用smbpasswd命令来修改密码(必须root,应为刚把读写权限设为600)
smbpasswd username
再加上这两行
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd

这样在Windows中访问可以Win+R后输入"\\yourIP"回车后即可(如果有用户名和密码则接下来输入用户名和密码)。
以上是直接在配置文件中修改,也可以用有图形界面的工具修改。

后记:
今天又看了下UC上提供下载的一个Linux配置教程,其中是这样配置samba的:
在samba.conf中先设置
workgroup = student
然后设置hosts allow = 192.168.16.
接下来interfaces = eth0
最后重启服务

Labels: ,

Tuesday, December 2, 2008

UC登录后不同系统共用存储区域

登录UC的任一台机子,看见的都是同一个存储空间,
所用技术:身份验证LDAP,存储NFS

Labels: ,

xen之domU的安装尝试

以前版本的xen对Dom0和DomU的内核是有区分的:Dom0中只有后端驱动,DomU中只有前端驱动。而现在xen编译出的内核既含后端驱动又含前端驱动,对Dom0和DomU来说都是通用的,再加上内核只是被读取到内存而无写操作,所以一个系统中的所有Dom都可以共用一个内核文件而不冲突。
BTW:xen.org上提供的Archives的下载对Dom0和DomU进行了区分,都是经过裁剪的内核,注意,DomU的下载提供的仅仅是一个内核和相关文档或源码。
基于以上原因,内核就没自己安装了,干脆用Dom0的。

下一步就是制作磁盘镜像,包括一个ext3的和一个swap的。有3中方式:一种是直接建立镜像文件,另一种是直接利用物理磁盘,最后一种是压缩的方式(没仔细研究,Running Xen一书上有讲解)。这里采用的方法是建立磁盘镜像文件。
注意,swap在Xen的manual上没提到,不要忘记自己做一个!
按照Xen的manual,首先用命令
dd if=/dev/zero of=vmd01 bs=1k seek=40M count=1
建一个40G大小的空文件:这一步很快,用ll看其属性则为40G而du -sh看则为16K
第二步再用命令mkfs -t ext3 vmd01将其格式化为ext3格式(mkfs.ext3也一样)(swap格式用mkswap命令后面加上待格式化文件的文件名),这一步要慢一点,用ll看其属性仍为40G,而du -sh看其属性则为778M
BTW:由此可见,这里的dd命令建立的磁盘镜像文件的大小是随着其内容增加而动态增长的;后来用命令dd if=/dev/zero of=./vmdisk count=4000 bs=1M,则建立的文件大小在开始就固定了,里面不管有没有东西都把空间占着!
按照同样的方法建立swap文件
注意:jailtime.org上有很多已经做好的镜像文件,而且都是经过裁剪的,很小,可以直接下载拿来用。

第三步,把镜像文件挂载上来,往里面拷东西。命令:
mount -o loop vmd01 /mnt
cp -ax /{root,dev,var,etc,usr,bin,sbin,lib} /mnt
mkdir /mnt/{proc,sys,home,tmp}
umount /mnt
注意:
1. 以上操作后文件的属性,尤其是所有者。根目录下的文件所有者都是root,如果用普通用户去执行以上操作会使镜像中文件的所有者不为root,所以操作时要加上sudo。如果不加也可以,那么进入系统后相应文件夹的所有者就为那个普通用户,不安全!
2. 在我们的服务器上还有个lib64文件夹(系统是64位的),没有拷,启动时报错:
exec of init (/sbin/init) failed!!!: No such file or directory
后来把/lib64和/selinux一起拷进去再启动就OK了

接下来就是写配置文件了,里面把相关配置写好,用命令
xm create -c test.cfg
就可以启动了
xm list列出所有虚拟机的信息
xm shutdown关闭虚拟机(在虚拟机内部用shutdown now并不能关机)
xm destroy强行关机
注:
1. 配置文件中设置的IP是实际启动后的IP,镜像文件中的配置不管用!镜像文件中的配置文件/etc/sysconfig/network-scripts/ifcfg-eth0和/etc/sysconfig/network-scripts/ifcfg-eth1都被加上了一个后缀".bak"!
2. 配置文件中的disk选项只是把相应的镜像文件挂到像/dev/sda1这样的设备上,而系统中的配置文件/etc/fstab则是把/dev/中的设备映射到相应目录中。

下面来show一下我的配置文件(从jailtime.org下载的Debian的配置修改后所得,后来做了一个rhel5的和这个类似):
kernel = "/boot/vmlinuz-2.6-xen"
ramdisk = "/boot/initrd-2.6.18.8-xen.img"
memory = 256
name = "debian.3-1"
vif = [ '' ]
#dhcp = "dhcp"
ip = "192.168.205.45"
netmask = "255.255.255.0"
gateway = "192.168.205.1"
disk = ['file:/home/cs/xen/images/debian/debian.3-1.img,sda1,w', 'file:/home/cs/xen/images/debian/debian.swap,sda2,w']
root = "/dev/sda1 ro"

以上是PV方式的磁盘文件镜像方式,而VT虚拟机的配置据说是把一个安装文件的iso往磁盘镜像文件里一扔,启动时就自动从光驱启动,把iso加载上,直接安装就可以了。VT我自己还没尝试,而且利用物理磁盘的方式和压缩方式都还没有尝试过,有时间亲手安装一次再把详细过程贴出来。


后记1:
用du -sh和ls -sh看所占空间大小是准确的,二者是一致的,而用ls -l是不准的

后记2:
以上是对于单个文件来说的
而对于文件夹来说,du -sh是看所占空间的,而ls -sh 和 ls -l 只是显示文件夹大小16K

Labels: ,