In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how xenserver installs vm in bulk. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Install VM: http://heylinux.com/archives/2795.html from the XCP/XenServer command line
[root@xenserver-1 ~] # vim install.py
#! / bin/env python
Import threading
Import time
Import os
Loops= ['192.168.11.203']
Def work (ip):
Cmd='bash-x. / install.sh'+ ip
Os.system (cmd)
Def main ():
Threads= []
Nloops=range (len (loops))
For i in loops:
Kscmd= "sed-ci\'/ ^ network. * / network-- onboot yes-- device eth0-- bootproto=static-- ip=" + I + "--netmask=255.255.255.0-- gateway=192.168.11.21-- nameserver=114.114.114.114-- noipv6/\'/ var/www/html/repo/ks/centos-6.3.ks
"
Print kscmd
Os.system (kscmd)
T=threading.Thread (target=work,args= (I))
T.start ()
Time.sleep (40)
# work (I)
If _ _ name__== "_ _ main__":
Main ()
[root@xenserver-1 ~] # vim install.sh
#! / bin/bash
Function installvm () {
Networkip=$1
Sruuid= `xe sr-list | grep-C1 "Local" | head-3 | grep uuid | awk-fills:''{print $2}'`
# initialize an empty VM
Uuid= `xe vm-install new-name-label=centos6_$networkip sr-uuid=$sruuid template=Other\ install\ media`
# set CPU and memory of VM
Xe vm-param-set VCPUs-max=2 uuid=$uuid
Xe vm-param-set VCPUs-at-startup=2 uuid=$uuid
Xe vm-param-set memory-static-max=1073741824 uuid=$uuid
Xe vm-param-set memory-dynamic-max=512435456 uuid=$uuid
Xe vm-param-set memory-dynamic-min=512435456 uuid=$uuid
Xe vm-param-set memory-static-min=268217728 uuid=$uuid
# xe vm-param-set memory-dynamic-max=906MiB uuid=$uuid
# xe vm-param-set memory-static-max=1024MiB uuid=$uuid
# xe vm-param-set memory-dynamic-min=812MiB uuid=$uuid
# xe vm-param-set memory-static-min=512MiB uuid=$uuid
# set bootloader,httprepo,kickstart for automatic installation of VM
Xe vm-param-set HVM-boot-policy= "" uuid=$uuid
Xe vm-param-set PV-bootloader= "eliloader" uuid=$uuid
Xe vm-param-set other-config:install-repository= "http://192.168.11.200:8080/repo/centos/6.3/" uuid=$uuid
Xe vm-param-set PV-args= "ip=$networkip netmask=255.255.255.0 gateway=192.168.11.21 ns=114.114.114.114 ks= http://192.168.11.200:8080/repo/ks/centos-6.3.ks ksdevice=eth0" uuid=$uuid
# add a virtual hard disk to VM
Xe vm-disk-add uuid=$uuid sr-uuid=$sruuid device=0 disk-size=20GiB
# set virtual hard disk to bootable
Uuid1= `xe vbd-list vm-uuid=$uuid userdevice=0 params=uuid-Minimal`
Xe vbd-param-set bootable=true uuid=$uuid1
# create a network for VM
Networkid= `xe network-list bridge=xenbr0-Minimal`
Xe vif-create vm-uuid=$uuid network-uuid=$networkid mac=random device=0
# start VM, and then VM will automatically install all the basic software packages and start the SSH service
Xe vm-start uuid=$uuid
}
Installvm $1
[root@xenserver-1 ~] # more / var/www/html//repo/ks/centos-6.3.ks
Cmdline
Skipx
Install
Cdrom
Lang en_US.UTF-8
Keyboard us
Rootpw 12345678
Firewall-service=ssh
Authconfig-enableshadow-passalgo=sha512
Selinux-disabled
Timezone-utc Etc/UTC
Bootloader-location=mbr-driveorder=xvda-append= "crashkernel=auto"
Zerombr
Clearpart-all-initlabel
Autopart
Reboot
% packages-- nobase
@ core
% end
Network-onboot yes-device eth0-bootproto=static-ip=192.168.11.205-netmask=255.255.255.0-gateway=192.168.11.21-nameserver=114.114.114.114-noipv6
Thank you for reading! This is the end of this article on "how xenserver installs vm in batches". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.