官方文档:
kvm中使用kickstart无法获取IP的问题:
首先,Convirt分为两部分CMS 即Convirt Manage Server,即管理控制端。
另外一部分为Managed Servers即被管理端。被管理端即运行虚拟机的物理服务器。
一、安装CMS(convirt manage server)
尝试在Ccentos5.7上,使用二进制安装的mysql上,安装部署Convirt 2.0.1 CMS,没有成功。
以下为在Centos6.2的虚拟机上安装的步骤。
按照官方文档安装即可。
1、添加convirt的yum源并安装socat。
wget --no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo
yum makecache
安装socat,socat的主要特点就是在两个数据流之间建立通道,且支持众多协议和链接方式:ip, tcp, udp, ipv6, pipe,exec,system,open,proxy,openssl,socket等
2、下载convirt相关程序
convirt-install:CMS端安装程序
wget --no-cache http://www.convirture.com/downloads/convirt/2.0.1/convirt-install-2.0.1.tar.gz
convirt:CMS及managed server端安装程序
wget --no-cache http://www.convirture.com/downloads/convirt/2.0.1/convirt-2.0.1.tar.gz
convirture-tools:managed server端安装程序
wget --no-cache http://www.convirture.com/downloads/convirture-tools/2.0.1/convirture-tools-2.0.1.tar.gz
3、使用root用户安装依赖程序
tar -xzf convirt-install-2.0.1.tar.gz
cd convirt-install/install/cms/scripts/
sudo ./install_dependencies
注:建议不要在运行着mysql的服 务器上安装cms,因为会rpm安装mysql,并执行/usr/bin/mysql_secure_installation该脚本的作用是加强 mysql的安全性,会修改mysql的root密码,清除匿名用户等。如果服务器上已经运行了二进制的mysql,容易冲突及覆盖。
建议启动一个虚拟机来安装运行CMS。
安装过程中提示修改root密码,修改为"convirt"。稍后可以修改。
修改MySQL配置,在/etc/mysql/my.cnf文件的[mysqld]部分添加如下内容:
innodb_buffer_pool_size=1G
innodb_additional_mem_pool_size=20M
重启mysql。
4、安装CMS
默认情况下,将安装convirt到用户的home目录下,需要修改安装路径:
convirt-install/install/cms/scripts/install_config
修改CONVIRT_BASE为要安装的路径
如:
CONVIRT_BASE=/usr/local (不需要在后面添加/)
同时注意修改下面的CONVIRT_TARBALL和CONVIRT_DOWNLOAD_URL的convirt版本号。
*Untar the CMS tarball.
source convirt-install/install/cms/scripts/install_config
tar -xzf ./convirt-2.0.1.tar.gz -C $CONVIRT_BASE
*Setup TurboGears
./convirt-install/install/cms/scripts/setup_tg2
* Setup ConVirt
更改数据库相关信息
src/convirt/web/convirt/development.ini 修改 sqlalchemy.url
注:后台收集的cpu、内存等信息都会保存到数据库中,默认为365天,数据量非常大,造成后期mysql查询很慢,磁盘IO很高,如果机器性能不好,应该修改下面的参数,来减少数据保存的时间:
purge_hr_data = 60
purge_day_data = 30
purge_week_data = 30
purge_month_data = 30
purge_raw_data = 30
task_results_purge_interval=30
TaskPaneLimit=7
task_panel_row_limit=200
notifications_row_limit=200
如何删除以前的数据?因为我的cms的服务器性能不好,造成删除这些数据都很慢,所以我将数据库dump到一台性能较好的服务器上删除以后再导到cms服务器上。
http://www.convirture.com/forums/viewtopic.php?f=34&t=5970delete from metrics where metric_type=1 and cdate < '2012-06-01 19:24:03';
delete from metrics where metric_type=4 and cdate < '2012-06-01 19:24:03';
delete from metrics where metric_type=7 and cdate < '2012-06-01 19:24:03';
delete from metrics_arch where rollup_type=1 and cdate < '2012-06-01 19:24:03';
DELETE FROM task_results WHERE task_results.task_id in (4,9,10) AND status = 3 and datediff(now() , task_results.timestamp) >= 15;
delete FROM task_results WHERE task_id in (SELECT tasks.task_id AS tasks_task_id FROM tasks WHERE datediff(now() , tasks.submitted_on) >= 15 AND tasks.parent_task_id in (4,9,10)) and status=3;
delete FROM tasks WHERE datediff(now() , tasks.submitted_on) >= 15 AND tasks.parent_task_id in (4,9,10) and task_id not in (select task_id from task_results);
脚本:
#!/usr/bin/perl
use DBI;
use Date::Format;
my $del_nday_ago=15;
my $del_time=time2str('%Y-%m-%d %H:%d:%S',time - (86400*$del_nday_ago));
my $dbh=connect_mysql();
$dbh->do("delete from metrics where metric_type=1 and cdate <'$del_time';");
$dbh->do("delete from metrics where metric_type=4 and cdate <'$del_time';");
$dbh->do("delete from metrics where metric_type=7 and cdate <'$del_time';");
$dbh->do("delete from metrics_arch where rollup_type=1 and cdate <'$del_time';");
$dbh->do("DELETE FROM task_results WHERE task_results.task_id in (4,9,10) AND status = 3 and datediff(now() , task_results.timestamp
) >= $del_nday_ago;");
$dbh->do("delete FROM task_results WHERE task_id in (SELECT tasks.task_id AS tasks_task_id FROM tasks WHERE datediff(now() , tasks.s
ubmitted_on) >= $del_nday_ago AND tasks.parent_task_id in (4,9,10)) and status=3;");
$dbh->do("delete FROM tasks WHERE datediff(now() , tasks.submitted_on) >= $del_nday_ago AND tasks.parent_task_id in (4,9,10) and tas
k_id not in (select task_id from task_results);");
sub connect_mysql {
安装:
./convirt-install/install/cms/scripts/setup_convirt
过程中会创建cms的ssh key,密码设置为空。
创建的key的文件名为:cms_id_rsa
5、启动CMS
/usr/local/convirt/convirt-ctl start
启动的端口为8081
iptables -I INPUT -p tcp --dport 8081 -j ACCEPT
登陆的初始用户名及密码为 admin/admin
6、VNC
需要为VNC打开6900:6999端口范围,用于convirt允许VNC applet访问虚拟机的concole。
登陆CMS服务器,添加:
二、安装被管理端managed server
安装KVM,对于centos/rhel 5.x,安装工具可以自动配置桥接网络,对于centos/rhel 6.x,需要手动配置。
建议无论centos/rhel 5.x还是6.x都手动配置桥接网络。
安装convirt-tool
For the KVM platform, the command creates appropriate public bridges, required scripts and writes a summary of its operations to the /var/cache/convirt/server_info file.
cd /usr/local/;wget --no-cache http://www.convirture.com/downloads/convirture-tools/2.0.1/convirture-tools-2.0.1.tar.gz
tar -xzf convirture-tools-2.0.1.tar.gz
cd ./convirture-tools/install/managed_server/scripts
查看帮助:
验证platform而不做任何更改:
安装所需的依赖
有可能出现的冲突
Transaction Check Error:
/usr/local/convirture-tools/common/scripts/RedHat_functions
install_dependencies
去掉其中的tunctl
安装
注意,建议先手动配置桥接网络,下面的安装convirt-tool,并不配置桥接网络及防火墙策略。。
./convirt-tool --skip_bridge --skip_firewall setup
关于手动配置桥接网络的配置,可以查看:
http://www.convirture.com/wiki/index.php?title=RedHat_6_Networking
或:
http://blog.chinaunix.net/space.php?uid=1838361&do=blog&id=257238
配置bridge network要特别注意,特别是通过远程配置,因为配置错误可能造成不能远程连接。
迁移涉及的端口:
Fox KVM : TCP ports 8002 to 8012 for migration
通过console添加managed server时:
ERROR [convirt.viewModel] [NodeService.py]:489 :EOL while scanning string literal (, line 3)
原因:
/etc/redhat-release文件中包含两行
造成managed server 在使用下面的方法获取系统信息时:
./common/scripts/functions:
得到类似这样的信息
查看:/var/cache/convirt/server_info
CODE_NAME="Tikanga
Final"
VER="5.7
5.7"
解决办法:
删除一行,重新执行:./convirt-tool --skip_bridge --skip_firewall
setup
添加 cms_id_rsa.pub到被管理server的authorized_keys中
如果出现Key Mismatch
需要重启CMS服务
三、将现有libvirt管理的KVM虚拟机导入到convirt中。
将xml的配置文件转换成.cfg配置文件,工具:
batch_convert [-h] [] [
./batch_convert.sh /etc/libvirt/qemu/
转换完的格式:
kernel = '/usr/lib/xen/boot/hvmloader'
vif = ['mac=52:54:00:55:52:e9,bridge=br0', 'mac=52:54:00:5a:b7:d4,bridge=br1']
on_shutdown = 'destroy'
disk = ['qemu:raw:/usr/local/kvm/rhel6.1/disk.os,vda,w', 'qemu:raw:/usr/local/kvm/rhel6.1/disk.data,vdb,w']
vncunused = 1
apci = 0
uuid = 'dba78c52-a767-2496-742c-5215ffc284fa'
os_version = '1.0'
on_reboot = 'restart'
boot = 'c'
platform = 'kvm'
pae = 1
memory = 2614
acpi = 1
os_name = 'Linux'
vnc = 1
on_crash = 'destroy'
network_mode = 'tap'
bootloader = ''
arch = 'x86_64'
usb = 1
name = 'rhel6.1'
usbdevice = 'tablet'
device_model = '/usr/libexec/qemu-kvm'
builder = 'hvm'
template_version = '1.0'
vfb = ['type=vnc,vncunused=1']
vcpus = 4
os_flavor = 'Linux'
其中需要注意的是磁盘部分,需要修改:
disk = ['qemu:raw:/usr/local/kvm/rhel6.1/disk.os,vda,w', 'qemu:raw:/usr/local/kvm/rhel6.1/disk.data,vdb,w']
修改为:
disk=['file:/usr/local/kvm/rhel6.1/disk.os,/dev/vda,w','file:/usr/local/kvm/rhel6.1/disk.data,/dev/vdb,w']
drive=['file=/usr/local/kvm/rhel6.1/disk.os,if=virtio,format=raw,index=0,boot=on','file=/usr/local/kvm/rhel6.1/disk.data,if=virtio,format=raw,index=1']
找不到bootloader?试试磁盘名前加/dev/,
另外,对于pxe安装,报找不到bootloader的问题,应查看/tftpboot/pxelinux.cfg/default,确认default指向正确的项目。
boot=on
包含bootloader的分区,如果写了多个,会报错:
'TUNSETIFF: Device or resource busy\nTUNSETIFF: Device or resource busy\nqemu: two bootable drives specified\n
使用vim直接修改cfg文件不生效,需要重新导入cfg文件,或者在console中编辑config file。