linux平台使用ntp搭建自己的时间服务器

前提条件:机器上有可使用的yum源
步骤:
1、安装ntp软件包

yum install ntp

2、启动ntp服务并查看服务是否成功启动

[root@test bin]# systemctl start ntpd.service
[root@test bin]# systemctl status ntpd.service
\u25cf ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
   Active: active (running) since \u4e09 2021-02-24 10:21:59 CST; 4s ago
  Process: 30326 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 30341 (ntpd)
    Tasks: 1
   CGroup: /system.slice/ntpd.service
           \u2514\u250030341 /usr/sbin/ntpd -u ntp:ntp -g

2\u6708 24 10:21:59 test ntpd[30341]: Listen normally on 2 lo 127.0.0.1 UDP 123
2\u6708 24 10:21:59 test ntpd[30341]: Listen normally on 3 enp1s0 192.168.1.3 UDP 123
2\u6708 24 10:21:59 test ntpd[30341]: Listen normally on 4 virbr0 192.168.122.1 UDP 123
2\u6708 24 10:21:59 test ntpd[30341]: Listen normally on 5 lo ::1 UDP 123
2\u6708 24 10:21:59 test ntpd[30341]: Listen normally on 6 enp1s0 fe80::fd5:58ec:b068:c711 UDP 123
2\u6708 24 10:21:59 test ntpd[30341]: Listening on routing socket on fd #23 for interface updates
2\u6708 24 10:21:59 test systemd[1]: Started Network Time Service.
2\u6708 24 10:21:59 test ntpd[30341]: 0.0.0.0 c016 06 restart
2\u6708 24 10:21:59 test ntpd[30341]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
2\u6708 24 10:21:59 test ntpd[30341]: 0.0.0.0 c011 01 freq_not_set

3、假如机器A时间显示不对,可在机器A上执行:

[root@localhost Linux64]# ntpdate 192.168.1.3   --注意:此处IP为步骤1、2中安装了ntp的机器IP
24 Feb 10:48:21 ntpdate[20636]: step time server 192.168.1.3 offset -8122190.555449 sec

同步成功。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值