Xen 虚拟机默认不允许不同的虚拟机使用不同的系统时间,因此所有虚拟机的系统时间都会同宿主机的系统时间严格同步,用 date 命令修改虚拟机系统时间时虽然提示成功但其实系统时间还是没变。若有独立修改 Xen 虚拟机的特殊需要,可以通过如下方法进行:
1、在命令行输入下面命令#echo 1 > /proc/sys/xen/independent_wallclock
#/usr/sbin/ntpdate -u 0.centos.pool.ntp.org //ntp时间同步 3 Jun 11:07:12 ntpdate[24581]: step time server 114.80.81.1 offset -28633.982583 sec 2、修改配置文件/etc/sysctl.conf加入下面一行#vim /etc/sysctl.conf
xen.independent_wallclock = 1 #sysctl -p net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 4294967295 kernel.shmall = 268435456 net.ipv4.ip_forward = 1 net.ipv4.tcp_keepalive_time = 1800 net.ipv4.tcp_keepalive_probes = 5 net.ipv4.tcp_keepalive_intvl = 15 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_tw_reuse = 1 net.core.netdev_max_backlog = 30000 net.ipv4.tcp_no_metrics_save = 1 net.core.somaxconn = 262144 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_max_orphans = 262144 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.ip_conntrack_max = 6553600 net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_max_tw_buckets = 20000 net.ipv4.ip_local_port_range = 1024 65000 xen.independent_wallclock = 1