星空网 > 软件开发 > 操作系统

centos6配置vnc登录远程物理机及vb复制vdi启动虚拟机网络问题

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,可以将系统重启一遍就变过来了。





原标题:centos6配置vnc登录远程物理机及vb复制vdi启动虚拟机网络问题

关键词:Centos

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流