hypervm 修改ip地址

[不指定 2009/09/23 19:28 | by suibing ]
hypervm修改了ip地址会报错了,只要运行下面的代码就好了



/script/change-slave-id old-id new-id (with correct ips)


then server home -> ipaddress and re-read ip

给CentOS添加常用软件的源

[不指定 2009/09/23 11:01 | by suibing ]
刚刚装好CentOS后随便玩了玩,感觉她就像一个不懂风趣的老头,沉稳,安静但是一点都不幽默。系统安全性能很好,原生的中文支持就很好,中文字体也很漂亮,KDE的界面也很美观。做服务器和开发的工具齐全,但是娱乐性太差了,想听一听歌,没有一个好的音乐播放器,也没有MP3解码器,看视频也是。更新源里的软件好少,而且还大多是开发库的库文件和参考文档。好一个古板的老头!
        上网搜了搜,找到解决方案。让CentOS立刻活泼了起来!很多软件都可以用yum来安装了!
        http://wiki.centos.org/AdditionalResources/Repositories/RPMForge
        这个网站是英文的,我把翻译过来贴在这里,如果我的翻译于该网页有悖,以原文为准。

译文:
安装RPMForge

以root用户运行命令
yum install yum-priorities
然后编辑/etc/yum/pluginconf.d/priorities.conf文件,确保其中有:
[main]
enabled=1
然后编辑/etc/yum.repos.d/目录下所有的.repo文件
给所有更新源加上优先级: priority=N
例如我的repo文件:

[base]
name=CentOS-$releasever - Base
baseurl=http://centos.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
priority=1

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://centos.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
priority=1

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://centos.ustc.edu.cn/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://centos.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://centos.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
priority=2

然后下载RPMForge的安装包:
i386: http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
x86_64: http//apt.sw.be/redhat/el5/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
根据自己电脑型号选择,我的是i386,64位机请选择x86_64

用下面的命令下载公钥
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

检查自己所下载的安装包
rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm
*为i386或者x86_64,各人下载的不同。

安装软件包
rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm

刷新软件库
yum check-update

接下来就可以安装自己想要的软件了,例如我想听歌,就安装XMMS和MP3、WMA解码器。
yum -y install xmms xmms-mp3 xmms-wma

HAVE FUN!

TIPS:
解决XMMS播放列表乱码问题

在xmms主窗口点右键->选项->首选项,在字体选项卡中,把播放清单和主窗口都换成下面的:
-adobe-helvetica-medium-r-normal-*-16-*-*-*-p-*-iso8859-1,-*-*-medium-r-normal--16-*-*-*-*-*-gb2312.1980-0

在标题选项卡中,把标题格式改为%f的格式

安装hypervm可能遇到的问题

[不指定 2009/09/22 23:23 | by suibing ]
hypervm还是管理虚拟机的最佳帮手,尽管目前漏洞可能还有,不过只要不公布也没关系了,哈哈

下面是安装hypervm的一些条件和可能遇到的问题

这些问题经常遇到的,还是记录一下的好

好在我已经在本地建立lxlabs系列的全部镜像了

Note: Although the notes below will fall under recommended best practices for installing your server, they are mandatory only if you are installing Xen, and if you are planning on installing openvz, then you can skip them without any issue.


The boot loader must be grub. Grub is a much more flexible and mature boot loader, and it is actually a good idea to use it rather than lilo.
There must be a separate /boot partition. You can assign it 200MB.
You should use LVM.The recommended disk configuration is:

/boot /dev/hda1 (500MB)
/ /dev/mapper/vol00-root (8GB)
swap /dev/mapper/vol00-swap (1GB)



The above are just minimum configurations, and you can extend them whenever they get full.

HyperVM will automatically detect your xen configuration and will set the driver to xen and also add the existing LVMs in the system to the xen locations. Just make sure that you are running xen and the Volume Groups have been added by going to server home -> location home .

On fedora 6/centos 5, you will need to run the following for xen to work properly. This is because xen on fedora 6/centos 5 is broken and the default initrd will not function.

---------

cd /usr/local/lxlabs/hypervm/httpdocs/

lphp.exe ../bin/misc/fixfc6xen.php

----------

---------

cd /usr/local/lxlabs/hypervm/httpdocs/

lphp.exe ../bin/misc/fixcentos5xen.php

----------

If hyperVM didn't automatically recognize the xen driver, you can run the command below to forcibly set it.

-------------

cd /usr/local/lxlabs/hypervm/httpdocs/

lphp.exe ../bin/common/setdriver.php --server=localhost --class=vps --driver=xen

-------------

If you switch the kernel at any point later, you will have to run the above commands again.

HyperVM will automatically set the driver for the server if you install it as xen. But if by any chance, the driver fails to get set at the install time, you can always set it later by running the command below.

---------

cd /usr/local/lxlabs/hypervm/httpdocs/

lphp.exe ../bin/common/setdriver.php --server=localhost --class=vps --driver=xen

----------
一、下载相关的rpm 软件包:

http://www.gitco.de/repo/xen3.3.0/

libvirt-0.4.4-3.x86_64.rpm
libvirt-devel-0.4.4-3.x86_64.rpm
libvirt-python-0.4.4-3.x86_64.rpm
xen-3.3.0-2.x86_64.rpm
xen-devel-3.3.0-2.x86_64.rpm
xen-libs-3.3.0-2.x86_64.rpm

二、创建新的repo 更新源:

#vi /etc/yum.repos.d/XEN.repo
[xen]
name=CentOS-$releasever - XEN
baseurl=http://www.gitco.de/repo/xen3.3.0
gpgcheck=0  

三、 yum 命令就搞定了:

[root@huilin]# yum install xen-3.3.0-2.x86_64.rpm xen-devel-3.3.0-2.x86_64.rpm  
xen-libs-3.3.0-2.x86_64.rpm libvirt-0.4.4-3.x86_64.rpm libvirt-devel-0.4.4-3.x86_64.rpm libvirt-python-0.4.4-3.x86_64.rpm

下一步安装图形界面管理工具:
[root@huilin]#rpm -ivh gnome-python2-gnomekeyring-2.16.0-1.fc6.x86_64.rpm
[root@huilin]#rpm -ivh virt-manager-0.4.0-3.el5.x86_64.rpm

ok 到此结束!!

xen 3.3 改进不少呢  呵呵!

最近这个站点有更新了已经是xen 3.4 了 呵呵,还没有来得及去测试呢!!! 希望大家也去看看哦!!!

xen3.4 安装文档

[不指定 2009/09/22 15:19 | by suibing ]
xen3.4 安装文档

下了包http://bits.xensource.com/oss-xen/release/3.4.0/xen-3.4.0-xen.tar.gz。编译老出错,哎,看了看readme
需要很多包,不过写的不详细,也罢。先把用户文档弄出来吧
make -C docs
god,又缺少包。google了一下。需要tetex-latex,ghostscript
yum install 安装之
真是麻烦,网上说可以用现成的源。那就配吧
http://www.php-oa.com/2009/03/18/xen33_centos52.html

Redhat官方提供的XEN只有3.0.1很老了.想换成最新的.下面的这个网站,给最新的打包了.直接放到repo中,就可以
安装了
wget http://www.gitco.de/repo/CentOS5-GITCO_x86_64.repo
放到/etc/yum.repos.d/下面.
然后直接运行下面的命令安装
#yum groupinstall Virtualization
如果要删除的话
#yum groupremove Virtualization
不过这样安装一点成就感也没有
还是源码编译一个最新的3.4吧(我是不是有毛病啊)

如果从网络安装只需要下载一个包就可以了
http://bits.xensource.com/oss-xen/release/3.4.0/xen-3.4.0-xen.tar.gz

如果无法联网,那么还需要下载第3个包。
http://bits.xensource.com/oss-xen/release/3.4.0/xen-3.4.0.tar.gz

再次make world
这次 又出错,依然是没有命令hg
还需要mercurial
yum install mercurial
继续,依然缺少X11 header
怒了yum install libX11-devel
或者修改源码,tools/check/check_x11_devel
注释掉
has_header X11/keysymdef.h || \
has_header /usr/X11R6/include/X11/keysymdef.h || \
fail "can't find X11 headers"
总算好了,不过还有一个警告,提示缺最后一个包。god,为了完美,还是补上吧。
yum install transfig

如果提示gpg: public key not found
执行
gpg --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E
然后继续make dist
如果不能下载key,那么可以手动导入key
从浏览器访问
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x517D0F0E
保存到一个文件,如key.asc
pgp --import key.asc
然后就可以了




三、在Xen3.3中安装虚拟CentOS

1.虚拟系统的安装 可以从网络安装(受速度的限制会很慢),也可以从镜像安装(不知道是否支持光盘安装),
我们采用从镜像的ISO安装。
2.在网站上下载CentOS的镜像,保存到宿主机的一个制定目录:/root /ISO /CentOS5.2.iso
3.用命令 dd if=/dev/zero of=~/vm/vm1.img bs=1k seek=15M count=1 创建一个磁盘镜像,名字为vm1.img,该
镜像会被虚拟机当硬盘使用,其大小为15G。该命令创建的磁盘大小会随着其内内容的增加而变化。
4.创建一个该虚拟系统对应的配置文件,该文件创建位置为~/vm/vm1.cfg,该文件用来设置虚拟系统的启动、网
络、内存、CPU个数等。实例说明如下:
1. im
port os, re
2. ar
ch = os.uname()[4]
3. if
re.search('64', arch):
4.
arch_libdir = 'lib64'
5. el
se:
6.
arch_libdir = 'lib'
7. #
Kernel image file.
8. ke
rnel = "/usr/lib/xen/boot/hvmloader"
9. #
The domain build function. HVM domain uses 'hvm'.
10. bu
ilder='hvm'
11. #
Initial memory allocation (in megabytes) for the new domain.
12. #
13. #
WARNING: Creating a domain with insufficient memory may cause out of
14. #
memory errors. The domain needs enough memory to boot kernel
15. #
and modules. Allocating less than 32MBs is not recommended.
16. #内存大小设置为
512M
17. me
mory = 512
18. #A
name for your domain. All domains must have different names.
19. #虚拟机的名字为
vm1
20. na
me = "vm1"
21. #
The number of cpus guest platform. has, default=1
22. #
虚拟CPU的个数为1
23. vc
pus=1
24. #
Optionally define mac and/or bridge for the network interfaces.
25. #
MACs are not same for VMs.
26. vi
f = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ]
27. #
type=ioemu specify the NIC is an ioemu device not netfront
28. #v
if = [ 'type=ioemu, bridge=xenbr0' ]
29. #网卡使用
eth0物理网卡
30. #v
if = [ 'type=ioemu, bridge=eth0' ]
31. #
Define the disk devices you want the domain to have access to, and
32. #
what you want them accessible as.
33. #
Each disk entry is of the form. phy:UNAME,DEV,MODE
34. #
where UNAME is the device, DEV is the device name the domain will see,
35. #
and MODE is r for read-only, w for read-write.
36. #磁盘镜像文件使
用file:/root/vm/vm1.img,同时把file: /root/ISO/CentOS5.2.iso当作光驱使用。
37. di
sk = [ 'file:/root/vm/vm1.img,hda,w', 'file:/root/ISO/CentOS5.2.iso’]
38. #
Device Model to be used
39. de
vice_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
40. #
boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d)
41. # default:
hard disk, cd-rom, floppy(默认顺序)
42. #b
oot="cda"
43. #设置为从光驱启
动(首次安装时选择光驱启动)
44. bo
ot="d"
45. #
enable SDL library for graphics, default = 0
46. sd
l=0
47. #
enable OpenGL for texture rendering inside the SDL window, default = 1
48. #
valid only if sdl is enabled.
49. op
engl=1
50. #
enable VNC library for graphics, default = 1
51. #启动后通过
vnc连接访问其图形界面
52. vn
c=1
53. #
address that should be listened on for the VNC server if vnc is set.
54. #
default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
55. #允许任何
IP使用vnc服务
56. vn
clisten="0.0.0.0"
57. #
set VNC display number, default = domid
58. #v
ncdisplay=1
59. #
try to find an unused port for the VNC server, default = 1
60. #v
ncunused=1
61. #
set password for domain's VNC console
62. #
default is depents on vncpasswd in xend-config.sxp
63. #没有设置
vnc密码
64. vn
cpasswd=''
65. #
enable stdvga, default = 0 (use cirrus logic device model)
66. st
dvga=0
67. #
serial port re-direct to pty deivce, /dev/pts/n
68. #
then xm console or minicom can connect
69. se
rial='pty'
5.
使用命令sudo xm create ~/vm/vm1.cfg 启动虚拟机。此时通过终端命令virt‐manager 查看虚拟系统的状态,
双击对应的虚拟机后通过console 可以看到虚拟系统的安装界面,或者直接通过终端命令 xm console vm1来查看
启动的虚拟系统。
6.
接下来就和物理机上安装CentOS一样安装了。
7.
安装好虚拟系统后。将vm1.cfg文件改成从硬盘启动,进入系统后对vm1进行网络配置:首先用图形界面配置好IP
、Gateway、 DNS(此处需要注意设置的IP必须和宿主机的IP在同一网段)等,激活网卡(eth0)。然后禁用掉
SELinux服务(该服务是基于域模型的高级安全服务,通常不需要这么高的安全性),最后修
改/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
8.
以打开53号端口,使虚拟机能够上网。此时虚拟系统的网络配置工作已经全部完成。重新启动虚拟系统。
9.
如果安装多个虚拟机,将上面的vm1.img文件和vm1.cfg文件拷贝到另一个文件夹如~/vm/vm2/ 下,然后分别改名
为vm2.img和vm2.cfg。对vm2.cfg稍做修改即可:包括系统名、安装目录、mac地址几项,最后用命令sudo xm
create ~/vm/vm2.cfg 启动新建的虚拟机。

四、远程访问虚拟系统。

客户端通过Xmanager软件中的Xbrowser来远程登录虚拟机。该软件支持xdmcp传输,速度快,易于操作。
服务器端设置
1.修改/etc/gdm/custom.conf,允许使用xdmcp。
[xdmcp]
Enable=1
如果需要root用户也能通过XDMCP远程登录,可添加
[security]
AllowRemoteRoot=true
DisallowTCP=false
2.打开防火墙设置
打开XDMCP的端口:UDP 177
打开TCP 6000到6010端口
可直接修改/etc/sysconfig/iptables
‐A RH‐Firewall‐1‐INPUT ‐m state ‐‐state NEW ‐m udp ‐p udp ‐‐dport 177 ‐j ACCEPT
‐A RH‐Firewall‐1‐INPUT ‐m state ‐‐state NEW ‐m tcp ‐p tcp ‐‐dport 6000:6010 –j ACCEPT
然后重启iptables:/etc/init.d/iptables restart
客户端设置
客户端安装好Xmanager后,打开Xbrowser服务,输入需要访问的虚拟系统的IP即可。
五、FTP的配置

使用gssftp服务
1.
设置服务启动:在终端中输入setup,弹出窗口中选择系统服务项,选中gssftp服务,并使vsftp服务处于非选中
状态。
2.
编辑/etc/xinetd.d/下的gssftp配置文件:
# default: off
# description: The kerberized FTP server accepts FTP connections
# that can be authenticated with Kerberos 5.
service ftp
{
disable = yes
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/ftpd
server_args = ‐l ‐a
log_on_failure += USERID
}
将上面的:
disable = yes 改为 disable =no
server_args = ‐l ‐a 改为 server_args = ‐l
其中表示使用Kerberos 5验证机制,而一般的ftp是不支持该验证机制的。
3.
关掉vsftp服务,同时重新启动gssftp服务,使用命令service vsftpd stop、 service xinetd restart。
4.
在/etc/sysconfig/iptables文件中加上一行:
‐A RH‐Firewall‐1‐INPUT ‐m state ‐‐state NEW ‐m tcp ‐p tcp ‐‐dport 20 ‐j ACCEPT
并且注释掉:
#‐A RH‐Firewall‐1‐INPUT ‐j REJECT ‐‐reject‐with icmp‐host‐prohibited
5.
重启iptables:/etc/init.d/iptables restart。
使用vsftp服务
1.
设置服务启动:在终端中输入setup,弹出窗口中选择系统服务项,选中vsftp服务,并使gssftp服务处于非选中
状态。
2.
若允许root帐户进行ftp操作,需修改文件/etc /vsftpd /ftpusers.txt及/etc /vsftpd /user_list.txt :将
root注释掉。
3.
关掉gssftp服务(/etc/xinetd.d/gssftp.txt中disable = yes),同时启动vsftp服务,使用命令service xinetd
restart 、service vsftpd start。
4.
在/etc/sysconfig/iptables文件中加上一行:
‐A RH‐Firewall‐1‐INPUT ‐m state ‐‐state NEW ‐m tcp ‐p tcp ‐‐dport 20 ‐j ACCEPT
并且注释掉:
#‐A RH‐Firewall‐1‐INPUT ‐j REJECT ‐‐reject‐with icmp‐host‐prohibited
5.
重启iptables:/etc/init.d/iptables restart。
分页: 10/12 第一页 上页 5 6 7 8 9 10 11 12 下页 最后页 [ 显示模式: 摘要 | 列表 ]