Techyou labs
真正的爱应该超越生命的长度,心灵的宽度,灵魂的深度
常用标签
您正在查看:2011年8月
August 25, 2011

HTTP协议有一种分块传输编码的机制(Chunked Transfer Encoding),即一个HTTP消息可以分成多个部分进行传输。它对HTTP请求和HTTP响应都是适用的, 我们在作这样一个项目的时候就遇到了这样的问题:J2ME作的客户端,server端是rails,但J2ME发送的HTTP request 的header Transfer-Encoding: chunked,即是以块传输的,Rails接受这样的数据有问题(报错:negative length -27 given),所以需要编译Nginx的时候处理下,要编译chunkin-nginx-module模块:


wget http://github.com/agentzh/chunkin-nginx-module/tarball/v0.21
tar zxvf agentzh-chunkin-nginx-module-cb610a5.tar.gz

然后再:


[root@li96-10 nginx-0.7.65]# ./configure --prefix=/usr/local/system/nginx --with-openssl=/usr/include --with-pcre=/usr/local/lib --with-http_stub_status_module --with-http_realip_module --add-module=/root/src/agentzh-chunkin-nginx-module-cb610a5
[root@li96-10 nginx-0.7.65]# vim objs/Makefile
./configure --disable-shared #注释掉这行内容
[root@li96-10 nginx-0.7.65]# make
[root@li96-10 nginx-0.7.65]# make install</code>

August 24, 2011

环境:Scientific Linux 6.1 64bitKVM:qemu-kvm-0.12.1.2

问题:1:迁移kvm的时候遇到的。在源机器上,镜像文件实际占用的空间和申请空间是不一样的。但cp镜像文件到新机器,发现就直接把申请空间当占用空间了。解决:cp --sparse=always 2:虚拟机的镜像路径改动过。启动不了 error: unable to set security context 'system_u:object_r:svirt_image_t:s0:c56,c391' on '/data/vmachines/ubuntu.luo.img': No such file or directory

系统默认会在/var/lib/libvirt/下面保存数据~so,删掉/var/lib/libvirt/qemu/save下面的东东即可(当然会丢失数据)

完美的解决办法:先关掉虚拟机。再重新启动

参考:http://www.ibm.com/developerworks/cn/linux/l-cn-mgrtvm2/index.html
一些KVM的工具集https://github.com/ghoneycutt/puppet-kvm
https://github.com/aidanshribman/qemu-kvm
https://github.com/ptman/kvmmgr
https://github.com/lvidarte/kvmctl
https://github.com/jagane/qemu-kvm-livebackup
https://github.com/serverhorror/python-kvmctl
https://github.com/tstafford/Simple-image-based-kvm-virsh-backup-scrip
thttp://stefan.hoefer.ch/node/3

./configure: 12667: 5: Bad file descriptor
./configure: 12667: :: checking for dirent.h that defines DIR: not found
./configure: 12667: 6: Bad file descriptor
./configure: 12667: checking for dirent.h that defines DIR... : not found
eval: 1: Bad substitution

默认的autoconf版本太高,2.64。
解决办法:安装autoconf2.13版本
参考:http://forum.nginx.org/read.php?3,64091,87800

SSH 是一个强大且安全的工具,我们除了可以用它来远程管理主机外,还可以通过它建立 SSH tunnel 作 Proxy 用,远程传输文件等等。而这里我想要介绍另外一个功能,那就是结合 sshfs 这个工具可以把远程主机的文件系统映射到本地主机上,透过 SSH 把远程文件系统挂载到本机上,这样我们可以不必使用 scp 工具就可以做到直接复制及删除远程主机的文件了,就像操作本地磁盘一样方便。
sshfs 是基于 FUSE 构建的 SSH 文件系统客户端程序,通过它远程主机的配置无需作任何改变,就可以透过 SSH 协议来挂载远程文件系统了,非常方便及安全。
主页:http://fuse.sourceforge.net/sshfs.html

Ubuntu 上安装:
sudo apt-get install sshfs
挂载远程 ssh 文件系统:
sshfs -o transform_symlinks -o follow_symlinks user@hostname: /home/username/sshfs
-o transform_symlinks 表示转换绝对链接符号为相对链接符号 
-o follow_symlinks 沿用服务器上的链接符号

更多参数请 man sshfs ,如果碰到其它问题请参考官方的 FAQ 。
如果你想不输入密码的话,请使用 SSH key 认证方式。
执行命令后 Ubuntu 会自动在桌面上显示挂载的 sshfs 文件系统盘,现在你就可以像操作本地磁盘一样操作这个映射的磁盘了。
PS: 其实 FreeBSD 上也有此工具,Ports : /usr/ports/sysutils/fusefs-sshfs