2013年3月10日 星期日

雲端網路實務 2013/3/10

#virsh version
#tree /etc/libvirt
#tree /var/log/libvirt

1.下載映像檔
#wget http://www.vyatta.com/downloads/vc6.5/vyatta-livecd_VC6.5R1_i386.iso
2.產生虛擬硬碟檔
#kvm-img create -f qcow2 vyatta.qcow2 1G
3.開始安裝
#virt-install -r 512 -n vyatta --disk path=./vyatta.qcow2, format=qcow2 --noreboot --cdrom vyatta-livecd_VC6.5R1_i386.iso  vyatta.qcow2 -boot d
4.啟動
#kvm -m 1024 -cdrom vyatta-livecd_VC6.5R1_i386.iso vyatta.qcow2
(登入帳密 vyatta vyatta)

#virsh list --all
(確認狀態)
QEMU裡
#install system
(連續按Enter)
#show version

#virsh shutdown vyatta
#tree libvirt
#virsh undefine vyatta
(把定義檔xml移除)

linux作業系統  -=>縮寫  --=>全名
--------------------------------------------------------------------------------------------------
#apt-get install libvirt-bin
 安裝目錄為
1./etc/libvirt         (root)
2./var/libvirt/        (root)
#apt-get install virtinst virt-viewer
#kvm-img create -f qcow2 vyatta.qcow2
#virt-install -r 512 -n vyatta --disk path=~/vyatta.qcow, format=qcow2 --noreboot --cdrom ~/vyatta.iso
#virsh list --all
#virsh start vyatta
#virsh shutdown vyatta

-----------------------------------------------
#xmllint -- noout abc.xml
(檢查xml檔案內容)
<?xml version="1.0"?>
<bobe>
<disk>
<name>vyatta06.qcow2</name>
<type>qcow</type>
<size>1G</size>
</disk>
</bobe>

#xpath -e "/bobe/disk/name/textc()" conf/mydisk.xml 2>/dev/null
2>/dev/nul=>黑洞裝置
#x=$(xpath -e "/bobe/disk/name/textc()" conf/mydisk.xml 2/dev/null)
#y=$(xpath -e "/bobe/disk/type/textc()" conf/mydisk.xml 2/dev/null)
#z= $(xpath -e "/bobe/disk/size/textc()" conf/mydisk.xml 2/dev/null)
#kvm-img create -f $y $x $z
    ($y=>取出變數y的內容)

#nano mkdisk.sh
#!/bin/bash
x=$(xpath -e "/bobe/disk/name/textc()" conf/mydisk.xml 2/dev/null)       
y=$(xpath -e "/bobe/disk/type/textc()" conf/mydisk.xml 2/dev/null)
z=$(xpath -e "/bobe/disk/size/textc()" conf/mydisk.xml 2/dev/null)        

[ -f $x ] && exit 1

kvm-img create -f $y$x$z &>/dev/null
[ "$? != 0 ] && echo "error $?"

exit 0

&&=>前面條件成立,後面接著做
exit 1=>離開
&>/dev/null=>不管隊的錯的訊息都丟黑洞
"$?=>前一個命令的結果

#echo $?
(上一個命令執行的結果,非0的數字代表執行不正常)


沒有留言:

張貼留言

(TOP)Temp for soulin only

123