文章目录
1.时间同步服务
我们在进行日志管理的时候,需要客户端的时间与服务器端相同。
chronyd是一个同步系统时钟的守护进程。
1.1 服务端
1)在配置文件中设定:
- 允许哪些客户端来同步本机时间
- 本机作为时间源
[root@server ~]# vim /etc/chrony.conf
# 在第21行添加设定允许123.0.0.0网段的用户获取同步时间
21 # Allow NTP client access from local network.
22 allow 123.0.0.0/24
# 29行设定本机为时间源
28 # Serve time even if not synchronized to any NTP server.
29 local stratum 10
2)重启服务:
[root@server ~]# systemctl restart chronyd.service
1.2 在客户端
1)修改时间同步服务配置文件:
[root@client ~]# vim /etc/chrony.conf
#将第3行的同步源更改为123.0.0.1服务端的IP。
1 # Use public servers from the pool.ntp.org project.
2 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
3 server 123.0.0.1 iburst
4
5 # Ignore stratum in source selection.
2)重新启动时间同步服务
[root@client ~]# systemctl restart chronyd.service
1.3 测试
1)客户端:输入同步命令
[root@client ~]# 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
|| / xxxx = adjusted offset,
|| Log2(Polling interval) -. | yyyy = measured offset,
|| \