chrony时间同步服务(3)

//ntp服务器地址
ens35: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.10.20  netmask 255.255.255.0  broadcast 172.16.10.255
        inet6 fe80::da6c:394e:1ef7:c236  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:6e:66:65  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 480 (480.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 21  bytes 1614 (1.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

//客户端同步,时间已经同步正确
[root@ntp-client ~]# ntpdate 172.16.10.20
21 Aug 15:35:10 ntpdate[2421]: step time server 172.16.10.20 offset 252552056.617240 sec
You have new mail in /var/spool/mail/root
[root@ntp-client ~]# date
Tue Aug 21 15:35:15 CST 2018

//第一种方式设置定时任务
[root@ntp-client ~]# which ntpdate
/usr/sbin/ntpdate
[root@ntp-client ~]# crontab -e
*/2 * * * * /usr/sbin/ntpdate 172.16.10.20 &>/dev/null


//第二种方式客户端编辑配置文件服务器指向172.168.10.20
[root@ntp-client ~]# vim /etc/chrony.conf
server 172.16.10.20 iburst

//启动服务查看服务运行状态
[root@ntp-client ~]# systemctl restart chronyd
[root@ntp-client ~]# systemctl status chronyd
● chronyd.service - NTP client/server
  Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
  Active: active (running) since Tue 2018-08-21 15:52:11 CST; 6s ago
    Docs: man:chronyd(8)
          man:chrony.conf(5)
  Process: 3012 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 3009 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 3011 (chronyd)
    Tasks: 1
  CGroup: /system.slice/chronyd.service
          └─3011 /usr/sbin/chronyd

Aug 21 15:52:10 ntp-client systemd[1]: Starting NTP client/server...
Aug 21 15:52:11 ntp-client chronyd[3011]: chronyd version 3.2 starting (+CMDMON +NTP ...G)
Aug 21 15:52:11 ntp-client chronyd[3011]: Frequency -37.840 +/- 1000000.000 ppm read ...ft
Aug 21 15:52:11 ntp-client systemd[1]: Started NTP client/server.
Aug 21 15:52:15 ntp-client chronyd[3011]: Selected source 172.16.10.20
Hint: Some lines were ellipsized, use -l to show in full.

//差不多一分钟同步了
[root@ntp-client ~]# date
Tue Aug 10 08:32:32 CST 2010
[root@ntp-client ~]# date
Tue Aug 10 08:32:33 CST 2010
[root@ntp-client ~]# date
Tue Aug 21 16:04:24 CST 2018
[root@ntp-client ~]# date
Tue Aug 21 16:04:25 CST 2018

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12543.html