ʹÓÃconvirt¼¯ÖйÜÀíkvmÐéÄâ»ú
(2012-01-19 09:40)
·ÖÀࣺ ÐéÄ⻯
¹Ù·½Îĵµ£º
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µÈ
- yum install socat
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
°²×°£º
- ./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
ÓпÉÄܳöÏֵijåÍ»
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 (<string>, 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
Èý¡¢½«ÏÖÓÐlibvirt¹ÜÀíµÄKVMÐéÄâ»úµ¼Èëµ½convirtÖС£
½«xmlµÄÅäÖÃÎļþת»»³É.cfgÅäÖÃÎļþ£¬¹¤¾ß£º
batch_convert [-h] [<directory with xml files>] [<directory for output files ]
./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']
ÌØ±ð×¢Ò⣺´ÅÅÌÃûǰ¼Ó/dev/£¬·ñÔò±¨´í£¬ÕÒ²»µ½bootloader
ÁíÍ⣬¶ÔÓÚ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¡£
ʵ¼ÊÉÏ£¬ÉÏÃæµÄdrive£¬boot£¬diskµÈ²ÎÊýÀ´Ô´ÓÚkvm£¬¿ÉÒԲ鿴£º
Íø¿¨£¬Ê¹ÓÃvirtio£º
vif = ['mac=52:54:00:55:52:e9,bridge=br0', 'mac=52:54:00:5a:b7:d4,bridge=br1']
ÐÞ¸ÄΪ
vif = ['mac=52:54:00:55:52:e9,bridge=br0,model=virtio', 'mac=52:54:00:5a:b7:d4,bridge=br1,model=virtio']
¹ØÓÚkernel
kernel = '/usr/lib/xen/boot/hvmloader'
kvmΪʲôʹÓÃxenµÄ£¿¹Ù·½µÄÂÛ̳ÖÐÓÐÌáµ½£º
In the the section 'Boot Parameters' of 'VM templates' by 'Kernel' the following pathc is mentioned '/usr/lib/xen/boot/hvmloader'.
I guess in case using KVM and not Xen a KVM applicable path must be mentioned here e.g. '/usr/lib/kvm/boot/hvmloader', but that doesn't exist. What is the KVM one?
macamba
Re: Bootparameters template: Kernel: /usr/lib/xen/boot/hvmlo
by jd_jedi on Wed Feb 23, 2011 10:09 am
We use common template for both xen and kvm. The hvmloader will be ignored for KVM. (just keep it the way it was).
½«ÅäÖÃÎļþ·ÅÖõ½´æ·ÅÅäÖÃÎļþµÄĿ¼£¬µ¼Èë¼´¿É¡£
ËÄ¡¢Ä£°å
console->Template Library->CommonÖеÄÄ£°å¿ÉÒÔÓÃÓÚKVM¡£
ÓйشÅÅÌ£º
´ÅÅ̵ĿÉÑ¡Ãû³ÆÀïûÓÐvda¡¢vdbµÈ£¿Ö±½ÓÊÖ¶¯ÊäÈë¼´¿É¡£
´ÅÅÌÀàÐÍÑ¡ÔñFile£¨VDB£©£¬file systemÑ¡none¼´¿É¡£
ÈçºÎÖ¸¶¨´´½¨µÄ´ÅÅÌʹÓÃvirtio£¿MiscellaneousÖÐÌí¼ÓÊôÐÔ£º
file=/usr/local/convirt/vm_disk/$VM_NAME.disk.xm,if=virtio,format=raw,index=0,boot=on
¶à¸ö´ÅÅÌ£¿Ê¹ÓÃÊý×飺
- ['file=/usr/local/convirt/vm_disk/$VM_NAME.os.xm,if=virtio,format=raw,index=0,boot=on','file=/usr/local/convirt/vm_disk/$VM_NAME.disk.xm,if=virtio,format=raw,index=0']
ÈçºÎÑéÖ¤´´½¨µÄ´ÅÅÌÊÇraw£¿
qemu-img info -f raw ./convrit_test.disk.xm
image: ./convrit_test.disk.xm
file format: raw
virtual size: 30G (32212254720 bytes)
disk size: 2.9G
ÓйØÍøÂ磺
¶ÔÓÚÇŽÓÍøÂ磬Ӧ¸ÃÑ¡Ôñbr0£¬br1.
boot parametersÖеÄboot loaderΪĬÈÏ/usr/lib/xen/boot/hvmloader¼´¿É£º
We use common template for both xen and kvm. The hvmloader will be ignored for KVM. (just keep it the way it was).
¹ØÓÚ
Switching kvm binary to 'qemu-kvm'
/usr/local/convirt/src/convirt/core/platforms/kvm/KVMProxy.py
- if self.node_proxy.file_exists("/usr/libexec/qemu-kvm"):
-
print "Switching kvm binary to 'qemu-kvm'"
- self.kvm_binary = "/usr/libexec/qemu-kvm"
¸ÃÎļþ±»±àÒëΪ£º/usr/local/convirt/src/convirt/core/platforms/kvm/KVMProxy.pyc
¹ØÓÚÊý¾Ý¿â£¬·¢ÏÖÊý¾Ý¿âÔö³¤½Ï¿ì£¬Ö÷񻃾¼°Ò»ÏÂ±í£º
tasks¡¢task_results ¡¢metrics£¨·þÎñÆ÷¼°¼°ÐéÄâ»úµÄ¸÷ÖÖÀúÊ·Êý¾Ý£¬ÈçcpuÀûÓÃÂʵȣ©
ËùÒÔɾ³ýÁËһЩÊý¾Ý£¬½á¹ûÔì³Éºǫ́±¨´í£¬Ç°Ì¨²»ÄÜÏÔʾϵͳ״̬ͼ£¬½¨Ò鲻Ҫɾ³ýÊý¾Ý¿âµÄÊý¾Ý£º
delete from tasks where submitted_on <'2012-03-01 00:00:00';

