设为首页 收藏本站
查看: 1544|回复: 0

[经验分享] Xen虚拟机安装

[复制链接]

尚未签到

发表于 2015-10-12 08:58:40 | 显示全部楼层 |阅读模式

1.从命令行安装:

1.1 取得镜像文件,

    mkdir -p /mnt/loop

    mount -o loop <image file> /mnt/loop/

    cp -a /mnt/loop/* /mnt/dest/

1.2 配置xen配置文件,

1.3 通过xm create 创建虚拟机.



2.从YaST/XEN Management安装虚拟机



2.1 从光盘和/或ISO安装suse10到LVM,按照向导逐步安装即可。



2.2 从光盘和/或ISO安装suse10到镜像文件,再安装此镜像系统到LVM。

2.2.1 从光盘和/或ISO安装suse10到镜像文件。

2.2.2 把安装好的镜像文件中的系统导入LVM。实际上是P2V的方式。

************************************************************************************

按照如下步骤建立LVM,或者通过YaST/System/LVM来交互式地建立LVM

************************************************************************************

1) 在一个磁盘分区上创建一个物理卷,创建后可以用pvdisplay显示创建的结果。

pvcreate /dev/sda3

2) 在物理卷上以vg2为名创建一个卷组,可以用vgdisplay查看创建结果

vgcreate vg2 /dev/sda3

3) 创建一个逻辑卷用于存储我们的镜像并命名此卷为lvm2,逻辑卷的细节可以用lvdisplay显示。

lvcreate -L 4096M -n lv2 vg2

4) lvscan命令用于扫描所有的逻辑卷和它们当前的状态。

5) 在我们新建的逻辑卷上建立ext3文件系统

mkfs.ext3 /dev/vg2/lv2

6) 创建一个目录并把逻辑卷挂上去

mkdir /mnt/lvm2

mount /dev/vg2/lv2 /mnt/lvm2

7) 把文件系统拷贝到LVM

*************或者,拷贝一份安装好的虚拟机或者物理机到LVM

rsync -essh -avz root@192.168.143.221:/ /mnt/lvm2

*************然后,修改拷贝源机器的ip,或者关机,或者断开网线,

8) 通过VMM追加一个新的虚拟机,需要作如下修改:

******修改配置文件

**指定LVM的路径:/dev/vgroupname/lvname

**指定CDROM的路径:/dev/hda

**指定network配置:ip addr,mask,gateway.重要:指定bridge name(可以仅指定MAC 和 bridge name)

9) 启动新追加的虚拟机,需要作如下修改:

******修改/etc/fstab

cat > /etc/fstab << &quot;EOF&quot;

# file system    mount point   type    options      dump  pass

/dev/sda1        /             ext3    defaults       0     1

proc             /proc         proc    defaults       0     0

sys              /sys          sysfs   defaults       0     0

EOF

10) 为系统设置主机名

echo &quot;susevm5&quot; > /etc/hostname

11) 修改网络配置

**启动yast2,修改网卡参数,指定network配置:ip addr,mask,gateway.

12) 在虚拟机上安装NX,或者通过ssh -X 连接图形界面。



我们鼓励使用LVM来存储xen域,它是建立和管理域最理想的一种方法,但是,必需注意的是在LVM上建立的客户机里面使用LVM可能导致客户机内部看到错误的LVM信息。LVM使企业在处理一个可配置和可适应的虚拟环境的存储需求时非常容易。



2.3 遇到的问题:

2.3.1 重新配置IP地址。使用xen提供的script,先停止bridge,再修改IP。

   使用如下命令:

  /etc/xen/scripts/network-bridge stop netdev=eth0

  /etc/xen/scripts/network-bridge start netdev=eth0


==========================================================================================




一、安装前检查


1)查看你的主机cpu是否支持虚拟化:输入命令 cat /proc/cpuinfo | grep flags ,查看结果中有没有 pae ,若有则支持半虚拟化,再看有没有 vmx(intel) 或 svm((amd) ,若有,则支持全虚拟化。


2 )查看虚拟化是否打开:


<span style=&quot;background-color: rgb(0, 176, 80);&quot;>grep -E 'svm|vmx' /proc/cpuinfo</span>
如果有返回。就说明你的cpu打开虚拟化

二、Xen的安装步骤如下所示
<p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>首先使用<span style=&quot;background-color: rgb(0, 176, 80);&quot;>rpm –qa|grep xen</span>检查系统是否已经安装了xen相关程序包</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;><strong>安装Xen</strong> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>安装有几种方式,可供选择,你只需选择其中之一即可。</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>方式一:类windows安装。</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>类似windows下的安装。具体操作为:</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>用鼠标点击左上角  应用程序 -> 添加或删除软件 -> 虚拟化,选中安装即可。</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>方式二:命令行安装。</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;><span style=&quot;background-color: rgb(0, 176, 80);&quot;># yum –y install xen*</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>安装XEN需要的服务</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;><span style=&quot;background-color: rgb(0, 176, 80);&quot;>#yum -y install virt-manager</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>安装虚拟化管理程序包</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;><span style=&quot;background-color: rgb(0, 176, 80);&quot;># yum -y install kernel-xen*</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>安装XEN的相关内核</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>方式三:源码包安装</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>1,下载。可以到<a target=_blank target=&quot;_blank&quot; href=&quot;http://www.xensource.com/&quot; _href=&quot;http://www.xensource.com/&quot; style=&quot;color: rgb(51, 102, 153); text-decoration: none;&quot;>www.<strong>xensource</strong>.com</a>。</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>2,解压。tar</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>3,进入目录。cd</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>4,<span style=&quot;background-color: rgb(0, 176, 80);&quot;>make KERNELS=&quot;Linux-2.6-xen0 linux-2.6-xenU&quot; world</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>这一步需要一些第三方包,如python。需要什么就安装什么就可以。编译完成后,会在dist目录生成需要安装的东西。</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>5,<span style=&quot;background-color: rgb(0, 176, 80);&quot;>make install</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>如果以上步骤出错,请Google或Baidu之。安装完毕后,你会发现在/boot下新安装了三个东西:xen-3.1.0.gz,vmlinuz-2.6.18-xen0和vmlinuz-2.6.18-xenU。xen-3.1.0.gz是hyperviser,或者叫VMM;内核xen0是运行在domain0的,内核xenU运行在其它的domain。</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>二、检测</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>1、检查xen内核文件</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>安装是否正常:文件位于/boot</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;><span style=&quot;background-color: rgb(0, 176, 80);&quot;># ls –lh /boot</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>2、修改系统启动内核为支持xen的kernel</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;><span style=&quot;background-color: rgb(0, 176, 80);&quot;># vi /etc/grub.conf</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>把default改成0,表示启动第一个内核</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>3、重新启动主机(reboot)</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>4、检查系统是否已经成功加载支持虚拟化的kernel</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>(1) 执行#<span style=&quot;background-color: rgb(0, 176, 80);&quot;> uname –a</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>Linux slave1 2.6.18-371.4.1.el5xen #1 SMP Thu Jan 30 06:58:16 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
表示已安装成功</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>
</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>(2) xen启动停止命令 <span style=&quot;background-color: rgb(0, 176, 80);&quot;>xend start|stop|restart</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>三、创建虚拟机</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>1、创建镜像文件<span style=&quot;background-color: rgb(0, 176, 80);&quot;> dd if /dev/zero of=/home/llp/test/vm.img bs=1M count=10240</span>
</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>2、创建配置文件 vm.cfg</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>name = &quot;test01&quot;
maxmem = 1024
memory = 1024
vcpus = 1
builder = &quot;hvm&quot;
kernel = &quot;/usr/lib/xen/boot/hvmloader&quot;
boot = &quot;d&quot;
pae = 1
acpi = 0
apic = 0
arch = &quot;x86_64&quot;
localtime = 0
on_poweroff = &quot;destroy&quot;
on_reboot = &quot;restart&quot;
on_crash = &quot;restart&quot;
device_model = &quot;/usr/lib64/xen/bin/qemu-dm&quot;
sdl = 0
vnc = 1
vncunused = 1
vncconsole = 1
vncdisplay = 4
disk = [ &quot;file:/home/llp/test/vm.img,hda,w&quot;,&quot;file:/root/CentOS-6.4-x86_64-minimal.iso,hdc:cdrom,r&quot;]
vif = [ &quot;mac=00:16:3e:5d:11:22,bridge=xenbr0,script=vif-bridge&quot; ]
parallel = &quot;none&quot;
nographic = 0
serial = &quot;pty&quot;</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>3、创建虚拟机 <span style=&quot;background-color: rgb(0, 176, 80);&quot;>vm create /home/llp/test/vm.cfg</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>4、<span style=&quot;background-color: rgb(0, 176, 80);&quot;>xm list  查看虚拟机</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>5、查看防火墙状态:<span style=&quot;background-color: rgb(0, 176, 80);&quot;>service iptables status</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>6、查看开放的端口:netstat -tunlp
  将设置的端口加入到开发端口中vi /etc/sysconfig/iptables</p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>7、<span style=&quot;background-color: rgb(0, 176, 80);&quot;>service iptables restart 重新启动</span></p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;> </p><p style=&quot;margin-top: 5px; margin-bottom: 5px;&quot;>8、使用vnc 登陆虚拟机安装相应的系统</p>





virt-install 常用参数一览表

-n NAME

指定虚拟机的名称


-r MEMORY

指定虚拟机的内存用量


-u UUID

指定虚拟机的唯一通用标识符

(Universally Unique Identifier,UUID)。

省略这个参数时,virt-install 将会自动产生


--vcpus=VCPUS

指定虚拟机的虚拟 CPU (Virtual CPU,VCPU) 数量

-f DISKFILE

指定虚拟磁盘的文件路径名称



-s DISKSIZE

用来指定虚拟磁盘的大小,这个参数需配合-f 使用。

DISKSIZE为虚拟磁盘的大小,单位是GB



-m MAC

指定虚拟机的网络卡之硬件地址。

这个参数可以省略,省略时virt-install 将自动产生



-p 以半虚拟化的方式建立虚拟机



-l LOCATION 指定安装来源






virt-install 参数解析:


-n  vm01-CentOS-5.5                          # 虚拟机的名称,这里我们的名称是 vm01-CentOS-5.5


-r 1024                                              # 虚拟机的最大内存,单位 MB 。这里我们的内存是 1G


--vcpus=4                                          # 虚拟机的 CPU 数量,这里我们的数量是 2


-f  vm01-CentOS-5.5.img                   # 虚拟机虚拟硬盘的名称,我们这里用 vm01-CentOS-5.5.img


--nographic                                        # 不安装图形界面。


-l   nfs:10.10.113.14:/opt/CentOS/mirrors/5.5        # 系统的镜像路径。 Xen 只支持 FTP/HTTP/NFS










创建完毕,在当前目录下,生成镜像文件 vm01-CentOS-5.5.img;



在 /etc/xen 目录下,生成虚拟机配置文件 vm01-CentOS-5.5;




[iyunv@gmnode14 xen]# cat /etc/xen/vm01-CentOS-5.5

name = &quot;vm01-CentOS-5.5&quot;

uuid = &quot;0283f36d-c95a-521b-737d-e400ca657029&quot;

maxmem = 1024

memory = 1024

vcpus = 4

bootloader = &quot;/usr/bin/pygrub&quot;

on_poweroff = &quot;destroy&quot;

on_reboot = &quot;restart&quot;

on_crash = &quot;restart&quot;

disk = [ &quot;tap:aio:/local/Xen_zkl/vm01-CentOS-5.5/vm01-CentOS-5.5.img,xvda,w&quot; ]

vif = [ &quot;mac=00:16:36:40:43:85,bridge=virbr0,script=vif-bridge&quot; ]


========================================================================================


一、安装步骤


1、 配置yum源


2、 安装xen


# yum –y install xen*


安装XEN需要的服务


# yum -y install kernel-xen*


安装XEN的相关内核


#yum -y install virt-manager*


安装XEN图形化管理工具


二、检查启动选项是否使用xen内核启动


1、检查xen内核文件


安装是否正常:文件位于/boot


# ls –lh /boot


total 9.5M


-rw-r--r-- 1 root root 61K Mar 16 08:19 config-2.6.18-8.el5


-rw-r--r-- 1 root root 60K Mar 16 09:27 config-2.6.18-8.el5xen


drwxr-xr-x 2 root root 1.0K Aug 15 14:47 grub


-rw------- 1 root root 1.5M Aug 13 17:18 initrd-2.6.18-8.el5.img


-rw------- 1 root root 1.5M Aug 15 14:47 initrd-2.6.18-8.el5xen.img


drwx------ 2 root root 12K Aug 13 17:15 lost&#43;found


-rw-r--r-- 1 root root 79K Apr 1 22:49 message


-rw-r--r-- 1 root root 82K Mar 16 08:20 symvers-2.6.18-8.el5.gz


-rw-r--r-- 1 root root 83K Mar 16 09:28 symvers-2.6.18-8.el5xen.gz


-rw-r--r-- 1 root root 865K Mar 16 08:19 System.map-2.6.18-8.el5


-rw-r--r-- 1 root root 848K Mar 16 09:27 System.map-2.6.18-8.el5xen


-rw-r--r-- 1 root root 1.7M Mar 16 08:19 vmlinuz-2.6.18-8.el5


-rw-r--r-- 1 root root 2.0M Mar 16 09:27 vmlinuz-2.6.18-8.el5xen


-rw-r--r-- 1 root root 269K Mar 16 07:51 xen.gz-2.6.18-8.el5


-rwxr-xr-x 1 root root 595K Mar 16 09:43 xen-syms-2.6.18-8.el5


2、检查grub配置


# cat /boot/grub/grub.conf


# grub.conf generated by anaconda


#


# Note that you do not have to rerun grub after making changes to this file


# NOTICE: You have a /boot partition. This means that


# all kernel and initrd paths are relative to /boot/, eg.


# root (hd0,0)


# kernel /vmlinuz-version ro root=/dev/sda3


# initrd /initrd-version.img


#boot=/dev/sda


default=1


timeout=5


splashimage=(hd0,0)/grub/splash.xpm.gz


hiddenmenu


title CentOS (2.6.18-8.el5xen)


root (hd0,0)


kernel /xen.gz-2.6.18-8.el5


module /vmlinuz-2.6.18-8.el5xen ro root=LABEL=/


module /initrd-2.6.18-8.el5xen.img


title CentOS (2.6.18-8.el5)


root (hd0,0)


kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/


initrd /initrd-2.6.18-8.el5.img


修改其中的default=1为default=0,启用xen内核


3、重新启动计算机


使用xen内核启动计算机


1)reboot


2)按F10,进入BIOS,打开CPU的VT功能


3)在引导菜单里选择“Red Hat Enterprise Linux Server (2.6.18-8.el5xen)”


4、重启后登录系统,检查XEN是否正常


4.1 执行# xm list


Name ID Mem(MiB) VCPUs State Time(s)


Domain-0 0 3919 4 r----- 16.9


出现上述结果表示xen启动正常


4.2 检查log:


#ls -lh /var/log/xen


total 8.0K


-rwxr-xr-x 1 root root 36 Aug 15 15:43 xend-debug.log


-rw-r--r-- 1 root root 1.8K Aug 15 15:43 xend.log


# cat /var/log/xen/xend-debug.log


Nothing to flush.


Nothing to flush.


表示一切正常,我们的CentOS5中的XEN服务已经成功启动。至此,我们的CentOS5的宿主机已经安装就绪。




三、安装XEN的Windows客户机


前提:宿主计算机的CPU支持intel的VT或者AMD的amd-v,并且在BIOS中开启了对应的选项。




1、检查是否支持VT:


#xm info |grep xen_cap


xen_caps : xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p


# xm dmesg |grep -i vmxon


(XEN) VMXON is done


(XEN) VMXON is done


如果出现上述字段则计算机支持VT,否则很有可能是不支持或者BIOS禁用了。


也可以通过 xm dmesg或者cpuinfo等等方式查询,这里就不详细描述了。


接下去我们就可以创建一个个虚拟的操作系统了。


2、为实现图形化远程安装开启vnc


#yum –y install vnc*


3、 使用vnc客户端连接,打开gnome下的Virtual Machine Manager并创建虚拟机


1). 点击 &quot;Applications&quot; - &quot;System Tools&quot; - &quot;Virtual Machine Manager&quot;,打开Xen图形管理窗口


2). 创建虚拟机


(1) 点击 &quot;New&quot; 按钮或 &quot;File&quot; - &quot;New machine...&quot;菜单


(2) 点击 &quot;Forward&quot;按钮


(3) 输入System Name,如:win2003, 点击&quot;Forware&quot;按钮


(4) 选择&quot;Fully Virtualized&quot;,点击&quot;Forware&quot;按钮


(5) 找到win2003.iso (此处我使用iso文件代替光盘进行安装),点击&quot;Forware&quot;按钮


(6) 点击&quot;Simple File&quot;,并在File Location处输入:/var/xen/imagess/win2003.img (注:先建立目录),


File Size设置为4000, 点击&quot;Forware&quot;按钮


(7) VM Max Memory及VM Startup Memory都设置成500,VCPUs设置为1个,点击&quot;Forware&quot;按钮


(8) 点击&quot;Finish&quot;按钮,之后就进入windows安装程序


(9)在windows完成复制文件需要重启后将关闭虚拟机窗口,需要手工再开始虚拟机。


(10)xm create win2003 (重新启动win2003虚拟机)


(11)在Virtual Machine Manager中双击win2003虚拟机即可打开该虚拟机显示窗口,继续进行windows安装,直至安装完成即可。


=====================================================================================


Xen使用http方式安装虚拟机


首先新建安装源


如果没按apache,先安apache


yum install httpd






然后打开vi /etc/httpd/conf.d/welcome.conf,把所有行都注释掉






/etc/init.d/httpd start   //必须执行






mount -t iso9660 -o loop /usr/Redhat.Enterprise.Linux.iso /var/www/html






关闭防火墙(如果不关防火墙可能会出现 Unable to retrieve ...的问题)






/etc/init.d/iptables stop






上面使用的是http,也可以使用ftp,nfs等其他的方式安装虚拟机。


新建xen虚拟机,选择半虚拟化 在安装介质URL中填写 http://Dom0的IP地址


之后就是正常的安装过程


========================================================================================


xen虚拟机的linux系统时间设置本来没想到会成为问题,但是因为项目中的特殊要求,需要服务器设定为中国标准时间。因此研究了一下。



原来,安装虚拟机后,在虚拟机脚本中的时间设定部分,一般都默认设置为localtime=0,即取物理机的时间为虚拟机的RTC。而物理机一般都把时间设置为北京时间。结果,虚机里的时间总是错的,原来是虚机把物理机的北京时间当作的UTC。所以,虚拟机的时间总是和物理机相差8个小时。当项目对服务器时间要求严&#26684;的情况下,不得不认真面对这个问题的时候,只好认真地梳理一下linux系统的各种时间设定方法。






首先又重新了解一下linux上面的时间的种类。


linux上面的时间的种类



linux上面一般有UTC, CST时间,以及RTC,他们的含义分别是:


GMT(Greenwich Mean Time,&#26684;林威治标准时间): 是指位于英国伦敦郊区的皇家&#26684;林&#23612;治天文台的标准时间,因为本初子午线被定义在通过那里的经线。


UTC(Universal Time/Temps Cordonné 世界标准时间)



CST(Central Standard Time 國家標準時間,一說中原標準時間); 中国标准时间(China Standard Time)。实际就是北京时间。


GMT &#43; 8 = UTC &#43; 8 = CST ,也就是说中国标准时间比UTC快8个小时。



RTC(Real Time Clock) -- 实时时钟,也叫做CMOS时钟, 它是PC主机板上的一块芯片,它靠电池供电,即使系统断电,也可以维持日期和时间。由于它独立于操作系统,所以也被称为硬件时钟,它为整个计算机提供一个计时标准,是最原始最底层的时钟数据,Linux只用RTC来获得时间和日期;然而,通过作用于/dev/rtc设备文件,也允许进程对RTC编程。通过执行/sbin/clock系统程序,系统管理员可以配置时钟.


在虚拟机中没有物理时钟,因此通过修改clock文件来设定时钟的属性






设定虚拟机时间


若想达到虚拟机中的时间能够正确地显示为中国标准时间。需要作这些修改:


1.首先修改这个文件的内容:


/etc/sysconfig/clock 设置硬件时钟,



设置为UTC时间



HWCLOCK=&quot;--utc&quot;



正确设置时区,如果不知道时区的&#26684;式,可以通过tzselect命令工具看到。


TIMEZONE=&quot;Asia/Shanghai&quot;


2.设定本地时间为CST,即中国标准时间


ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime



这样就OK了,虚拟机的时间能够显示为正确的CST时间了。


5、克隆虚拟机


virt-clone -o vm00 -n vm01 -f vm01

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-125635-1-1.html 上篇帖子: Xen的启动信息页(Start Info Page) 下篇帖子: Xen 支持的虚拟机类型
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表