linux运维基础[日志管理]——————chronyd时间同步、timedatectl设置系统时间、journal日志采集

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,
||                                  \      
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值