centos6配置vnc登入遠程物理機及vb複製vdi啟動虛擬機器網路問題,centos6vdi
1、安裝vnc和vncserver
#yum install tigervnc tigervnc-server
2、啟動VNC服務
# vncserver
You will require a password to access your desktops.
Password:
Verify:
會提示輸入密碼,這個密碼是遠程登入時所需要輸入的密碼。 我嘗試無密碼登入,好像還不行,必須整個密碼。這裡要關閉防火牆,/etc/init.d/iptables stop
3、編輯VNC設定檔
vi /etc/sysconfig/vncservers
VNCSERVERS="1:root" //去掉#,按實際配置案頭號和使用者名稱
VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -localhost" //去掉#,配置解析度
修改後儲存退出
4、設定vnc伺服器開機自動啟動:
方法一:使用“ntsysv”命令啟動圖形化服務配置程式,選中vncserver服務,點擊確定即可。
方法二:在終端裡使用chkconfig命令:
# chkconfig vncserver on
# chkconfig --list vncserver
vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off
5、更改VNC串連密碼:(也可以不改)
# vncpasswd
到這裡VNC服務端就基本完成了,可以在另一台機器上用VNC用戶端(如RealVNC)遠程登入CentOS:
輸入:CentOS系統IP:5901(預設連接埠號碼) (如在RealVNC視窗輸入:192.168.1.100:5901)
之後會提示輸入密碼。
6、如果串連上以後出現灰屏或者只顯示終端(命令列)不進入圖形介面(已安裝圖形介面的情況下),可以按照下面的方法設定:
進入使用者的home目錄,cd /home/user
如果是用root帳號登入的,那麼目前的目錄就是使用者根目錄
# cd ~/.vnc
vi xstartup //編輯xstartup配置
#twm & //加#,注釋掉這一行
gnome-session & //添加這一行
儲存退出即可正常串連!
vbox安裝:http://www.cnblogs.com/xia520pi/p/3545666.html
公司測試環境安裝的都是RHEL6.3,在進行虛擬機器複製後,發現clone的虛擬機器網卡起不來,具體報如下錯誤:
[root@localhost Desktop]# service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Error: No suitable device found: no device found for connection 'System eth0'.
[FAILED]
當你執行ifconfig命令的時候,會發現顯示eth1網卡的設定檔卻為/etc/sysconfig/network-scripts/ifcfg-eth0。
[root@localhost network-scripts]# ifconfig|grep addr
eth1 Link encap:Ethernet HWaddr 00:0c:29:f4:95:e3
inet6 addr: fe80::20c:29ff:fe5c:65b7/64 Scope:Link
Interrupt:19 Base address:0x2024
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
[root@localhost network-scripts]# ls
ifcfg-eth0 ifdown-isdn ifup-aliases ifup-plusb init.ipv6-global
ifcfg-lo ifdown-post ifup-bnep ifup-post net.hotplug
ifdown ifdown-ppp ifup-eth ifup-ppp network-functions
ifdown-bnep ifdown-routes ifup-ippp ifup-routes network-functions-ipv6
ifdown-eth ifdown-sit ifup-ipv6 ifup-sit
ifdown-ippp ifdown-tunnel ifup-isdn ifup-tunnel
ifdown-ipv6 ifup ifup-plip ifup-wireless
[root@localhost network-scripts]#
產生這個問題的原因是虛擬機器分配給作業系統的虛擬網卡MAC地址是不一樣的。第一個系統的網卡MAC地址記錄在了/etc/udev/rules.d /70-persistent-net.rules,命名為eth0。新複製分配的系統的網卡MAC地址也記錄在了該檔案當中,與之前的系統一樣,因此有 了衝突。
可以查看一下兩個機子的這個70-persistent-net.rules檔案的內容
第一個系統:
[root@localhost rules.d]# cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f4:95:e3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
複製後的系統:
[root@localhost rules.d]# cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f4:95:e3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
我們可以看到這兩個系統中的MAC地址一樣。
問題解決方案:
刪除複製後這個系統中的 /etc/udev/rules.d/70-persistent-net.rules檔案,重啟後系統會重建一個新的虛擬網卡MAC地址,然後把這 個檔案裡NAME="eth1"的eth1改成eth0,同時也要修改ATTR{address}裡的mac地址和/etc/sysconfig /network-scripts/ifcfg-eth0檔案mac地址,並與新的虛擬網卡MAC地址保持一致。
如:將原檔案的
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f4:95:e3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
改為 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:5c:65:b7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
修改/etc/sysconfig/network-scripts/ifcfg-eth0檔案
DEVICE="eth0"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="05944003-ae77-4c9d-9e58-3ec2851db71d"
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME="System eth0"
HWADDR=00:0c:29:5c:65:b7
然後重啟網路服務,發現一切正常了。
[root@localhost Desktop]# service network restart
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
state: activated
Connection activated [ OK ]
設定IP後,再檢查一下
[root@localhost Desktop]# ifconfig|grep addr
eth0 Link encap:Ethernet HWaddr 00:0C:29:5C:65:B7
inet addr:192.168.0.129 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe5c:65b7/64 Scope:Link
Interrupt:19 Base address:0x2024
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
註:如果你執行ifconfig命令的時候,發現仍然顯示eth1而不是eth0,可以將系統重啟一遍就變過來了。