在TimesTen Scaleout User Guide中提到:
It is important to ensure that the system clocks of every host in your grid are roughly synchronized. Synchronized system clocks ensure that timestamps of transactions and logs are accurate on all hosts.
也就是说,grid成员之间是需要时间同步的,此处不涉及到ZooKeeper主机,因为ZooKeeper服务并不依赖于时间同步机制。
此处我们配置管理服务器(10.0.0.11)为时间同步服务器,其它的数据主机为数据同步客户端,服务使用chrony而非NTP,因为chrony更简洁,也更准确。
在配置前,请确认chrony依据安装:
[oracle@datahost1 ~]$ sudo yum info chrony
Loaded plugins: ulninfo
Installed Packages
Name : chrony
Arch : x86_64
Version : 3.2
Release : 2.0.1.el7
Size : 476 k
Repo : installed
From repo : anaconda
Summary : An NTP client/server
URL : https://chrony.tuxfamily.org
License : GPLv2
Description : A client/server for the Network Time Protocol, this program keeps your
: computer's clock accurate. It was specially designed to support
: systems with intermittent internet connections, but it also works well
: in permanently connected environments. It can use also hardware reference
: clocks, system real-time clock or manual input as time references.
如果未安装:
sudo yum install chrony
默认的/etc/chrony.conf文件内容如下:
[oracle@mgmthost1 ~]$ cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
以下为修改的部分,共两处,含义见英文注释:
...
# Allow NTP client access from local network.
allow 10.0.0.0/24
# Serve time even if not synchronized to a time source.
local stratum 10
...
重启服务,服务器端就配置完成了:
[oracle@mgmthost1 ~]$ sudo systemctl restart chronyd
和服务器端相关的一些命令:
[oracle@mgmthost1 ~]$ chronyc
chrony version 3.2
Copyright (C) 1997-2003, 2007, 2009-2017 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.
chronyc> help
System clock:
tracking Display system time information
makestep Correct clock by stepping immediately
makestep
Configure automatic clock stepping
maxupdateskew Modify maximum valid skew to update frequency
waitsync [ [ [ []]]]
Wait until synchronised in specified limits
Time sources:
sources [-v] Display information about current sources
sourcestats [-v] Display statistics about collected measurements
reselect Force reselecting synchronisation source
reselectdist Modify reselection distance
NTP sources:
activity Check how many NTP sources are online/offline
ntpdata [] Display information about last valid measurement
add server [options]
Add new NTP server
add peer [options]
Add new NTP peer
delete Remove server or peer
burst / [/]
Start rapid set of measurements
maxdelay Modify maximum valid sample delay
maxdelayratio
Modify maximum valid delay/minimum ratio
maxdelaydevratio
Modify maximum valid delay/deviation ratio
minpoll Modify minimum polling interval
maxpoll Modify maximum polling interval
minstratum
Modify minimum stratum
offline [/] Set sources in subnet to offline status
online [/] Set sources in subnet to online status
polltarget
Modify poll target
refresh Refresh IP addresses
Manual time input:
manual off|on|reset Disable/enable/reset settime command
manual list Show previous settime entries
manual delete Delete previous settime entry
settime
客户端也是使用chronyd服务。
修改/etc/chrony.conf文件,对于默认的配置文件,只需要修改移除,即server指向管理服务器的IP地址10.0.0.11:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# server 0.pool.ntp.org iburst
# server 1.pool.ntp.org iburst
# server 2.pool.ntp.org iburst
server 10.0.0.11
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
重启服务:
systemctl restart chronyd
相关监控命令如下:
[oracle@datahost1 ~]$ chronyc
chrony version 3.2
Copyright (C) 1997-2003, 2007, 2009-2017 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.
chronyc> sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* mgmthost1 2 6 377 19 +271us[ +324us] +/- 47ms
chronyc> activity
200 OK
1 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address
chronyc> tracking
Reference ID : 0A00000B (mgmthost1)
Stratum : 3
Ref time (UTC) : Wed Dec 19 10:20:16 2018
System time : 0.000195726 seconds fast of NTP time
Last offset : +0.000053017 seconds
RMS offset : 0.004054334 seconds
Frequency : 3.973 ppm slow
Residual freq : -0.075 ppm
Skew : 23.666 ppm
Root delay : 0.077822976 seconds
Root dispersion : 0.002500026 seconds
Update interval : 64.5 seconds
Leap status : Normal
chronyc> sourcestats
210 Number of sources = 1
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
mgmthost1 8 4 454 -0.075 24.249 -2895ns 1797us
chronyc> exit
检查系统时间同步的设置:
[oracle@datahost1 ~]$ timedatectl
Local time: Wed 2018-12-19 18:21:34 CST
Universal time: Wed 2018-12-19 10:21:34 UTC
RTC time: Wed 2018-12-19 10:21:35
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
在时间同步服务器上可以检查客户端的状态,注意必须用root用户执行,否则报501错:
[oracle@mgmthost1 ~]$ sudo chronyc
chrony version 3.2
Copyright (C) 1997-2003, 2007, 2009-2017 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.
chronyc> clients
Hostname NTP Drop Int IntL Last Cmd Drop Int Last
===============================================================================
localhost 0 0 - - - 1 0 - 278
datahost3 5 0 6 - 6 0 0 - -
datahost1 4 0 6 - 55 0 0 - -
datahost4 4 0 6 - 48 0 0 - -
datahost2 4 0 6 - 33 0 0 - -
chronyc> exit
从管理节点上查询时间:
[oracle@mgmthost1 ~]$ ttGridAdmin hostExec date
Commands executed on:
ttdatahost1 rc 0
ttdatahost2 rc 0
ttdatahost3 rc 0
ttdatahost4 rc 0
ttmgmthost1 rc 0
Return code from ttdatahost1: 0
Output from ttdatahost1:
Wed Dec 19 18:22:27 CST 2018
Return code from ttdatahost2: 0
Output from ttdatahost2:
Wed Dec 19 18:22:27 CST 2018
Return code from ttdatahost3: 0
Output from ttdatahost3:
Wed Dec 19 18:22:27 CST 2018
Return code from ttdatahost4: 0
Output from ttdatahost4:
Wed Dec 19 18:22:27 CST 2018
Return code from ttmgmthost1: 0
Output from ttmgmthost1:
Wed Dec 19 18:22:27 CST 2018