时间同步"/>
Centos 时间同步
新装的服务器可能设置了错误的,需要调整时区并调整时间.如下是使用NTP来从一个时间服务器同步
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate us.pool.ntp
很简单吧,解析一下,第一句是把当前时区调整为上海就是+8区,想改其他时区也可以去看看/usr/share/zoneinfo目录;
然后第二句是利用ntpdate同步标准时间.
没有安装ntpdate的可以yum一下:
yum install -y ntpdate
加入定时计划任务,每隔10分钟同步一下时钟
crontab -e
0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp | logger -t NTP
中国国家授时中心:
.asp
其他网络时间服务器地址如下:(也可以自己去搜索下)
time.nist.gov (美国)
ntp.fudan.edu (复旦) )(国内用户推荐使用此服务器)
timekeeper.isi.edu
subitaneous.cpsc.ucalgary.ca
usno.pa-x.dec
time.twc.weather
swisstime.ethz.ch
ntp0.fau.de
ntp3.fau.de
time-a.nist.gov
time-b.nist.gov
time-nw.nist.gov
nist1-sj.glassey
210.72.145.44 也是一个不错的地址,速度很快!
.html1)确认已经安装ntp程序包:
# yum install ntp
2)配置时间源
# vi /etc/ntp.conf
server pool.ntp #可选择其他优先服务器
server 0.pool.ntp
server 1.pool.ntp
server 2.pool.ntp
3)配置是否为其他PC提供时间服务
# vi /etc/ntp.conf
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
按I插入修改然后:w保存,并:q!退出
4)配置开机时自动运行时间服务
# chkconfig ntpd on
5)启动或停止时间服务
# service ntpd start
# service ntpd stop
# service ntpd restart
6)验证ntp服务已经运行
# pgrep ntpd
7)初始同步
# ntpdate -u time.lib.tsinghua.edu
8)确认同步成功
# ntpq -p
9)同时建议修改一下 /etc/sysconfig/ntpd 文件
# vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
按I插入修改然后:w保存,并:q!退出
# 改成 yes 吧!这样主机 BIOS 的时间也会跟着一起改变的 !
转载请注明来源: 迷失乐园 » CentOS中时间同步方法
本文链接地址: .html 订阅本站:
更多推荐
Centos 时间同步
发布评论