Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10222790
  • 博文数量: 1669
  • 博客积分: 16831
  • 博客等级: 上将
  • 技术积分: 12594
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 07:23
个人简介

柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!

文章分类

全部博文(1669)

文章存档

2023年(4)

2022年(1)

2021年(10)

2020年(24)

2019年(4)

2018年(19)

2017年(66)

2016年(60)

2015年(49)

2014年(201)

2013年(221)

2012年(638)

2011年(372)

分类: 虚拟化

2012-07-17 11:37:17

kvm----- --extra-args='console=tty0 console=ttyS0,115200n8'  

2011-11-01 17:09:12|  分类: 虚拟化+云计 |  标签: |字号 


[1] Install KVM.
[root@dlp ~]# 
 -y install kvm kmod-kvm kvm-qemu-img libvirt python-virtinst bridge-utils
[root@dlp ~]# 
 kvm 

[root@dlp ~]# 
 kvm_intel 
  
# if AMD, "kvm_amd"

[root@dlp ~]# 
 |  kvm 

kvm_intel
46589 0

kvm 
292815 1 kvm_intel

[root@dlp ~]# 
/etc/rc.d/init.d/libvirtd start 

Starting libvirtd daemon: 
[ OK ]

[root@dlp ~]# 
 libvirtd on
[2] Configure Bridge networking.
[root@dlp ~]# 
 /etc/sysconfig/network-scripts 

[root@dlp network-scripts]# 
 ifcfg-eth0 ifcfg-br0 

[root@dlp network-scripts]# 
 ifcfg-br0
DEVICE=
br0
# change

BOOTPROTO=none
HWADDR=00:22:68:5e:34:06
ONBOOT=yes
DHCP_HOSTNAME=dlp.server.world
IPADDR=10.0.0.30
NETMASK=255.255.255.0
GATEWAY=10.0.0.1
TYPE=
Bridge
# change
[root@dlp network-scripts]# 
 ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:22:68:5e:34:06
ONBOOT=yes
DHCP_HOSTNAME=dlp.server.world
IPADDR=10.0.0.30
NETMASK=255.255.255.0
GATEWAY=10.0.0.1
TYPE=Ethernet
BRIDGE=br0
# add
[root@dlp network-scripts]# 
 

[root@dlp ~]# 
/etc/rc.d/init.d/network restart 

Shutting down interface eth0:
[  OK  ]

Shutting down loopback interface:
[  OK  ]

Bringing up loopback interface:
[  OK  ]

Bringing up interface eth0:
[  OK  ]

Bringing up interface br0:
[  OK  ]

[root@dlp ~]# 
 

br0 Link encap:Ethernet HWaddr 00:22:68:5E:34:06  inet addr:10.0.0.30 Bcast:10.0.0.255 Mask:255.255.255.0  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1  RX packets:17 errors:0 dropped:0 overruns:0 frame:0  TX packets:34 errors:0 dropped:0 overruns:0 carrier:0  collisions:0 txqueuelen:0  RX bytes:1196 (1.1 KiB) TX bytes:5284 (5.1 KiB) eth0  Link encap:Ethernet HWaddr 00:22:68:5E:34:06  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1  RX packets:21886 errors:0 dropped:0 overruns:0 frame:0  TX packets:12991 errors:0 dropped:0 overruns:0 carrier:0  collisions:0 txqueuelen:1000 RX bytes:26727940 (25.4 MiB)  TX bytes:1212713 (1.1 MiB) Interrupt:58 Base address:0xe000  lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0   UP LOOPBACK RUNNING MTU:16436 Metric:1   RX packets:80 errors:0 dropped:0 overruns:0 frame:0   TX packets:80 errors:0 dropped:0 overruns:0 carrier:0   collisions:0 txqueuelen:0   RX bytes:8860 (8.6 KiB) TX bytes:8860 (8.6 KiB) virbr0  Link encap:Ethernet HWaddr 00:00:00:00:00:00   inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0   UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1   RX packets:0 errors:0 dropped:0 overruns:0 frame:0   TX packets:0 errors:0 dropped:0 overruns:0 carrier:0   collisions:0 txqueuelen:0 RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


[1] Install on text mode via network, it's OK on Console or remote connection with Putty and so on.
[root@dlp ~]# 
 -p /var/kvm/images 
# create a directory for virtual machines

[root@dlp ~]# 
virt-install \
-n www \
-r 1024 \
-f /var/kvm/images/ \
-s 20 \
--vcpus=2 \
--os-type linux \
--os-variant=rhel5.4 \
--network bridge=br0 \
--nographics \
--location='' \
--extra-args='console=tty0 console=ttyS0,115200n8'
Starting install...
# start installation
 
For options, make sure 'man virt-install', there are many options.
-n specify the name of Virtual Machine
-r specify the amount of memories of Virtual Machine
-f specify the location of disks of Virtual Machine
-s specify the amount of disks of Virtual MachineG
--vcpus=
specify the virtual CPUs
--os-type
specify types of GuestOS
--network=
specify network types of Virtual Machine
--nographics 
nographics
--location=
specify location of installation where from
--extra-args=
specify parameters that is set in kernel
[2] Install with text mode, it's the same with common procedure of installation.
After finishing installation, reboot first and then login prompt is shown like follwos.
CentOS release 5.6 (Final)
Kernel 2.6.18-238.el5 on an x86_64
login: 
# login with root

Password:
[root@www ~]#
[3] Move to GuestOS to HostOS with Ctrl + ] key.
Move to HostOS to GuestOS with a command 'virsh console (name of virtual machine)'.
[root@www ~]# 
# push Ctrl + ]

[root@dlp ~]#
# Host's console
[root@dlp ~]# 
virsh console www 
# move to Guest

Connected to domain www
Escape character is ^]
# Enter key
[root@www ~]#
# Guest's console
[4] Because after installing GuestOS from network, it is minimum settings, so it's useful to save it as a template in order to create new virtual machines later. Please refer  to create a new virtual machine from template below. 
[root@dlp ~]# 
virt-clone --original www --name template --file /var/kvm/images/template.img 

Cloning /var/kvm/images/
| 20 GB 01:44
Clone 'template' created successfully.
[root@dlp ~]# 
 /var/kvm/images/template.img 
  
# disk image

-rwxr-xr-x 1 root root 21474836480 Jun 21 20:31 /var/kvm/images/template.img
[root@dlp ~]# 
 /etc/libvirt/qemu/template.xml 
  
# xml file

-rw------- 1 root root 1130 Jun 21 20:29 /etc/libvirt/qemu/template.xml
[5]
 to GuestOS first before using it.
[6] Define a new Storage Pool
[root@dlp ~]# 
 /etc/libvirt/storage 

[root@dlp ~]# 
 /etc/libvirt/storage/disk01.xml
  
# create new


  
# any name

  disk01
  0
  0
  0
 
 
 
    
# specify pool directory

    /var/kvm/images
   
        0700
        -1
        -1
   

 

# define the pool

[root@dlp ~]# 
virsh pool-define /etc/libvirt/storage/disk01.xml 

Pool disk01 defined from /etc/libvirt/storage/disk01.xml
# start the pool

[root@dlp ~]# 
virsh pool-start disk01 

Pool disk01 started
# set auto-start

[root@dlp ~]# 
virsh pool-autostart disk01 

Pool disk01 marked as autostarted
# confirm to show the pool list

[root@dlp ~]# 
virsh pool-list 

Name
State
Autostart

-----------------------------------------
disk01
active
yes
# confirm to show the details

[root@dlp ~]# 
virsh pool-info disk01 

Name:
disk01

UUID:
dab2994a-ba65-418e-34dd-f87117735471

State:
running

Persistent:
yes

Autostart:
yes

Capacity:
279.25 GB

Allocation:
4.25 GB

Available:
275.00 GB








[1] Create a Virtual Machine from template that is made in .
# copy disk image and XML file for a new Virtual Machine

[root@dlp ~]# 
virt-clone --original template --name mail --file /var/kvm/images/mail.img 

Cloning /var/kvm/images/template.img
| 20 GB 01:44
Clone 'mail' created successfully.
[root@dlp ~]# 
virsh start mail --console 

Domain mail started
Connected to domain mail
CentOS release 5.6 (Final)
Kernel 2.6.18-238.el5 on an x86_64
login:
# completed to boot
[2] News GuestOS' network is failed to boot because it is the same to existing GuestOS's one. So Change network settings for new one.
[root@www ~]# 
 -a 

eth1
Link encap:Ethernet HWaddr 52:54:00:67:8C:A1

BROADCAST MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

 
Interrupt:11
lo
Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

 
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[root@www ~]# 
 /etc/sysconfig/network-scripts 

[root@www network-scripts]# 
 ifcfg-eth0 ifcfg-eth1 

[root@www network-scripts]# 
 ifcfg-eth1
# change the name and MAC address to correct one

DEVICE=
eth1

BOOTPROTO=dhcp
HWADDR=
52:54:00:67:8C:A1

ONBOOT=yes
[root@www network-scripts]# 
/etc/rc.d/init.d/network restart 

Shutting down loopback interface:
[  OK  ]

Bringing up loopback interface:
[  OK  ]

Bringing up interface eth1:
Determining IP information for eth1... done.
[  OK  ]
[root@www network-scripts]# 
 

eth1
Link encap:Ethernet HWaddr 52:54:00:67:8C:A1

inet addr:10.0.0.205 Bcast:10.0.0.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:12 errors:0 dropped:0 overruns:0 frame:0

TX packets:10 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:1216 (1.1 KiB) TX bytes:1277 (1.2 KiB)

 
Interrupt:11 Base address:0xc000
lo
Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:6 errors:0 dropped:0 overruns:0 frame:0

TX packets:6 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:828 (828.0 b) TX bytes:828 (828.0 b)


图形安装


[1] Start Virtual Machine
[root@dlp ~]# 
virsh start www 
# Start Virtual Machine 'www'

Domain www started
[root@dlp ~]# 
virsh start www --console 
# connect to console of 'www'

Domain www started
Connected to domain www
[2] Stop Virtual Machine
[root@dlp ~]# 
virsh shutdown www 
# Stop Virtual Machine 'www'

Domain www is being shutdown
[root@dlp ~]# 
virsh destroy www 
# Stop fourcely Virtual Machine 'www'

Domain www destroyed
[3] Set auto-start for Virtual Machines
[root@dlp ~]# 
virsh autostart www 
# Enable auto-start for 'www'

Domain www marked as autostarted
[root@dlp ~]# 
virsh autostart --disable www 
# Disable auto-start for 'www'

Domain www unmarked as autostarted
[4] List all Virtual Machines
[root@dlp ~]# 
virsh list 
# List all active Virtual Machines

  Id Name
State

------------------------------------------
  2   win2k8
running
[root@dlp ~]# 
virsh list --all 
# List all Virtual Machines include inactives

  Id Name
State

------------------------------------------
  2   win2k8
running

  1   www
shut off
[5] Switch console
Move to GuestOS to HostOS with Ctrl + ] key.
Move to HostOS to GuestOS with a command 'virsh console (name of virtual machine)'.
[root@dlp ~]# 
virsh console www 
# connect to 'www'

Connected to domain www
Escape character is ^]
# Enter
CentOS release 5.6 (Final)
Kernel 2.6.18-238.el5 on an x86_64
login:
# just switched on Guest
Password:
Last login: Thu Nov 4 12:33:37 on ttyS0
[root@www ~]# 
# Ctrl + ] key

[root@dlp ~]# 
# just switched on Host

[6] Other options. There are many options, please try to execute them.


阅读(3993) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~