KVM就夠了。

在西安等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計制作、做網(wǎng)站 網(wǎng)站設(shè)計制作定制制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),成都營銷網(wǎng)站建設(shè),外貿(mào)網(wǎng)站制作,西安網(wǎng)站建設(shè)費(fèi)用合理。
virt-install --name centos --ram 1024 --vcpus=1 --disk path=/home/3158cdn/images/node92.img,size=100 --network network:default --os-variant=rhel6 -l --extra-args='console=tty0 console=ttyS0,115200n8'
安裝完成后,virtsh console centos
剩下的象操作實體機(jī)一樣
另外
--name 名字 -ram 內(nèi)存大小 --vcpus 虛擬CPU --disk 虛擬硬盤選項 --network 網(wǎng)絡(luò)接入模式
--os-variant=系統(tǒng)類型,這個也可以先成default -l 安裝源,這里采用了網(wǎng)絡(luò)安裝源,
--extra-args='console=tty0 console=ttyS0,115200n8' 比較重要,沒它,你安完了無法console
如果想安完了,就自動連入,可以再加上--connect qemu:///system
眼下有幾種不同的方法可以管理在KVM虛擬機(jī)管理程序上運(yùn)行的虛擬機(jī)。比如說,virt-manager就是一種廣受歡迎的基于圖形用戶界面(GUI)的前端工具,可用來管理虛擬機(jī)。不過,如果你想在無外設(shè)服務(wù)器上使用KVM,那么基于GUI的解決方案并非理想方案
制作鏡像文件有三種方法,cp, cat, dd 和其它專用工具。cp ,cat 和 dd都可以從設(shè)備復(fù)制文件來創(chuàng)建鏡像。而 dd 命令更為強(qiáng)大,可以通過指定塊大小,塊多少來直接創(chuàng)建鏡像。
IMG 文件:
因為cp, cat 只能從設(shè)備來制作鏡像,但又沒有專用工具來做 IMG 文件,故這里用 dd 命令來制作 IMG 文件。
1,制作
dd if=/dev/zero of=fdimage.img count=2880
or
dd if=/dev/zero of=fdimage.img bs=1024 count=1440
2,格式化
mkfs.msdos fdimage.img
3,修改
可以用下面的命令 mount 后,可直接修改
mount -o loop *.img /mnt
4,可啟動
因為制作可啟動鏡像一定會用到虛擬機(jī),推薦用 Virtualbox,先到網(wǎng)上下個 DOS 啟動盤來引導(dǎo)。用 DOS 的 sys 命令傳遞系統(tǒng)。推薦使用 FreeDOS,屬自由軟件。也可用 dd 命令 來傳遞引導(dǎo)引導(dǎo)信息,并復(fù)制啟動啟動時所需文件來做啟動盤。以 FreeDOS 為例,傳遞啟動信息用以下命令,其中下載的啟動盤為 balder10.img 文件
dd if=balder10.img of=fdimage.img bs=512 count=1 conv=notrunc
多系統(tǒng)用 grub4dos,
1),用 grub.exe 引導(dǎo)多系統(tǒng)
2),安裝 grub 到MBR,用 grldr 來引導(dǎo)多系統(tǒng)。當(dāng)然也可用同上面一樣的辦法用 dd 直接寫入引導(dǎo)信息。
bootlace.com --floppy --chs 0x00
注:才發(fā)現(xiàn)用 dd 命令只能從邏輯扇區(qū)開始 copy,先前我想可否用 dd 來將 grldr.mbr 寫入 u 盤,我用自己的 U 盤試了,結(jié)果不能打開了。因為我的 U 盤為 fat16 格式,邏輯扇區(qū)開始是OBR,接著是FAT表,結(jié)果把 FAT1 表給蓋了,那時還沒有想到還有 FAT2 呢,就格了,現(xiàn)在想起來郁悶啊,好多東西都沒有了。
為什么軟盤可以呢,因為它就沒有前面的63個扇區(qū),直接從邏輯0扇區(qū)開始的。
ISO 文件:
因為文件系統(tǒng)的關(guān)系,就不能用 dd 來直接做 ISO 鏡像了(當(dāng)然,它還是可以從設(shè)備制作 ISO 鏡像)。 ISO 文件的制作有專用工具,
1,制作
mkisofs -r -o cdimage.iso /home/XXX/cddir
2,格式化
用mkiso制作的 iso 已有文件系統(tǒng) iso9660
3,可啟動
無論是引導(dǎo)單系統(tǒng)還是引導(dǎo)多系統(tǒng)都還是用 mkisofs 這個工具,只是加載到光盤的 boot loader 不一樣而已。當(dāng)然也可以將 DOS 的引導(dǎo)器 (也就是它的引導(dǎo)扇區(qū)) 或 windows 的引導(dǎo)器 ( XP 系統(tǒng)的是 ntldr ) 放入讓光盤引導(dǎo)。下面只討論 grub4dos 的使用
1),用 grub.exe 引導(dǎo)多系統(tǒng)
用 DOS 加載 grub.exe 引導(dǎo)多系統(tǒng)
2),將 grub 安裝到光盤 MBR
在制作時可用下面的命令直接生成可啟動鏡像,其中 grldr, menu.lst 要放在 cddir 目錄下,也就是在 cd 根目錄。
mkisofs -R -b grldr -no-emul-boot -boot-load-seg 0x1000 -o cdimage.iso cddir
mkisofs -R -b grldr -no-emul-boot -boot-load-size 4 -o cdimage.iso cddir
PS,下面給出 dd 命令和 mkisofs 參數(shù)說明
dd (convert and copy files)
dd 是 Linux/UNIX 下的一個非常有用的命令,作用是用指定大小的塊拷貝一個文件,并在拷貝的同時進(jìn)行指定的轉(zhuǎn)換。
dd 的主要選項:
指定數(shù)字的地方若以下列字符結(jié)尾乘以相應(yīng)的數(shù)字:
b=512, c=1, k=1024, w=2, xm=number m
if=file
輸入文件名,缺省為標(biāo)準(zhǔn)輸入。
of=file
輸出文件名,缺省為標(biāo)準(zhǔn)輸出。
ibs=bytes
一次讀入 bytes 個字節(jié)(即一個塊大小為 bytes 個字節(jié))。
obs=bytes
一次寫 bytes 個字節(jié)(即一個塊大小為 bytes 個字節(jié))。
bs=bytes
同時設(shè)置讀寫塊的大小為 bytes ,可代替 ibs 和 obs 。
cbs=bytes
一次轉(zhuǎn)換 bytes 個字節(jié),即轉(zhuǎn)換緩沖區(qū)大小。
skip=blocks
從輸入文件開頭跳過 blocks 個塊后再開始復(fù)制。
采用模板的方式可能導(dǎo)致虛擬機(jī)的硬盤容量不夠,可以通過單獨(dú)增加一塊硬盤來作為數(shù)據(jù)的存儲。
1、首先使用dd命令在默認(rèn)路徑下創(chuàng)建一個大小為10G的映像文件:
dd?bs=1M?count=10240?if=/dev/zero?of=/var/lib/libvirt/images/guest1_data.img
另外也可以使用?qemu-img?命令來創(chuàng)建,具體可以參考:centos?6.6?安裝?KVM?虛擬機(jī)。
2、使用virsh?edit?命令來編輯?domain?的配置文件,在其中已有的disk?段后增加如下內(nèi)容:
disk?type='file'?device='disk'
driver?name='qemu'?type='raw'?cache='none'/
source?file='/var/lib/libvirt/images/guest1_data.img'/
target?dev='hdb'?bus='ide'/
address?type='drive'?controller='0'?bus='0'?target='0'?unit='1'/
/disk
3、分區(qū)格式化以及自動掛載硬盤
使用fdisk?-l?查看系統(tǒng)的硬盤,根據(jù)上次配置,應(yīng)該可以看到設(shè)備?/dev/sdb,然后使用如下命令進(jìn)行分區(qū)
fdisk?/dev/sdb
然后進(jìn)行格式化
mkfs.ext4?/dev/sdb1
假設(shè)把新的硬盤mount?到?/data?目錄,可以采用命令
mount?/dev/sdb1?/data
這種方式如果機(jī)器重啟后就需要重新mount,所以可以把他加入到fstab?中,這樣系統(tǒng)啟動時就能自動mount上去
/dev/sdb1???/data???ext4????defaults????0???0
使用VNC軟件:
Linux下VNC配置詳解,以下配置為配置VNC詳細(xì)介紹。并解決了用VNC View登入發(fā)現(xiàn)畫面是灰色的問題
1. Linux下VNC的配置
首先在Linux的add/remove applications中的system tools下面安裝VNC-server服務(wù)安裝完成后直接輸入vncserver 會出現(xiàn)以下內(nèi)容:
passwd: //只有這個帳號是第一次運(yùn)行vncserver,才會要求你輸入連接的密碼。
verify:
New 'server1.linux:4 (demo)' desktop is server1.linux:1
Starting applications specified in /home/.vnc/xstartup
Log file is /home/.vnc/server1.linux:1.log
上面這段話表示起動了一個圖形終端,編號為1,要記住這個編號,等下登錄時需要提供這個編號。第一次啟動VNC一定要先直接輸入vncserver。如果你要停止這個進(jìn)程,使用命令
vncserver -kill :1
啟動后就可以在客戶端上面輸入IP加剛才提到的那個編號即可登陸機(jī)器(xxx.xxx.xxx.xxx:1) 看到一個灰色的Xwindow桌面但上面什么也沒有
運(yùn)行過一次VNSERVER后會在HOME目錄下面生成一個.VNC文件夾(在開始啟動的時候可看到該文件夾的位置)注:該目錄為隱藏,可直接輸入路徑進(jìn)入。修改xstartup文件,去掉unset SESSION_MANAGER 和exec /etc/X11/xinit/xinitrc 前面的注釋符號,將最后一行twm 改成 gnome-session
vi /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER //此行注釋去掉
# exec /etc/X11/xinit/xinitrc //此行注釋去掉
[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"
twm //改成 gnome-session
重新啟動VNCSERVER即可
2、VNC的啟動/停止/重啟
#service vncserver start/stop/restart
關(guān)閉具體的vncserver命令:
vncserver -kill :1
vncserver -kill :2
3、設(shè)置密碼
#vncpasswd
4、客戶端登陸
在vnc客戶端中輸入:服務(wù)器端IP:1或服務(wù)器端IP:2
5、設(shè)置登陸到KDE桌面
注:很多情況下,提示VNC無法連接,或者提示10086錯誤都是沒有修改vncservers文件的問題,所以編輯該文件修改
# VNCSERVERS="1:myusername"
# VNCSERVERARGS[1]="-geometry 800x600"
這兩行問題一般都可以解決。
a.
[root@CentOS ~]# vi /etc/sysconfig/vncservers
# # Uncomment the line below to start a VNC server on display :1 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, see # URL:.
# VNCSERVERS="1:myusername"
VNCSERVERS="1:root"
# VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[1]=”-geometry 800×600 -alwaysshared -depth 24″
-alwaysshared代表允許多用戶同時登錄 -depth代為色深,參數(shù)有8,16,24,32。
注:紅色部分就是被修改或增加的部分
b.
[root@centos .vnc]$ vi /root/.vnc/xstartup #!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" #gnome-session #set starting GNOME desktop startkde kde desktop
#twm
#Text interface
注:紅色部分就是被修改或增加的部分
c.
重啟VNC即可。
vnc安裝 Oracle:
出現(xiàn)錯誤提示:“Xlib: connection to ":1.0" refused by server”
如下處理:
實用技巧:在Linux下設(shè)置xhost方法步驟
source:
第一步:用root登陸linux,啟動vnc服務(wù);
第二步:根據(jù)vnc起來的端口,設(shè)置export DISPLAY=localhost:1(1表示vnc在第一個tty上啟動的),vnc的啟動信息見附件1;
第三步:執(zhí)行xhost +,并且提示“access control disabled, clients can connect from any host”才正確。
Linux下的操作日志如下:
[root@localhost ~]# vncserverNew 'localhost:1 (root)' desktop is localhost:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost:1.log[root@localhost ~]# export DISPLAY=localhost:1 [root@localhost ~]# xhost +access control disabled, clients can connect from any host
在設(shè)置xhost時,出現(xiàn)了unable的問題。
使用上訴方法就可以搞定。
一下為我以root身份登錄的配置文件
[root@PC-223-CE ~]# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# URL:;.
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600"
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared -depth 24"
~
[root@PC-223-CE ~]# vi /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
xrdb $HOME/.Xresources
# [ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup
# [ -r $HOME/.Xresources ] xrdb $HOME/.Xresources
xsetroot -solid grey
# vncconfig -iconic
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"
# twm
gnome-session
~
更改完后保存,重新啟動VNC即可
3.多個用戶登錄
linux的VNC可以實現(xiàn)多個用戶同時鏈接.方法如下
su 用戶名
vncserver (這里就是第二個用戶了)
第三個用戶是
su 用戶名
vncserver
添加完后需要在/etc/sysconfig/vncserver里面添加這個用戶,不然就會出現(xiàn)登錄后都是灰色的
另外還需要 修改用戶目錄下的.vnc/xstartup文件
例:我的電腦上已經(jīng)有一個root用戶,此時我還需要ocmSUSEr這個用戶可以VNC登錄
[root@linuxidc~]# su ocmsuser
[ocmsuser@linuxidcroot]$ vncserver
You will require a password to access your desktops.
Password:
Verify:
New 'ywei:2 (ocmsuser)' desktop is ywei:2
Creating default startup script /home/ocmsuser/.vnc/xstartup
Starting applications specified in /home/ocmsuser/.vnc/xstartup
Log file is /home/ocmsuser/.vnc/ywei:2.log
[ocmsuser@linuxidcroot]$ su - root
Password:
[root@linuxidc~]# vi /etc/sysconfig/vncservers
The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# URL:;.
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-nohttpd" to prevent web-based VNC clients connecting.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the "-via" option in the
# `man vncviewer' manual page.
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1280x800 -alwaysshared -depth 24"
VNCSERVERS="2:ocmsuser"
VNCSERVERARGS[2]="-geometry 1280x800 -alwaysshared -depth 24"
~
[root@linuxidc~]# cat /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"
twm
[root@linuxidc~]# cat /home/ocmsuser/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"
twm
[root@linuxidc~]# cp /home/ocmsuser/.vnc/xstartup /home/ocmsuser/.vnc/xstartup.bak
[root@linuxidc~]# cp /root/.vnc/xstartup /home/ocmsuser/.vnc/xstartup
cp: overwrite `/home/ocmsuser/.vnc/xstartup'? yes
[root@linuxidc~]# service vncserver restart
Shutting down VNC server: 2:ocmsuser [ OK ]
Starting VNC server: 2:ocmsuser
New 'ywei:2 (ocmsuser)' desktop is ywei:2
Starting applications specified in /home/ocmsuser/.vnc/xstartup
Log file is /home/ocmsuser/.vnc/ywei:2.log
[ OK ]
網(wǎng)頁名稱:kvmlinux命令,kvm常用命令
URL標(biāo)題:http://chinadenli.net/article31/dsicesd.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、軟件開發(fā)、域名注冊、靜態(tài)網(wǎng)站、品牌網(wǎng)站設(shè)計、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)