尝试启动服务
代码语言:javascript复制[root@h101 sbin]# /etc/init.d/ntpd status
ntpd is stopped
[root@h101 sbin]# /etc/init.d/ntpd start
Starting ntpd: /usr/sbin/ntpd: The 'user' option has been disabled. -- built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
ntpd - NTP daemon program - Ver. 4.2.8p4
Usage: ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
[ <server1> ... <serverN> ]
Try 'ntpd --help' for more information.
[FAILED]
[root@h101 sbin]#
报错
原因是配置过程中少加了一些权限特性
解决方法一
去掉用户和组的参数,再次启动
代码语言:javascript复制[root@h101 sbin]# vim /etc/sysconfig/ntpd
[root@h101 sbin]# cat /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
#OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
OPTIONS=" -p /var/run/ntpd.pid -g"
[root@h101 sbin]#
[root@h101 sbin]# /etc/init.d/ntpd start
Starting ntpd: [ OK ]
[root@h101 sbin]# /usr/sbin/ntpd --help
ntpd - NTP daemon program - Ver. 4.2.8p4
Usage: ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
[ <server1> ... <serverN> ]
Flg Arg Option-Name Description
-4 no ipv4 Force IPv4 DNS name resolution
- prohibits the option 'ipv6'
-6 no ipv6 Force IPv6 DNS name resolution
- prohibits the option 'ipv4'
-a no authreq Require crypto authentication
- prohibits the option 'authnoreq'
-A no authnoreq Do not require crypto authentication
- prohibits the option 'authreq'
-b no bcastsync Allow us to sync to broadcast servers
-c Str configfile configuration file name
-d no debug-level Increase debug verbosity level
- may appear multiple times
-D Num set-debug-level Set the debug verbosity level
- may appear multiple times
-f Str driftfile frequency drift file name
-g no panicgate Allow the first adjustment to be Big
- may appear multiple times
-G no force-step-once Step any initial offset correction.
-i --- jaildir built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
-I Str interface Listen on an interface name or address
- may appear multiple times
-k Str keyfile path to symmetric keys
-l Str logfile path to the log file
-L no novirtualips Do not listen to virtual interfaces
-n no nofork Do not fork
- prohibits the option 'wait-sync'
-N no nice Run at high priority
-p Str pidfile path to the PID file
-P Num priority Process priority
-q no quit Set the time and quit
- prohibits these options:
saveconfigquit
wait-sync
-r Str propagationdelay Broadcast/propagation delay
Str saveconfigquit Save parsed configuration and quit
- prohibits these options:
quit
wait-sync
-s Str statsdir Statistics file location
-t Str trustedkey Trusted key number
- may appear multiple times
-u --- user built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
-U Num updateinterval interval in seconds between scans for new or dropped interfaces
Str var make ARG an ntp variable (RW)
- may appear multiple times
Str dvar make ARG an ntp variable (RW|DEF)
- may appear multiple times
-w Num wait-sync Seconds to wait for first clock sync
- prohibits these options:
nofork
quit
saveconfigquit
-x no slew Slew up to 600 seconds
opt version output version information and exit
-? no help display extended usage information and exit
-! no more-help extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
The following option preset mechanisms are supported:
- examining environment variables named NTPD_*
Please send bug reports to: <http://bugs.ntp.org, bugs@ntp.org>
[root@h101 sbin]#
[root@h101 sbin]# ps faux | grep ntp
root 57457 0.5 0.0 107668 1436 pts/0 S 20:42 0:03 | _ watch -n .5 ntpstat
root 57453 0.0 0.0 107672 1436 pts/1 S 20:42 0:00 | _ watch -n 4 ntpq -p
root 58752 24.0 0.0 44148 2244 pts/1 R 20:51 0:00 | _ ntpq -p
root 58755 0.0 0.0 103256 828 pts/2 S 20:51 0:00 | _ grep ntp
root 58705 0.2 0.0 122808 2296 ? Ssl 20:51 0:00 ntpd -p /var/run/ntpd.pid -g
[root@h101 sbin]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
202.120.2.100 ( .INIT. 16 u - 64 0 0.000 0.000 0.000
s2a.time.edu.cn .INIT. 16 u - 64 0 0.000 0.000 0.000
202.112.0.7 .INIT. 16 u - 64 0 0.000 0.000 0.000
gus.buptnet.edu .INIT. 16 u - 64 0 0.000 0.000 0.000
mailgw.xanet.ed .INIT. 16 u - 64 0 0.000 0.000 0.000
dns1.synet.edu. .INIT. 16 u - 64 0 0.000 0.000 0.000
*202.112.26.37 202.112.29.82 3 u 28 64 1 5.193 -33.794 0.000
ntp.glnet.edu.c .INIT. 16 u - 64 0 0.000 0.000 0.000
ns.pku.edu.cn 129.6.15.28 2 u 27 64 1 102.864 23.455 0.000
news.neu.edu.cn .INIT. 16 u - 64 0 0.000 0.000 0.000
[root@h101 sbin]#
[root@h101 tmp]# ntpstat
synchronised to NTP server (202.118.1.130) at stratum 3
time correct to within 268 ms
polling server every 64 s
[root@h101 tmp]#