打赏
Fork me on GitHub

[转+原]chrony

 

本博客已经添加"打赏"功能,"打赏"位置位于右边栏红色框中,感谢您赞助的咖啡.

greenplum,openstack等云计算项目需要集群服务器部署,服务器之间的时间需要同步,但并不是所有机器可以

直接连外网,这时可以用Chrony工具解决。 

解决方法是将其中一台设为时间服务器,然后其它服务器和这台时间服务器同步即可。

 

一. 配置时间服务器

选择一台服务器,IP为10.168.10.10

首先安装Chrony工具(ubuntu系统,其它系统在官网有安装方法)

sudo apt-get install chrony

编辑配置文件:

sudo vi /etc/chrony/chrony.conf

找到下面的内容

server 0.debian.pool.ntp.org offline minpoll 8
server 1.debian.pool.ntp.org offline minpoll 8
server 2.debian.pool.ntp.org offline minpoll 8
server 3.debian.pool.ntp.org offline minpoll 8

将其修改为:

server 1.cn.pool.ntp.org
server 1.asia.pool.ntp.org
server 0.asia.pool.ntp.org

找到并修改下面的内容为自己的IP段,下面的IP为允许访问的IP

allow 10/8
allow 192.168/16
allow 172.16/12

重启chrony服务即可

sudo service chrony restart 

 

二. 其它节点同步时间

其它节点可以是任意系统,类linux系统可以安装chrony,ntpd,windows系直接配置即可

1. 使用chrony工具,安装同上,修改配置文件时,只需要将“server”项修改为上面的时间服务器即可

server 10.168.10.10

2. 使用ntpd 

 在centos系统安装

yum install ntp

修改配置文件,添加“server 10.168.10.10” 到下面的配置文件

vi /etc/ntp.conf

3. windows系统,修改自动同步的时间服务器

 

相关资料:

1. http://docs.openstack.org/liberty/install-guide-ubuntu/environment-ntp.html

2. http://www.chrony.tuxfamily.org/

3. http://www.pool.ntp.org/zone/cn

 

转自:http://www.cnblogs.com/wzy5223/p/5345378.html

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

查看同步:

常用命令 chronyc sources -v   查看同步源

[root@network1 ~]# chronyc sources -v
210 Number of sources = 1

.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? controller0 0 7 0 10y +0ns[ +0ns] +/- 0ns

[root@compute1 ~]# chronyc sources -v
210 Number of sources = 1

.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? controller0 0 7 0 10y +0ns[ +0ns] +/- 0ns

 

常用命令:

timedatectl status

timedatectl set-ntp true/false   //设置远程同步ntp服务器

posted @ 2016-07-04 14:04  my_cool2007  阅读(704)  评论(0编辑  收藏  举报