CentOS7/Red Hat7 NTP服务无法开机自启动问题解决

原文地址:http://blog.csdn.net/babyfish13/article/details/52502522


centos7不同于以往linux的操作,对于开机自启动的调整,命令有所不同。    chkconfig --list查看非系统内置服务的自启动状态

[html]  view plain  copy
 print ?
  1. [root@master ~]# chkconfig --list  
  2.   
  3. Note: This output shows SysV services only and does not include native  
  4.       systemd services. SysV configuration data might be overridden by native  
  5.       systemd configuration.  
  6.   
  7.       If you want to list systemd services use 'systemctl list-unit-files'.  
  8.       To see services enabled on particular target use  
  9.       'systemctl list-dependencies [target]'.  
  10.   
  11. iprdump         0:off   1:off   2:on    3:on    4:on    5:on    6:off  
  12. iprinit         0:off   1:off   2:on    3:on    4:on    5:on    6:off  
  13. iprupdate       0:off   1:off   2:on    3:on    4:on    5:on    6:off  
  14. netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off  
  15. network         0:off   1:off   2:on    3:on    4:on    5:on    6:off  
  16. vmware-tools    0:off   1:off   2:on    3:on    4:on    5:on    6:off  

    根据提示,要查看系统内置的服务自启动状态需要使用命令systemctl list-unit-files,它会列出系统所有内置服务的自启动状态。
    所以调整ntp的自启动需要在这里调整。

[html]  view plain  copy
 print ?
  1. [root@master ~]# systemctl enable ntpd.service         //开机自启动  
  2.     调整之后重启系统,可是发现ntp并没有启动起来  
  3.   
  4. [root@master ~]# pgrep ntpd                            //无法查看到相关进程  
  5. [root@master ~]# systemctl status ntpd  
  6. ntpd.service - Network Time Service  
  7.    Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)  
  8.    Active: inactive (dead)                                  //显示开机自启动了,但是状态是inactive  

    通过查询发现有一个chronyd服务设置为开机自启动,这个服务导致ntp无法开启自启动

[html]  view plain  copy
 print ?
  1. [root@master ~]# systemctl status chronyd  
  2. chronyd.service - NTP client/server  
  3.    Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled)  
  4.    Active: inactive (dead) since Tue 2014-11-11 08:28:14 CST; 1min 45s ago  
  5. Main PID: 3033 (code=exitedstatus=0/SUCCESS)  
  6.    CGroup: /system.slice/chronyd.service  
  7.   
  8. Nov 11 08:06:31 master.zj.chinamobile.com systemd[1]: Starting NTP clien...  
  9. Nov 11 08:06:31 master.zj.chinamobile.com chronyd[3033]: chronyd version...  
  10. Nov 11 08:06:31 master.zj.chinamobile.com chronyd[3033]: Linux kernel ma...  
  11. Nov 11 08:06:31 master.zj.chinamobile.com chronyd[3033]: hz=100 shift_hz...  
  12. Nov 11 08:06:31 master.zj.chinamobile.com systemd[1]: Started NTP client...  
  13. Nov 11 08:28:14 master.zj.chinamobile.com systemd[1]: Stopping NTP clien...  
  14. Nov 11 08:28:14 master.zj.chinamobile.com systemd[1]: Stopped NTP client...  
  15. Hint: Some lines were ellipsized, use -l to show in full.  

    通过禁止chronyd服务开机自启动之后再将系统重启

[html]  view plain  copy
 print ?
  1. [root@master ~]# systemctl disable chronyd.service   
  2. rm '/etc/systemd/system/multi-user.target.wants/chronyd.service'  
  3.   
  4. [root@master ~]# pgrep ntpd  
  5. 2981  
  6. [root@master ~]# ntpq -p  
  7.      remote           refid      st t when poll reach   delay   offset  jitter  
  8. ==============================================================================  
  9. 10.70.213.132   10.70.91.148     3 u   21   64    1    1.252    0.029   0.000  
  10. *10.70.213.133   10.70.91.148     3 u   21   64    1    1.139   -0.191   0.000  

此时,NTP的服务已经开机自启动了,完成!

说白了,一句话,因为chronyd未被禁用,导致ntpq即使配置了也无法实现开机启动!


备注:

Chrony是一个开源的自由软件,它能保持系统时钟与时钟服务器(NTP)同步,让时间保持精确。是RHEL7中新的ntp对时服务。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值