Jan 4

[原]正确设置VPS中的时间 不指定

linuxing , 15:40 , 网络服务 » 虚拟机 , 评论(0) , 引用(0) , 阅读(17810) , Via 本站原创 | |
    由于VPS使用模板创建,而构建模板的环境各不相同,导致系统中一些环境变量、时间等有差异,最常见的就是时区问题。在《OpenVZ-Users-Guide》就这个问题还专门开了一节来描述,我就不想写怎么多了,就看看实际情况如何处理吧。

一、当前时间
HW中的时间:
引用
# date
2009年 01月 04日 星期日 15:51:02 CST

VPS中的时间:
引用
# vzctl exec 113 date
Mon Jan  4 10:52:19 MSK 2009

很明显,VPS中的时区与HW的不同。

二、修改VPS时间设定
执行:
引用
# vzctl stop 113
Stopping container ...
Container was stopped
Container is unmounted
# vzctl set 113 --capability sys_time:on --save
Saved parameters for CT 113
# vzctl start 113
Starting container ...
Container is mounted
Adding IP address(es): 192.168.100.113
Setting CPU limit: 0
Setting CPU units: 1000
Configure meminfo: 131072
Set hostname: 113.linuxfly.org
Setting quota ugidlimit: 0
Container start in progress...
# vzctl enter 113
entered into CT 113
[root@113 /]# rm /etc/localtime
rm: remove regular file `/etc/localtime'? y
[root@113 ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@113 ~]# date
Mon Jan  4 15:56:56 CST 2009

更详细的信息,请参考之前的日志:[原]解决服务器重启后,时间自动变更的问题注意,不要在VPS中用hwclock -w写入硬件时间。
三、类似问题
类似时区的问题,还有像一些使用习惯的不同。例如,我使用的centos-5-x86_64-default-5.2-20081210.tar.gz,提供的vi不支持颜色显示,可以这样处理:

[root@112 ~]# yum install -y vim-enhanced

然后,在/root/.bashrc中加入:
引用
alias vi='vim'

这样,vi就能直接支持颜色显示了。
Tags: ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]