[root@foundation29 ~]# virt-manager
虛擬機建立完成linux
虛擬機安裝完成vim
使用RHEL中的Virtual Machine Manager建立的虛擬機會生成後綴爲.qcow2的虛擬機鏡像文件
Virtual Machine Manager支持從.qcow2的虛擬機鏡像文件建立虛擬機,這樣咱們就能夠經過管理鏡像,從而很方便的建立與管理linux虛擬機。bash
#####2.配置虛擬機
須要使用剛纔安裝的虛擬機封裝一個虛擬機母鏡像,因此咱們來配置這個虛擬機,方便之後的使用
開啓虛擬機,使用root身份登入系統,進行對應的配置,而後關機(注意要關機而不是重啓)
個人配置有:
1.修改主機名:網絡
[root@server1 ~]# hostname server1 [root@server1 ~]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=server1
2.關閉防火牆dom
[root@server1 ~]# chkconfig iptables off
3.關閉selinuxssh
[root@server1 ~]# vi /etc/selinux/config ... SELINUX=disabled ...
4.配置網絡ide
[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.主機名解析oop
[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源ui
[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.安裝經常使用軟件及服務url
[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,server34.server1,server2,server3設置開機並設置好eth0,hostname