kickstart+kvm批量产生测试机
kickstart+kvm批量产生测试机
kickstart+kvm批量产生测试机
01
kickstart+kvm批量产生测试机
02
03
1.可以使用RHEL6.0自带kickstart工具创建模板:ks.cfg
04
******************************************************
05
#platform=x86, AMD64, or Intel EM64T
06
#version=DEVEL
07
# Firewall configuration
08
firewall --disabled
09
# Install OS instead of upgrade
10
install
11
# Use network installation
12
url --url="ftp://192.168.0.254/pub/rhel6/dvd"
13
# Root password
14
rootpw --plaintext westos
15
# Network information
16
network --bootproto=dhcp --device=eth0 --onboot=on
17
# System authorization information
18
auth --useshadow --passalgo=md5
19
# Use text mode install
20
text
21
# System keyboard
22
keyboard us
23
# System language
24
lang en_US
25
# SELinux configuration
26
selinux --disabled
27
# Do not configure the X Window System
28
skipx
29
# Installation logging level
30
logging --level=info
31
# Reboot after installation
32
reboot
33
# System timezone
34
timezone Asia/Chongqing
35
# System bootloader configuration
36
bootloader --location=mbr
37
# Clear the Master Boot Record
38
zerombr
39
# Partition clearing information
40
clearpart --all --initlabel
41
# Disk partitioning information
42
part /boot --fstype="ext4" --size=200
43
part / --fstype="ext4" --size=6000
44
part swap --fstype="swap" --size=1000
45
46
%post
47
cd /etc/yum.repos.d/;
48
cat > test.repo << end
49
[server]
50
name=server
51
baseurl=http://192.168.0.254/pub/rhel6/
52
gpgckeck=0
53
end
54
mkdir -p /var/cache/yum/x86_64/6Server ;
55
yum clean all ;
56
yum install lftp -y
57
%end
58
59
%packages
60
@base
61
@dial-up
62
63
%end
64
******************************************************
65
66
2.使用virt-intall测试:
67
使用dd命令产生虚拟机硬盘
68
dd if=/dev/zero of=/var/lib/libvirt/images/server.img bs=1G count=8
69
virt-install --vnc --noautoconsole --name=server --ram=512 --arch=x86_64 --vcpus=1 --os-type=linux --os-variant=rhel6 --hvm --accelerate --disk=/var/lib/libvirt/images/server.img size=8G --location=ftp://192.168.0.254/pub/rhel6/dvd --extra-args="ks=http://192.168.0.158/ks.cfg" && virt-install --autostart server
70
71
3.批量产生虚拟机shell
72
#!/bin/bash
73
#function: add test servers
74
75
echo "input servers Num you need :"
76
read Num;
77
78
i=1;
79
for((i=1;i<=$Num;i++))
80
do
81
dd if=/dev/zero of=/var/lib/libvirt/images/server$i.img bs=1G count=8
82
virt-install --vnc \
83
--noautoconsole \
84
--name=server$i \
85
--ram=512 --arch=x86_64 \
86
--vcpus=1 --os-type=linux \
87
--os-variant=rhel6 \
88
--hvm --accelerate \
89
--disk=/var/lib/libvirt/images/server$i.img size=8G \
90
--location=ftp://192.168.0.254/pub/rhel6/dvd \
91
--extra-args="ks=http://192.168.0.158/ks.cfg" > /dev/null
92
echo "server$i created ok!"
93
done
评论暂时关闭