热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用convirt集中管理KVM虚拟机

官方文档:kvm中使用kickstart无法获取IP的问题:首先,Convirt分为两部分CMS即ConvirtManageServer,即管理控制端。另外一部分为ManagedServers即被管理端。被管理端即运行虚拟机的物理服务器。一、安装CMS(convirtmanageserver)尝试在Ccentos5

官方文档:

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

 For example in the following url, username = root, password = convirt, server=localhost, database port = 3306 

  and database name is convirt (the one before '?' in the url)

  

 sqlalchemy.url=mysql://root:convirt@localhost:3306/convirt?charset=utf8

注:后台收集的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=5970 

delete 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 {

    my $host = "127.0.0.1";

    my $port = "3306";

    my $db = "convirt";

    my $user = 'root';

    my $pass = 'password';

    my $dbh = DBI->connect("DBI:mysql:database=$db:host=$host:port=$port",

                           $user, $pass, {"RaiseError" => 1,

                           "AutoCommit" => 1}) or die $!;

                           return $dbh;

                                            }

安装: 

./convirt-install/install/cms/scripts/setup_convirt

过程中会创建cms的ssh key,密码设置为空。

创建的key的文件名为:cms_id_rsa  cms_id_rsa.pub

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服务器,添加:

 iptables -I INPUT -m state --state NEW -p tcp --dport 6900:6999 -j ACCEPT

二、安装被管理端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

查看帮助:

  ./convirt-tool -h

验证platform而不做任何更改:

  ./convirt-tool --detect_only setup

安装所需的依赖

 ./convirt-tool install_dependencies

有可能出现的冲突

Transaction Check Error:

  package tunctl-1.5-3.el5.x86_64 (which is newer than tunctl-1.5-2.el5.i386) is already installed

  file /usr/share/man/man8/tunctl.8.gz from install of tunctl-1.5-2.el5.i386 conflicts with file from package tunctl-1.5-3.el5.x86_64

/usr/local/convirture-tools/common/scripts/RedHat_functions

install_dependencies

   #$SUDO yum -y install dnsmasq tunctl tcp_wrappers socat expect pexpect 

   $SUDO yum -y install dnsmasq  tcp_wrappers socat expect pexpect 

去掉其中的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:      CODE_NAME=`cat /etc/fedora-release | sed s/.*\(// | sed s/\)//`

得到类似这样的信息

查看:/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。


推荐阅读
  • CentOS 7部署KVM虚拟化环境之一架构介绍
    本文介绍了CentOS 7部署KVM虚拟化环境的架构,详细解释了虚拟化技术的概念和原理,包括全虚拟化和半虚拟化。同时介绍了虚拟机的概念和虚拟化软件的作用。 ... [详细]
  • 本文介绍了使用cacti监控mssql 2005运行资源情况的操作步骤,包括安装必要的工具和驱动,测试mssql的连接,配置监控脚本等。通过php连接mssql来获取SQL 2005性能计算器的值,实现对mssql的监控。详细的操作步骤和代码请参考附件。 ... [详细]
  • mac php错误日志配置方法及错误级别修改
    本文介绍了在mac环境下配置php错误日志的方法,包括修改php.ini文件和httpd.conf文件的操作步骤。同时还介绍了如何修改错误级别,以及相应的错误级别参考链接。 ... [详细]
  • Python项目实战10.2:MySQL读写分离性能优化
    本文介绍了在Python项目实战中进行MySQL读写分离的性能优化,包括主从同步的配置和Django实现,以及在两台centos 7系统上安装和配置MySQL的步骤。同时还介绍了创建从数据库的用户和权限的方法。摘要长度为176字。 ... [详细]
  • 本文介绍了Python高级网络编程及TCP/IP协议簇的OSI七层模型。首先简单介绍了七层模型的各层及其封装解封装过程。然后讨论了程序开发中涉及到的网络通信内容,主要包括TCP协议、UDP协议和IPV4协议。最后还介绍了socket编程、聊天socket实现、远程执行命令、上传文件、socketserver及其源码分析等相关内容。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 本文介绍了在SpringBoot中集成thymeleaf前端模版的配置步骤,包括在application.properties配置文件中添加thymeleaf的配置信息,引入thymeleaf的jar包,以及创建PageController并添加index方法。 ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • 如何在服务器主机上实现文件共享的方法和工具
    本文介绍了在服务器主机上实现文件共享的方法和工具,包括Linux主机和Windows主机的文件传输方式,Web运维和FTP/SFTP客户端运维两种方式,以及使用WinSCP工具将文件上传至Linux云服务器的操作方法。此外,还介绍了在迁移过程中需要安装迁移Agent并输入目的端服务器所在华为云的AK/SK,以及主机迁移服务会收集的源端服务器信息。 ... [详细]
  • 本文介绍了在mac环境下使用nginx配置nodejs代理服务器的步骤,包括安装nginx、创建目录和文件、配置代理的域名和日志记录等。 ... [详细]
  • 众筹商城与传统商城的区别及php众筹网站的程序源码
    本文介绍了众筹商城与传统商城的区别,包括所售产品和玩法不同以及运营方式不同。同时还提到了php众筹网站的程序源码和方维众筹的安装和环境问题。 ... [详细]
  • Centos下安装memcached+memcached教程
    本文介绍了在Centos下安装memcached和使用memcached的教程,详细解释了memcached的工作原理,包括缓存数据和对象、减少数据库读取次数、提高网站速度等。同时,还对memcached的快速和高效率进行了解释,与传统的文件型数据库相比,memcached作为一个内存型数据库,具有更高的读取速度。 ... [详细]
author-avatar
南非酋长
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有