Rhel6.4 network-based kvm Virtual Machine and rhel6.4kvm Virtual Machine

Source: Internet
Author: User

Rhel6.4 network-based kvm Virtual Machine and rhel6.4kvm Virtual Machine

The test environment 1 shows


I. Prerequisites for installation:

1. Make sure the motherboard supports intel-VT or AMD-V

2. rhel 6.4 in VMware has been installed and the virtual machine has been set to support virtualization. The settings are as follows:


3. Confirm whether intel-VT or AMD-V is supported by command

[Root @ localhost ~] # Egrep -- color "vmx | svm"/proc/cpuinfo

If a result is returned, it is supported, and vice versa.

 

2. Install KVM and configure Nic bridging (bridge to eth1), and operate on the installed rhel 6.4 (shown in Figure 1 ).

1. Install KVM

[Root @ localhost ~] # Yum-y groupinstall Virtualization "Virtualization Client" "Virtualization Platform" "Virtualization Tools"

[Root @ localhost ~] #/Etc/init. d/lib1_d start; chkconfig lib1_d on

[Root @ localhost ~] #/Etc/init. d/libvirt-guests start; chkconfig libvirt-guests on

 

2. Bridge settings

[Root @ localhost ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE = eth1

HWADDR = 00: 0C: 29: 3F: 5A: 2e

TYPE = Ethernet

ONBOOT = yes

NM_CONTROLLED = no

BOOTPROTO = static

IPADDR = 172.16.1.1

NETMASK = 255.255.255.0

BRIDGE = br0 // Add this line

 

[Root @ localhost network-scripts] # pwd

/Etc/sysconfig/network-scripts

[Root @ localhost network-scripts] # cp ifcfg-eth1 ifcfg-br0

# Cat ifcfg-br0 [root @ localhost network-scripts] #

DEVICE = br0 // DEVICE name br0

TYPE = Bridge // set the TYPE to Bridge

ONBOOT = yes

NM_CONTROLLED = no

BOOTPROTO = static

IPADDR = 172.16.1.1

NETMASK = 255.255.255.0

Restart the network

[Root @ localhost network-scripts] #/etc/init. d/network restart

View Bridge Information

[Root @ localhost network-scripts] # brctl show

Bridge name bridge id STP enabled interfaces

Br0 8000.000c293f5a2e no eth1 // the device has been mounted to eth1.

Virbr0 8000.525400635d23 yes virbr0-nic

 

Iii. Configure dhcp + tftp + vsftpd to install the server

◆. Install dhcp

1. [root @ localhost ~] # Yum-y install dhcp

 

2. Configure dhcp

[Root @ localhost ~] # Grep-v "^ #"/etc/dhcp/dhcpd. conf | grep ^ [^ $]

Default-lease-time 600;

Max-lease-time 7200;

Next-server 172.16.1.1;

Filename "pxelinux.0 ";

Ddns-update-style none;

Log-facility local7;

Subnet 172.16.1.0 netmask 255.255.255.0 {

Range 172.16.1.2 172.16.1.10;

}

[Root @ localhost ~] #

 

3. Start the dhcp service

[Root @ localhost ~] #/Etc/init. d/dhcpd start; chkconfig dhcpd on

Starting dhcpd: [OK]

[Root @ localhost ~] #

 

◆. Install tftp-server and syslinux

1. [root @ localhost ~] # Yum-y install tftp-server syslinux

 

2. Configure tftp

[Root @ localhost ~] # Grep-v "^ #"/etc/xinetd. d/tftp

Service tftp

{

Socket_type = dgram

Protocol = udp

Wait = yes

User = root

Server =/usr/sbin/in. tftpd

Server_args =-s/var/lib/tftpboot

Disable = no // change yes to no

Per_source = 11

CPIs = 100 2

Flags = IPv4

}

[Root @ localhost tftpboot] # pwd

/Var/lib/tftpboot

[Root @ localhost tftpboot] # cp/usr/share/syslinux/pxelinux.0 ./

[Root @ localhost tftpboot] # mkdir pxelinux. cfg

[Root @ localhost tftpboot] # cp/media/rhel/isolinux/*. ///media/rhel is the disk Mount directory

[Root @ localhost tftpboot] # cp isolinux. cfg pxelinux. cfg/default

[Root @ localhost tftpboot] # chmod 644 pxelinux. cfg/default

[Root @ localhost tftpboot] # vi pxelinux. cfg/default (red indicates the change)

Default linux

# Prompt 1

Timeout 600

 

Display boot. msg

 

Menu background splash.jpg

Menu title Welcome to Red Hat unzip iselinux 6.4!

Menu color border 0 # ffffffff #00000000

Menu color sel 7 # ffffffff # ff000000

Menu color title 0 # ffffffff #00000000

Menu color tabmsg 0 # ffffffff #00000000

Menu color unsel 0 # ffffffff #00000000

Menu color hotsel 0 # ff000000 # ffffffff

Menu color hotkey 7 # ffffffff # ff000000

Menu color scrollbar 0 # ffffffff #00000000

 

Label linux

Menu label ^ Install or upgrade an existing system

Menu default

Kernel vmlinuz

Append initrd = initrd. img ksdevice = eth0 ks = ftp: // 172.16.1.1/rhel6.4.cfg

Label vesa

Menu label Install system with ^ basic video driver

Kernel vmlinuz

Append initrd = initrd. img xdriver = vesa nomodeset

Label rescue

Menu label ^ Rescue installed system

Kernel vmlinuz

Append initrd = initrd. img rescue

Label local

Menu label Boot from ^ local drive

Localboot 0 xffff

Label memtest86

Menu label ^ Memory test

Kernel memtest

Append-

[Root @ localhost tftpboot] #

 

3. Start the xinentd Service

[Root @ localhost ~] #/Etc/init. d/xinetd start; chkconfig xinetd on

Starting xinetd: [OK]

[Root @ localhost ~] #

 

◆ Install vsftpd

1. [root @ localhost ~] # Yum-y install vsftpd

2. Start the vsftpd service

[Root @ localhost ~] #/Etc/init. d/vsftpd start; chkconfig vsftpd on

Starting vsftpd for vsftpd: [OK]

[Root @ localhost ~] #

3. Mount the installation disc to the ftp directory.

[Root @ localhost ~] # Mount/dev/cdrom/var/ftp/pub/

 

◆ Configure the ks File

1. ks file content is as follows

[Root @ localhost ~] # Cat rhel6.4.cfg

# Platform = x86, AMD64, or Intel EM64T

# Version = DEVEL

# Firewall configuration

Firewall -- disabled

# Install OS instead of upgrade

Install

# Use network installation

Url -- url = "ftp: // 172.16.1.1/pub"

# Root password

Rootpw -- iscrypted $1 $ p4HkNd7X $ xOiflpAb0Rsi6Ec2R1F9l1

# System authorization information

Auth -- useshadow -- passalgo = sha512

# Use text mode install

Text

# System keyboard

Keyboard us

# System language

Lang en_US

# SELinux configuration

Selinux -- disabled

# Do not configure the X Window System

Skipx

# Installation logging level

Logging -- level = info

# Reboot after installation

Reboot

# System timezone

Timezone Asia/Shanghai

# Network information

Network -- bootproto = dhcp -- device = eth0 -- onboot = on

# System bootloader configuration

Bootloader -- location = mbr

# Clear the Master Boot Record

Zerombr

# Partition clearing information

Clearpart -- all -- initlabel

# Disk partitioning information

Part/-- fstype = "ext4" -- ondisk = vda -- size = 4000

Part swap -- fstype = "swap" -- grow -- ondisk = vda -- size = 1

 

% Packages

@ Base

Gcc

Gcc-c ++

Libstdc ++-devel

Make

Openssh-clients

Acpid

 

% End

 

% Post

 

Echo "ttyS0">/etc/securetty

Sed-I '/quiet/a \ console = ttyS0'/boot/grub. conf

Sed-I '/quiet/N; s/\ n //'/boot/grub. conf

 

Cat>/etc/yum. repos. d/network. repo <EOF

[Server]

Name = Red Hat Enterprise Linux 6.4

Baseurl = ftp: // 172.16.1.1/pub/Server

Enabled = 1

Gpgcheck = 0

 

 

[HighAvailability]

Name = Red Hat Enterprise Linux 6.4

Baseurl = ftp: // 172.16.1.1/pub/HighAvailability

Enabled = 1

Gpgcheck = 0

 

 

[LoadBalancer]

Name = Red Hat Enterprise Linux 6.4

Baseurl = ftp: // 172.16.1.1/pub/LoadBalancer

Enabled = 1

Gpgcheck = 0

 

[ResilientStorage]

Name = Red Hat Enterprise Linux 6.4

Baseurl = ftp: // 172.16.1.1/pub/ResilientStorage

Enabled = 1

Gpgcheck = 0

 

[ScalableFileSystem]

Name = Red Hat Enterprise Linux 6.4

Baseurl = ftp: // 172.16.1.1/pub/ScalableFileSystem

Enabled = 1

Gpgcheck = 0

EOF

[Root @ localhost ~] #

 

Note: ks file creation is not demonstrated here. I have prepared it in advance.

 

2. Copy rhel6.4.cfg to the/var/ftp/directory.

[Root @ localhost ~] # Cp rhel6.4.cfg/var/ftp/

 

4. Start to install the virtual machine. The virt-manager GUI is not provided here. Only the ks file is used for installation.

1. installation using location + "extra-args"

[Root @ localhost ~] # Virt-install \

> -- Name rhel6.4-1 \

> -- Ram 1024 \

> -- Vcpus 1 \

> -- OS-type = linux \ // you do not need this sentence. Only the URL method is supported.

> -- OS-variant = rhel6 \ // you do not need this sentence. Only the URL method is supported.

> -- Network bridge = br0 \

> -- File/var/lib/libvirt/images/rhel6.4-1.img \

> -- File-size 5 \

> -- Nonsparse \

> -- Location ftp: // 172.16.1.1/pub /\

> -- Extra-args "ks = ftp: // 172.16.1.1/rhel6.4.cfg"

 

2. Install using pxe

[Root @ localhost ~] # Virt-install \

> -- Name rhel6.4-1 \

> -- Ram 1024 \

> -- Vcpus 1 \

> -- OS-type = linux \ // you do not need this sentence. Only the URL method is supported.

> -- OS-variant = rhel6 \ // you do not need this sentence. Only the URL method is supported.

> -- Network bridge = br0 \

> -- File/var/lib/libvirt/images/rhel6.4-1.img \

> -- File-size 5 \

> -- Nonsparse \

> -- Pxe

 

Note: either of the above two methods can be used.

 

3. formatting the hard disk, as shown in


4. Installing, as shown in


5. After the installation is complete, you can use virshconsole "Virtual Machine name" to control the Virtual Machine

[Root @ localhost ~] # Virsh console rhel6.4-1

 

6. Some Common commands for controlling virtual machines

[Root @ localhost ~] # Virsh list // list running or paused virtual machines

[Root @ localhost ~] # Virsh list -- all // list all VMS, including those that have been shut down

[Root @ localhost ~] # Virsh start rhel6.4-1 // enable the virtual machine named rhel6.4-1

[Root @ localhost ~] # Virsh shutdown rhel6.4-1 // disable the virtual machine named rhel6.4-1

[Root @ localhost ~] # Virsh reboot rhel6.4-1 // restart the virtual machine named rhel6.4-1

[Root @ localhost ~] # Virsh destroy rhel6.4-1 // force disable the virtual machine named rhel6.4-1

[Root @ localhost ~] # Virsh dominfo rhel6.4-1 // list information about this virtual machine named rhel6.4-1

 

For more detailed commands, see the virsh man manual page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.