标签:虚拟机
一、虚拟机安装 [root@foundation29 ~]# virt-manager
虚拟机创建完成
虚拟机安装完成
使用RHEL中的Virtual Machine Manager创建的虚拟机会生成后缀为.qcow2的虚拟机镜像文件
Virtual Machine Manager支持从.qcow2的虚拟机镜像文件创建虚拟机,这样我们就可以通过管理镜像,从而很方便的创建与管理linux虚拟机。
#####2.配置虚拟机
需要使用刚才安装的虚拟机封装一个虚拟机母镜像,所以我们来配置这个虚拟机,方便以后的使用
开启虚拟机,使用root身份登入系统,进行对应的配置,然后关机(注意要关机而不是重启)
我的配置有:
1.修改主机名:
[root@server1 ~]# hostname server1
[root@server1 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server1
2.关闭防火墙
[root@server1 ~]# chkconfig iptables off
3.关闭selinux
[root@server1 ~]# vi /etc/selinux/config
...
SELINUX=disabled
...
4.配置网络
[root@server1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
IPADDR=172.25.29.1
PREFIX=24
[root@server1 ~]# cd /etc/udev/rules.d/
[root@server1 rules.d]# ls
60-raw.rules 70-persistent-net.rules
[root@server1 rules.d]# rm -f 70-persistent-net.rules
[root@server1 rules.d]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Determining if ip address 172.25.29.1 is already in use for device eth0...
[ OK ]
5.主机名解析
[root@server1 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.29.1 server1
172.25.29.2 server2
172.25.29.3 server3
172.25.29.4 server4
172.25.29.5 server5
172.25.29.6 server6
6.配置yum源
[root@server1 ~]# vi /etc/yum.repos.d/rhel-source.repo
[rhel-dvd]
name=rhel6.5-dvd
baseurl=http://172.25.29.250/rhel6.5
gpgcheck=0
[HighAvailability]
name=HighAvailability
baseurl=http://172.25.29.250/rhel6.5/HighAvailability
gpgcheck=0
[LoadBalancer]
name=LoadBalancer
baseurl=http://172.25.29.250/rhel6.5/LoadBalancer
gpgcheck=0
[ResilientStorage]
name=ResilientStorage
baseurl=http://172.25.29.250/rhel6.5/ResilientStorage
gpgcheck=0
[ScalableFileSystem]
name=ScalableFileSystem
baseurl=http://172.25.29.250/rhel6.5/ScalableFileSystem
gpgcheck=0
7.安装常用软件及服务
[root@server1 ~]# yum clean all
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: HighAvailability LoadBalancer ResilientStorage
: ScalableFileSystem rhel-dvd
Cleaning up Everything
[root@server1 ~]# yum install -y vim man lftp
...
8.关机
[root@server1 ~]# poweroff
1.初始化域
[root@foundation29 ~]# cd /var/lib/libvirt/images/
[root@foundation29 images]# virt-sysprep -d rhel-6.5-server
[ 0.0] Examining the guest ...
[ 69.0] Performing "abrt-data" ...
[ 69.0] Performing "bash-history" ...
[ 69.0] Performing "blkid-tab" ...
[ 69.0] Performing "crash-data" ...
[ 69.0] Performing "cron-spool" ...
[ 69.0] Performing "dhcp-client-state" ...
[ 69.0] Performing "dhcp-server-state" ...
[ 69.0] Performing "dovecot-data" ...
[ 69.0] Performing "logfiles" ...
[ 69.0] Performing "machine-id" ...
[ 69.0] Performing "mail-spool" ...
[ 69.0] Performing "net-hostname" ...
[ 69.0] Performing "net-hwaddr" ...
[ 69.0] Performing "pacct-log" ...
[ 69.0] Performing "package-manager-cache" ...
[ 69.0] Performing "pam-data" ...
[ 69.0] Performing "puppet-data-log" ...
[ 69.0] Performing "rh-subscription-manager" ...
[ 69.0] Performing "rhn-systemid" ...
[ 69.0] Performing "rpm-db" ...
[ 69.0] Performing "samba-db-log" ...
[ 69.0] Performing "script" ...
[ 69.0] Performing "smolt-uuid" ...
[ 69.0] Performing "ssh-hostkeys" ...
[ 69.0] Performing "ssh-userdir" ...
[ 69.0] Performing "sssd-db-log" ...
[ 69.0] Performing "tmp-files" ...
[ 69.0] Performing "udev-persistent-net" ...
[ 69.0] Performing "utmp" ...
[ 69.0] Performing "yum-uuid" ...
[ 69.0] Performing "customize" ...
[ 69.0] Setting a random seed
[ 69.0] Performing "lvm-uuids" ...
2.创建虚拟机image
首先删除原虚拟机并且保留qcow2镜像,其原因是为了避免母镜像(即原虚拟机rhel-6.5-server)与使用该qcow2文件创建的虚拟机同时工作导致错误
删除过程:
创建基于rhel-6.5-server.qcow2的虚拟机
[root@foundation29 images]# qemu-img create -f qcow2 -b rhel-6.5-server.qcow2 server1
Formatting ‘server1‘, fmt=qcow2 size=21474836480 backing_file=‘rhel-6.5-server.qcow2‘ encryption=off cluster_size=65536 lazy_refcounts=off
[root@foundation29 images]# qemu-img create -f qcow2 -b rhel-6.5-server.qcow2 server2
Formatting ‘server2‘, fmt=qcow2 size=21474836480 backing_file=‘rhel-6.5-server.qcow2‘ encryption=off cluster_size=65536 lazy_refcounts=off
[root@foundation29 images]# qemu-img create -f qcow2 -b rhel-6.5-server.qcow2 server3
Formatting ‘server3‘, fmt=qcow2 size=21474836480 backing_file=‘rhel-6.5-server.qcow2‘ encryption=off cluster_size=65536 lazy_refcounts=off
3.创建虚拟机
server1创建完成,同上可以创建server2,server3
4.server1,server2,server3设置
开机并设置好eth0,hostname
linux虚拟机Virtual Machine Manager
标签:虚拟机
原文地址:http://blog.51cto.com/kking/2104659