Linux學習 Unit 15

來源:互聯網
上載者:User

標籤:運行環境   images   管理工具   虛擬機器   create   


15.系統虛擬機器管理


####1.安裝####

 

#!/bin/bash##命令運行環境的指定

virt-install \##安裝虛擬機器

--name $1 \##虛擬機器名稱指定,$1表示指令碼後的第一串字元

--ram 1000 \##記憶體

--file /var/lib/libvirt/images/$1.img \##硬碟檔案

--file-size 8 \ ##硬碟檔案大小

--cdrom /var/ftp/pub/iso/rhel-server-7.1-x86_64-dvd.iso &  ##安裝源指定

 

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/91/EC/wKiom1j5eViyliAZAABC7qF2LrU981.jpg" style="float:none;" title="36020170421111417762.jpg" alt="wKiom1j5eViyliAZAABC7qF2LrU981.jpg" />


650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/91/EB/wKioL1j5eVjj1oXUAABDlo2QqpI457.jpg" style="float:none;" title="36020170421111435968.jpg" alt="wKioL1j5eVjj1oXUAABDlo2QqpI457.jpg" />


650) this.width=650;" src="https://s2.51cto.com/wyfs02/M00/91/EC/wKiom1j5eVjwZEEYAAAhwmR6GIw299.jpg" style="float:none;" title="36020170421111508840.jpg" alt="wKiom1j5eVjwZEEYAAAhwmR6GIw299.jpg" />


650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/91/EC/wKiom1j5eaiT6G11AAAufD2WXzw252.jpg" title="36020170421111624232.jpg" alt="wKiom1j5eaiT6G11AAAufD2WXzw252.jpg" />

650) this.width=650;" src="https://s5.51cto.com/wyfs02/M02/91/EC/wKiom1j5ejbTmqqXAAGO2nSGKuM263.jpg" title="36020170421111903137.jpg" alt="wKiom1j5ejbTmqqXAAGO2nSGKuM263.jpg" />

####2.管理####

virt-manager##開啟圖形管理工具

virt-viewer vmname##顯示虛擬機器,vmname表示虛擬機器名稱

virsh list##列出正在啟動並執行vm

virsh list --all##列出所有vm

virsh start vmname##運行指定vm

virsh shutdown vmname##正常關閉指定vm

virsh destroy vmname##強行結束指定vm

virsh create vmname.xml##臨時恢複指定vm,vmname表示前端管理檔案

virsh define vmname.xml##永久恢複vm

virsh undefine  vmname##刪除vm的前端管理,不會刪除儲存

 650) this.width=650;" src="https://s1.51cto.com/wyfs02/M00/91/EB/wKioL1j5eqjDu4C4AAAtEA45CJs372.jpg" title="36020170421112057945.jpg" alt="wKioL1j5eqjDu4C4AAAtEA45CJs372.jpg" />

 

####3.虛擬機器快照####

qemu-img create -f qcow2 -b vm2.qcow2 node1.qcow2

 

 

!/bin/bash

virsh destroy $1 &> /dev/null

virsh undefine $1 &> /dev/null

qemu-img create -f qcow2 -b /var/lib/libvirt/images/$1.qcow2  /var/lib/libvirt/images/$2.qcow2 &> /dev/null

virt-install \

--name $2 \

--ram 1000 \

--disk /var/lib/libvirt/images/$2.qcow2 \

--import &> /dev/null &

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M02/91/EB/wKioL1j5erWCSZlLAAClBIl9a1c735.jpg" title="36020170421112029282.jpg" alt="wKioL1j5erWCSZlLAAClBIl9a1c735.jpg" />

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M01/91/EB/wKioL1j5ewqhhoWjAABlPFK_kUc985.jpg" style="float:none;" title="36020170421112152423.jpg" alt="wKioL1j5ewqhhoWjAABlPFK_kUc985.jpg" />

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/91/EC/wKiom1j5ewrSl57YAADKPClRueM681.jpg" style="float:none;" title="36020170421112225073.jpg" alt="wKiom1j5ewrSl57YAADKPClRueM681.jpg" />


 4.reset


650) this.width=650;" src="https://s4.51cto.com/wyfs02/M02/91/EC/wKiom1j5e1extEWZAAA690jFBP8044.jpg" style="float:none;" title="36020170421112348769.jpg" alt="wKiom1j5e1extEWZAAA690jFBP8044.jpg" />

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/91/EC/wKioL1j5e4jQiuDLAABjq0_yFkw771.jpg" title="36020170421112443958.jpg" alt="wKioL1j5e4jQiuDLAABjq0_yFkw771.jpg" />


Linux學習 Unit 15

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.