NTPD配置指南

合集下载

ntpd -p的参数

ntpd -p的参数

ntpd -p的参数选项使用方法:
•-4:只使用IPv4。

•-6:只使用IPv6。

•-a:在NTP服务器和NTP服务器之间自动选择。

•-A:在NTP服务器和NTP服务器之间强制选择。

•-b:在启动时尝试广播。

•-d:增加调试信息到标准错误输出。

•-D:增加详细的调试信息到标准错误输出。

•-g:强制立即同步时间,而不等待NTP服务器之间的时间调整。

•-G:不使用任何延迟平滑算法。

•-h:打印帮助信息。

•-i:指定一个接口。

•-l:在日志文件中记录事件。

•-L:忽略所有NTP服务器的时间戳。

•-m:在启动时尝试多播。

•-n:只使用非递归模式。

•-N:使用最大可能的速率。

•-o:在启动时尝试单播。

•-p:指定一个PID文件。

•-P:设置NTP服务器的优先级。

•-q:退出并打印一个查询消息。

•-r:设置广播延迟。

•-s:设置统计目录。

•-t:测试时间戳。

•-u:设置用户ID和组ID。

•-U:设置接口更新间隔。

•-v:增加详细输出到标准错误输出。

•-V:打印版本信息并退出。

NTP时间服务器配置

NTP时间服务器配置

NTP时间服务器学习笔记引言NTP时间服务器就是提供时间授权(对时)的服务器,它可以用Linux或Windows系统来架设。

总来说NTP时间服务器理解和配置都相对简单,我们只在此提醒一点NTP通信端口采用udp的123端口。

以下我们以Windows 2008/Redaht5.4作为时间服务器为服务端,Linux和Windows系统为客户端来学习一下。

服务端Windows NTP服务器默认情况下,独立服务器WINDOWS SERVER 2008是作为NTP客户端工作的,所以必须通过修改注册表,以使系统作为NTP服务器运行。

工作之前请先备份注册表文件。

1、修改以下选项的键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServe r内的[Enabled]设定为1。

打开NTP服务器功能(默认是不开启NTP Server服务,除非电脑升级成为域控制站)。

2、修改以下键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\AnnounceFlags 设定为5.该设定强制主机将它自身宣布为可靠的时间源,从而使用内置的互补金属氧化物半导体(CMOS) 时钟。

如果要采用外面的时间服务器就用默认的a值即可.# 210.72.145.44 (国家授时中心服务器IP地址)3、修改以下键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\Type内的[Type]设定为NTP。

4、重启Win32Time服务:先关闭windows time 服务,再开启该服务。

可以在“管理工具”的“服务”界面下完成,也可以以DOS 方式输入“net stop w32time”、“net start w32time”。

NTPD配置指南

NTPD配置指南

NTPD配置指南本配置指南适用于使用NMEA格式gps,本文假定该gps使用$GPRMC格式数据,波特率为9600bps。

测试环境:操作系统,ubuntu11.10。

内核linux-3.1.6.tar.bz2。

ntp版本ntp-4.2.6p5.tar.gz,PPS测试工具ago-pps-tools-6b14c72.tar.gz,头文件ppsclock.h。

假定本机IP地址为192.168.1.1。

1.编译内核:$tar -xjvf linux-3.1.6.tar.bz2$cd linux-3.1.6$cp /boot/config-3.0.0-12-generic .config$make menuconfig选择以下驱动│┌─────────────────────────────────────────────────────────────────────┐│││ <*> PPS support ││││ [ ] PPS debugging messages ││││ *** PPS clients support *** ││││ <*> Kernel timer client (Testing client, use for debug) ││││ <*> PPS line discipline ││││ < > Parallel port PPS client ││││ *** PPS generators support ***{*} 8250/16550 and compatible serial support ││││ [*] Console on 8250/16550 and compatible serial port ││││ <*> 8250/16550 PCI device support$make$make modules$make modules_install$make install$reboot选择新内核启动系统$ cd /usr/include$ mv linux linux.old$ mv asm asm.old$ mv asm-generic asm-generic.old$ ln -s /lib/modules/$(uname -r)/build/include/linux linux$ ln -s /lib/modules/$(uname -r)/build/arch/x86/include/asm asm$ ln -s /lib/modules/$(uname -r)/build/include/asm-generic asm-generic$ cd /usr/include$ cp /usr/src/pps-tools/timepps.h timepps.h$ cp /usr/src/pps-tools/ppsclock.h ppsclock.h2.编译ntp$ sudo apt-get install ntp 获取相应的配置文件进入ntp-4.2.6p5目录$./configure --disable-all-clocks --enable-NMEA --enable-SHM --enable-ATOM --enable-LOCAL-CLOCK --disable-parse-clock$make;make install3.配置启动环境修改/etc/init.d/ntp文件第50行删除内容NTPD_OPTS="$NTPD_OPTS -u $UGID" 中的文字-u $UGID将16行的DAEMON=/usr/sbin/ntpd改为DAEMON=/usr/local/bin/ntpd15行下增加几行,这里假定使用串口4,此时的串口设备为/dev/ttyS4,如果使用其他串口,将下面的串口设备名做相应的修改:if [ ! -e /dev/pps1 ] ;thenldattach PPS /dev/ttyS4fiif [ -e /dev/gps0 ] ;thenrm -f /dev/gps0fiif [ -e /dev/gpspps0 ] ;thenrm -f /dev/gpspps0filn -s /dev/ttyS4 /dev/gps0ln -s /dev/pps1 /dev/gpspps0setserial /dev/ttyS4 low_latency4.配置ntpd启动文件更改配置文件/etc/ntp.conf去掉其他以server 开头的行,取消从网络获取时间编辑ntp.conf 方法:vim /etc/ntp.conf 回车进入界面,按i插入,编辑完成后,按ESC,按shift+Z 两次之后 /etc/init.d/ntp restart 回车启动ntp配置方法一:(推荐使用,同步更快,误差更小):增加一下两行:server 127.127.20.0 mode 17 minpoll 4 maxpoll 4 preferfudge 127.127.20.0 flag1 1 flag3 1 time2 0.085 (0.182)上面的time2 0.085 需要准确测量,它为秒脉冲前沿到串行数据结束之间的时间差,单位为秒。

NTPD手册

NTPD手册

NTPD手册LINUX环境:Linux localhost.localdomain 2.6.23.1-42.fc8 #1 SMP Tue Oct 30 13:55:12 EDT 2007 i686 i686 i386 GNU/LinuxTERM=linuxSHELL=/bin/bashHISTSIZE=1000USER=rootCCACHE_DIR=/var/cache/ccachePA TH=/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/arm/3.4.1/bin:/usr/local/sbin:/usr/local/b in:/sbin:/bin:/usr/sbin:/usr/bin:/root/binPWD=/mnt/hgfs/exchangeCCACHE_UMASK=002LANG=en_US.UTF-8HOME=/rootLOGNAME=rootCVS_RSH=sshG_BROKEN_FILENAMES=1_=/bin/envOLDPWD=/mnt/hgfsGCC:Reading specs from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/specsConfigured with: /work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/usr/local/arm/3.4.1 --with-headers=/usr/local/arm/3.4.1/arm-linux/include --with-local-prefix=/usr/local/arm/3.4.1/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-longThread model: posixgcc version 3.4.1(3.3.2也可以)配置命令:./configure --build=i386-pc-linux-gnu --host=arm-linux --target=arm-linux配置文件:config.hPPS API:timepps.hNTPD版本:4.2.4p4修改后的config.h和Makefile见目录。

Linux时间同步,ntpd,ntpdate-简单设置

Linux时间同步,ntpd,ntpdate-简单设置

linux时间同步,ntpd、ntpdate在Windwos中,系统时间的设置很简单,界面操作,通俗易懂。

而且设置后,重启,关机都没关系。

系统时间会自动保存在Bios的时钟里面,启动计算机的时候,系统会自动在Bios里面取硬件时间,以保证时间的不间断。

但在Linux下,默认情况下,系统时间和硬件时间,并不会自动同步。

在Linux运行过程中,系统时间和硬件时间以异步的方式运行,互不干扰。

硬件时间的运行,是靠Bios电池来维持,而系统时间,是用CPU tick来维持的。

在系统开机的时候,会自动从Bios中取得硬件时间,设置为系统时间。

一.Linux系统时间的设置在Linux中设置系统时间,可以用date命令://查看时间[root@localhost ~]# date2008年12月12日星期五14:44:12 CST//修改时间[root@localhost ~]# date --set "1/1/09 00:01" <== (月/日/年时:分:秒)2009年01月01日星期四00:01:00 CST//date 有几种时间格式可接受,这样也可以设置时间:[root@localhost ~]# date 012501012009.30 <== 月日时分年.秒2009年01月25日星期日01:01:30 CST二.Linux硬件时间的设置硬件时间的设置,可以用hwclock或者clock命令。

其中,clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。

//查看硬件时间可以是用hwclock ,hwclock --show 或者hwclock -r[root@localhost ~]# hwclock --show2008年12月12日星期五06时52分07秒-0.376932 seconds//设置硬件时间[root@localhost ~]# hwclock --set --date="1/25/09 00:00" <== 月/日/年时:分:秒[root@localhost ~]# hwclock2009年01月25日星期日00时00分06秒-0.870868 seconds三.系统时间和硬件时间的同步同步系统时间和硬件时间,可以使用hwclock命令。

NTP时间服务器配置

NTP时间服务器配置

NTP服务器配置实验环境:RHEL5Server:192.168.2.10Client:192.168.2.120一、搭建时间同步服务器1、编译安装ntp serverrpm -qa | grep ntp2、修改ntp.conf配置文件vi /etc/ntp.conf①、第一种配置:允许任何IP的客户机都可以进行时间同步#restrict default kod nomodify notrap nopeer noqueryrestrict default modify notrap②、第二种配置:只允许192.168.2.0网段的客户机进行时间同步在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap3、启动ntp服务service ntpd start开机启动服务chkconfig --level 35 ntpd on4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。

二、配置时间同步客户机手工执行ntpdate <ntp server> 来同步或者利用crontab来执行crontab -e0-59/10 * * * * /usr/sbin/ntpdate 192.168.2.10 >> /root/ntpdate.log 2>&1表示每隔10分钟同步一次时间三、在服务端验证:# watch ntpq -pEvery 2.0s: ntpq -p Tue Dec 7 05:52:55 2010remote refid st t when poll reach delay offset jitter====================================================================== ========*LOCAL(0) .LOCL. 8 l 22 64 377 0.000 0.000 0.001服务正常运行在客户端进行同步验证:# ntpdate -d 192.168.2.107 Dec 05:54:42 ntpdate[3627]: ntpdate 4.2.2p1@1.1570-o Thu Nov 26 11:35:07 UTC 2009 (1) Looking for host 192.168.2.10 and service ntphost found : 192.168.2.10transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)server 192.168.2.10, port 123stratum 9, precision -20, leap 00, trust 000refid [192.168.2.10], delay 0.02632, dispersion 0.00061transmitted 4, in filter 4reference time: d0a890f1.b4d040ff Tue, Dec 7 2010 5:54:41.706originate timestamp: d0a89102.09318178 Tue, Dec 7 2010 5:54:58.035transmit timestamp: d0a890f2.3c8effe2 Tue, Dec 7 2010 5:54:42.236filter delay: 0.02910 0.02632 0.02808 0.026410.00000 0.00000 0.00000 0.00000filter offset: 15.80026 15.79880 15.79793 15.798370.000000 0.000000 0.000000 0.000000delay 0.02632, dispersion 0.00061offset 15.7988017 Dec 05:54:42 ntpdate[3627]: step time server 192.168.2.10 offset 15.798801 sec附:当用ntpdate -d 来查询时会发现导致no server suitable for synchronization found 的错误的信息有以下2个:错误1.Server dropped: Strata too high在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误。

NTP时间同步客户端配置步骤

NTP时间同步客户端配置步骤

如果想设置NTP客户端,与时间服务器同步,可以采用如下步骤
1、客户端查询NTP服务器
ntp客户端使用 ntpdate 命令来确认是否可用指定的 ntp 服务器进行时间同步,命令的结果会显示客户端与服务器的时间偏移。
#ntpdate -d 192.168.30.221
……
18 Mar 10:52:54 ntpdate[23578]: step time server 192.168.30.221 offset 86323.068272 sec
c. driftfile /etc/ntp.drift
(3)编辑/etc/rc.config.d/netdaemons
更改一个参数:
export XNTPD=1 下次重启主机仍然生效
(4)启动xntpd
#date
Wed Mar 19 11:06:54 BEIST 2003
2、编辑 NTP 客户端上的 /etc/ntp.conf文件
内容如下:
#vi /etc/ntp.conf
—————————-
#broadcastclient
server 192.168.30.221
driftfile /etc/ntp.drift
touch
server 133.64.5.84/132.129.24.6
fudge 133.64.5.83 stratum 8
driftfile /etc/ntp.drift
IBM AIX:
xntpd是一个关于网络时间协议的守护进程,它遵循了因特网时间服务器的通用标准。在启动 xntpd 时, xntpd 会读取/etc/ntp.conf 配置文件来确定网络中系统时钟服务器,以ntp 服务器的系统时间为标准,来调整本机的系统时间。

海康威视NVR如何配置NTP和DST说明书

海康威视NVR如何配置NTP和DST说明书

How to configure NTP and DSTPurposeSometime the device date/time may be incorrect. In order to avoid this, HIKVISION devices use NTP (Network Time Protocol) as well as DST (Daylight Saving Time) to adjust device time.How to configure NTP:Steps:1. Enter the Network Settings interface.Menu >Configuration> Network2. Select the NTP tab to enter the NTP Settings interface. Check the Enable NTP checkbox to enable this feature.4. Configure the following NTP settings:•Interval: Time interval between the two synchronizing actions with NTP server. The unit is minute.•NTP Server: IP address of NTP server.•NTP Port: Port of NTP server. Default as 123.5. Click the Apply button to save and exit the interface.6. Or configure it via web browser in the interface below.Note:The time synchronization interval can be set from1 to 10080min, and the default value is60min. If the NVR is connected to a public network, you should use a NTP server that has a time synchronization function, such as the server at the National Time Center (IP Address: 210.72.145.44). If the NVR is setup in a more customized network, NTP software can be used to establish a NTP server used for time synchronization.How to configure DST:Steps:1. Enter the General Settings interface.Menu >Configuration>General2. Choose DST Settings tab.You can check the checkbox of Auto DST Adjustment item.Or you can manually check the Enable DST checkbox, and then you choose the date/time of the DST period.3. Or configure it via web browser in the interface below.Note:1. When it is daylight saving time, if you just enable NTP without DST enabled, your device time may not be synchronized with local DST time. The solution is to enable DST.2. If you have an IPC added to NVR, just set NTP and DST in NVR would be OK. The device time of IPC would be synchronized by NVR.First Choice for Security Professionals HIK VISION Technical Support。

NTP校时步骤

NTP校时步骤

设置平台的NTP校时服务有两种方式一、如果平台不对前端进行校时,可以通过设置“定时用ntpdate向NTP服务器读取时间”的方式。

1.关闭ntpd服务(ntpd开启时,无法使用ntpdate工具向校时源读取时间)service ntpd stopchkconfig ntpd off2.打开crond服务(crond是定时计划工具,我们用来配置定时去向校时源读取时间)chkconfig crond on(设置为开机启动)service crond restart3.配置crond服务,把“00 */30 ** * root /usr/sbin/ntpdate192.168.0.240;/sbin/hwclock -w”写入到/etc/crontab文件里,该设置为30分钟读取一次时间。

可以手动去修改文件,也可以通过下列语句完成echo “00 */30 * * * root /usr/sbin/ntpdate 192.168.0.240(时间服务器IP);/sbin/hwclock -w” >>/etc/crontab4.测试,把平台时间改掉,看半小时后时间是否能改回来;也可以把配置里30分钟往小了改,重启服务(service crond restart),测试完成后再改回来。

二、如果平台需要对前端进行校时,则建议用ntpd服务来向NTP服务器读取时间。

1.修改ntpd的配置文件,设定校时源vi /etc/ntp/conf在里面加上server 192.168.1.100(时间服务器)保存2.设置自动将软件时间写入硬件时间vi /etc/sysconfig/ntpd在结尾加上SYNC_HWCLOCK=yes保存service ntpd restartchkconfig ntpd on(设置为开机启动)3.测试ntpq -p查看NTP服务与外部服务器的交互状态,里面的具体含义可百度可以先给系统配一个错误的时间,等5分钟,看时间是否会自动校正。

NTPD配置指南

NTPD配置指南

NTPD配置指南本配置指南适用于使用NMEA格式gps,本文假定该gps使用$GPRMC格式数据,波特率为9600bps。

测试环境:操作系统,ubuntu11.10。

内核linux-3.1.6.tar.bz2。

ntp版本ntp-4.2.6p5.tar.gz,PPS测试工具ago-pps-tools-6b14c72.tar.gz,头文件ppsclock.h。

假定本机IP地址为192.168.1.1。

1.编译内核:$tar -xjvf linux-3.1.6.tar.bz2$cd linux-3.1.6$cp /boot/config-3.0.0-12-generic .config$make menuconfig选择以下驱动│┌─────────────────────────────────────────────────────────────────────┐│││ <*> PPS support ││││ [ ] PPS debugging messages ││││ *** PPS clients support *** ││││ <*> Kernel timer client (Testing client, use for debug) ││││ <*> PPS line discipline ││││ < > Parallel port PPS client ││││ *** PPS generators support ***{*} 8250/16550 and compatible serial support ││││ [*] Console on 8250/16550 and compatible serial port ││││ <*> 8250/16550 PCI device support$make$make modules$make modules_install$make install$reboot选择新内核启动系统$ cd /usr/include$ mv linux linux.old$ mv asm asm.old$ mv asm-generic asm-generic.old$ ln -s /lib/modules/$(uname -r)/build/include/linux linux$ ln -s /lib/modules/$(uname -r)/build/arch/x86/include/asm asm$ ln -s /lib/modules/$(uname -r)/build/include/asm-generic asm-generic$ cd /usr/include$ cp /usr/src/pps-tools/timepps.h timepps.h$ cp /usr/src/pps-tools/ppsclock.h ppsclock.h2.编译ntp$ sudo apt-get install ntp 获取相应的配置文件进入ntp-4.2.6p5目录$./configure --disable-all-clocks --enable-NMEA --enable-SHM --enable-ATOM --enable-LOCAL-CLOCK --disable-parse-clock$make;make install3.配置启动环境修改/etc/init.d/ntp文件第50行删除内容NTPD_OPTS="$NTPD_OPTS -u $UGID" 中的文字-u $UGID将16行的DAEMON=/usr/sbin/ntpd改为DAEMON=/usr/local/bin/ntpd15行下增加几行,这里假定使用串口4,此时的串口设备为/dev/ttyS4,如果使用其他串口,将下面的串口设备名做相应的修改:if [ ! -e /dev/pps1 ] ;thenldattach PPS /dev/ttyS4fiif [ -e /dev/gps0 ] ;thenrm -f /dev/gps0fiif [ -e /dev/gpspps0 ] ;thenrm -f /dev/gpspps0filn -s /dev/ttyS4 /dev/gps0ln -s /dev/pps1 /dev/gpspps0setserial /dev/ttyS4 low_latency4.配置ntpd启动文件更改配置文件/etc/ntp.conf去掉其他以server 开头的行,取消从网络获取时间编辑ntp.conf 方法:vim /etc/ntp.conf 回车进入界面,按i插入,编辑完成后,按ESC,按shift+Z 两次之后 /etc/init.d/ntp restart 回车启动ntp配置方法一:(推荐使用,同步更快,误差更小):增加一下两行:server 127.127.20.0 mode 17 minpoll 4 maxpoll 4 preferfudge 127.127.20.0 flag1 1 flag3 1 time2 0.085 (0.182)上面的time2 0.085 需要准确测量,它为秒脉冲前沿到串行数据结束之间的时间差,单位为秒。

ntp服务和客户端详细配置

ntp服务和客户端详细配置

ntp服务和客户端详细配置ntp同步时间实验服务端IP 192.168.1.101 客户端 192.168.1.88⼀.登录server端1.⾸先配置ntpd服务vi /etc/ntp.conf配置⽂件中⼀般有restrict default语句,#掉后选择,以下2种的⼀种restrict default nomodify notrap noquery # 默认允许所有可连接客户端ntpdate到本机restrict default ignore # 默认所有客户端禁⽌ntpdate到本机#与上级服务端连续性同步时间,prefer表⽰优先,如⽆可不设置server 上级ntp服务器IP或者域名 [prefer]#当之前设置了restrict default ignore的情况下,可以设置哪些客户可以ntpdate到本机restrict 192.168.1.88 mask 255.255.255.255 nomodify notrap#其余为可选设置,以默认值即可2.开启ntpd服务service ntpd startchkconfig ntpd on #设置为默认启动,关掉使⽤off⼆.登录客户端此时有2种办法,⼀种是客户端使⽤ntpdate + crontab的组合,另⼀种是客户端也开启ntpd服务1.第⼀种办法ntpdate + crontab1)#先确保⽹络通ping 192.168.1.1012)#使⽤ntpdate同步⼀次时间,查看是否有正确回显ntpdate 192.168.1.101#如为以下报错,⼀般是因为服务端才开启,需要等5分钟左右就好了[root@test ~]# ntpdate 192.168.1.1015 Nov 05:25:51 ntpdate[3892]: no server suitable for synchronization found#如显⽰以下信息表⽰成功[root@test ~]# ntpdate 192.168.1.1017 Nov 22:34:59 ntpdate[4546]: step time server 192.168.1.101 offset 2.946644 sec 3)#这样就可以将ntpdate命令放⼊crontab中,定期执⾏crontab -e添加⼀条,如* 1 * * * * ntpdate 192.168.1.101 #每天1点执⾏ntpdate命令进⾏同步保存即可这⾥可能碰见的其他问题:服务端开启了防⽕墙,没有允许ntpd的端⼝123被访问执⾏ service iptables stop 可以关闭防⽕墙2.第⼆种⽅法ntpd1)#先确保⽹络通ping 192.168.1.1012)#使⽤ntpdate同步⼀次时间,查看是否有正确回显ntpdate 192.168.1.1013)#设置ntpd服务vi /etc/ntp.conf⽅法同上,但注意将设置的上级ntp server端需要设置为server 192.168.1.101 prefer#设置开启服务后⾃动同步上级ntp server时间vi /etc/ntp/step-tickers 加⼊⼀条192.168.1.1014)#开启ntpd服务service ntpd startchkconfig ntpd on #设置为默认启动,关掉使⽤off ————————————————————————————————————————————————其他注意事项:1.如需做时间调整,也需要暂停ntpd服务后,调整,调整之后再开启ntpd服务2.查看ntp服务状态信息的命令ntpq -pntpstatntptrace 192.168.1.1013.检查ntp端⼝是否正常开启(服务是否开启)netstat -tunl | grep 1234.查看防⽕墙状态service iptables status。

NTP配置手册

NTP配置手册

Linux客户端Ntp时间同步配置手册1、NTP服务开机自动加载:1.1首先查看ntpd的服务是否在客户端开机时自动重启:chkconfig --list |grep ntpd //查看ntpd服务开启情况1.2设置NTP服务在下一次开机运行状态:chkconfig ntpd on //开机自动运行chkconfig ntpd off //关闭开机自动运行ntp服务2、修改/etc/ntp.conf文件:2.1通过命令more /etc/ntp.conf查看ntp.conf文件下的内容2.2指定时间同步服务器:restrict 10.150.210.72 mask 255.255.255.0 nomodify notrap noquery server 10.150.210.72备注:此命令必须加载到server 127.127.1.0 # local clock之前。

2.3指定NTP服务器日志文件:logfile /var/log/ntp2.4注销如下命令行:#server #server #server 3、修改/etc/ntp/step-tickers文件3.1通过more /etc/ntp/step-tickers查看文件内容;3.2通过vi /etc/ntp/step-tickers进行编辑文件,增加如下内容10.150.210.72 //ntp服务器位置127.127.1.0 //Linux客户端本地位置4、修改/etc/sysconfig/ntpd文件,允许BIOS与系统时间同步4.1通过vi etc/sysconfig/ntpd进行编辑,更改如下内容:SYNC_HWCLOCK=no改为yes5、通过service ntpd start开启ntpd服务;6、测试NTP时间同步6.1通过ntpq –p 查看偏移量6.2通过ntpdate –d 10.150.210.72进行测试如果出现transmit(10.150.210.72)receive(10.150.210.72) 则配置正确。

ntpd用法

ntpd用法

ntpd用法
ntpd是ntp daemon的缩写,是一个系统后台进程,用来同步本地系统时钟和远程NTP 时间服务器的时间,或者其他参考时间源。

以下是ntpd的一些常用用法:- 配置文件:ntpd通常需要一个配置文件/etc/ntp.conf,ntpd后面的选项和命令可以写在该配置文件中。

也可以在ntpd后面接相应指令,让ntpd不考虑该配置文件。

- 工作模式:ntpd可以工作在client/server模式、symmetric模式、broadcast模式。

- 自动发现:ntpd可以自动发现远程服务器并自动配置。

- 调整时间:ntpd通常连续工作,隔一段时间调整一次系统时间。

也可以在调整完系统时间后自动退出,如果没有收到NTP服务器的回复,将会超时退出。

- 命令选项:ntpd有很多命令选项,例如-4、-6、-t、-a、-b、-r、-c、-f、-k、-l、-p、-s、-q、-g、-x、-n、-N、-M、-d、-D等,可以根据需要选择使用。

总的来说,ntpd是一个功能强大的时间同步工具,可以帮助你管理系统时钟。

在使用ntpd时,需要根据具体需求进行配置和操作。

如需了解更多关于ntpd的信息,可以参考相关文档或技术资料。

(完整word版)NTP服务器及客户端配置手册

(完整word版)NTP服务器及客户端配置手册

NTP时间同步配置说明目录1。

1 Linux NTP Server配置 (1)1。

2 AIX系统时间配置 (3)1。

3 Linux系统时间同步配置 (5)1。

4 Windows 2003系统时间同步配置 (7)1。

5 Windows 7 & Windows 2008系统时间同步配置 (11)1.6 ESXi系统时间同步配置 (16)1.7 Suse Linux 系统时间同步配置 (18)1。

8 HP-UX NTP配置 (20)1.1 Linux NTP Server配置1.检查NTP安装包#rpm —qa | grep ntpntp—4.2.6p5—10。

el6.x86_64ntpdate—4。

2。

6p5-10。

el6.x86_642.NTP配置文件/etc/ntp。

conf#vim /etc/ntp。

confdriftfile /var/lib/ntp/drift例:restrict 11。

1。

71。

0 mask 255。

255.255.0 nomodify noquery notrap #设置向11。

1.71.1-11。

1。

71.254段的主机提供NTP同步服务server 210.72。

145。

44 #中国国家授时中心IPserver [local IP address] prefer #prefer 表示优先使用此地址进行时间同步Server 127。

127.1.0 # local clock #外界同步源不可用时将用本地时间提供时间同步服务fudge 127.127。

1。

0 stratum 2 #stratum是定义时间服务器层级,0表示为最顶级;如果需要从别的NTP服务器更新时间,请修改为非0SYNC_HWCLOCK=yes #允许BIOS与系统时间同步,也可以通过hwclock -w命令权限管理使用 restrict 公式如下:restrict IP mask [参数]/ restrict 192。

如何配置NTP服务器

如何配置NTP服务器

如何配置NTP服务器NTP(Network Time Protocol)是一种用于同步计算机时钟的协议,它能够确保网络上的设备拥有一致准确的时间。

配置 NTP 服务器可以使得其他计算机通过网络同步其时钟,确保整个网络系统的时间一致性。

以下是一种基本的 NTP 服务器配置方法,共分为四个步骤:第一步:安装NTP服务器软件首先,需要在服务器上安装 NTP 软件。

常见的 NTP 软件有 ntpd、chronyd等。

这里我们以 ntpd 为例进行配置。

在 Linux 系统上,安装ntpd 通常使用以下命令:```bashsudo apt-get install ntp```安装完成后,NTP服务器将会自动启动。

第二步:选择合适的时间源NTP协议需要从一个可靠的时间源同步时间。

可以选择使用官方提供的公共NTP服务器或者使用自己的时钟源。

对于大多数情况,使用官方的公共NTP服务器是最简单且可靠的。

可以在NTP官方网站上查找可用的NTP服务器列表,并选择距离自己服务器最近的服务器。

如果你有自己的时钟源,可以使用GPS接收器、原子钟或者其他时间源作为NTP服务器的上游源。

```restrict default kod nomodify notrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noqueryrestrict 127.0.0.1restrict ::1server <NTP服务器IP地址> iburst```在配置文件中,restrict 选项表示限制 NTP 服务器允许连接的客户端的权限。

这里我们限制了只有本地的机器可以连接。

server 选项用于指定上游 NTP 服务器的 IP 地址。

添加完配置后,保存并关闭文件。

配置完成后,需要重新启动NTP服务器以使配置生效。

在终端中运行以下命令:```bashsudo service ntp restart```这会重新启动NTP服务器并应用新的配置。

NTP服务器配置方法

NTP服务器配置方法
一、Linux服务器的NTP设置
配置NTP架设本地时间服务器
NTP是用来使系统和一个精确的时间源保持时间同步的协议.在Linux下,我们可以通过自带的NTP(Network Time Protocol)协议通过网络使自己的系统保持精确的时间.
安装:
# yum install ntp
将同步好的时间写到CMOS里
vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
切记每次修改了配置文件后都需要重新启动服务来使配置生效。可以使用下面的命令来检查NTP服务是否启动,你应该可以得到一个进程ID号:
# pgrep ntpd
使用下面的命令检查时间服务器同步的状态:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient\SpecialPollTimeRemaining=192.168.1.1,0 (192.168.1.1替换为实际的NTP服务器IP)
# ntpq -p
用ntpstat 也可以查看一些同步状态,用netstat -ntlup查看端口使用情况!
安装完毕客户端需过5-10分钟才能从服务器端更新时间!
客户端设置:
# crontab -e
加入一行:
*/15 * * * * ntpdate 服务器端IP。
【客户端设置】
方法1) <-该方法未测试成功
修改注册表以下键值:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient\SpecialPollInterval=43200 (十进制)

ntpd用法 -回复

ntpd用法 -回复

ntpd用法-回复“ntpd用法”是关于网络时间协议守护进程(Network Time Protocol Daemon,简称ntpd)的使用指南和配置说明。

该文章将逐步回答关于ntpd的基本定义、功能和用法、安装和配置以及常见问题的提问。

第一部分:基本定义和功能介绍首先,我们来了解一下ntpd的基本定义和功能。

ntpd是一种守护进程,用于同步本地计算机的系统时间与全球标准时间(UTC)或网络时间服务器提供的时间同步。

ntpd通过网络时间协议(NTP)进行时间同步,并实现精确度高、可靠性好的时钟同步服务。

ntpd的工作原理是通过与网络中的一组时间服务器进行通信,获取更精确的时间信息,并将其应用于本地系统时钟。

ntpd会不断地监测和调整系统时钟,以确保其与网络时间服务器的时间保持一致。

第二部分:ntpd的用法和常用命令接下来,我们将讨论ntpd的用法和常用命令。

ntpd的主要命令是ntpd,它可以在终端窗口中直接执行。

下面是一些常用的ntpd命令:1. 启动ntpd服务:sudo ntpd -p该命令将启动ntpd服务,并使用默认的配置文件进行工作。

2. 手动时间同步:sudo ntpd -q该命令将强制ntpd立即与时间服务器进行通信,并进行手动时间同步。

3. 停止ntpd服务:sudo ntpd -g该命令将停止ntpd服务,并允许时间调整超过系统默认时钟调整阈值。

4. 显示ntpd状态:ntpq -p该命令将显示与ntpd同步的时间服务器列表和其状态信息。

除了这些命令之外,ntpd还支持其他一些选项和参数,可以通过man ntpd命令查看详细的帮助文档。

第三部分:ntpd的安装和配置现在,我们来讨论ntpd的安装和配置。

ntpd在大多数操作系统上都是预安装的,但需要进行一些简单的配置才能正常工作。

1. 安装ntpd:对于Debian或Ubuntu系统:sudo apt-get install ntp对于CentOS或Red Hat系统:sudo yum install ntp2. 配置ntpd:配置文件位于/etc/ntp.conf。

ntpd配置

ntpd配置

ntpd配置修改配置文件/etc/ntp.conf添加允许使用该ntpd服务器的服务器restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap将同步好的时间写到CMOS里vi /etc/sysconfig/ntpdSYNC_HWCLOCK=yes斜体部分是我添加的部分,设定可以使用时间服务器的两个网段的内网地址及使用的外部的时间服务器。

现在我们对配置做一个简要的解释:第一行restrict、default定义默认访问规则,nomodify禁止远程主机修改本地服务器配置,notrap拒绝特殊的ntpdq捕获消息,noquery拒绝btodq/ntpdc查询(这里的查询是服务器本身状态查询)。

配置文件的最后两行作用是当服务器与公用的时间服务器失去联系时以本地时间为客户端提供时间服务。

端口ntp使用udp协议,记得开放其123端口,注意,否则出现下面的错误,no server suitable for synchronization found启动NTPD启动ntpd守护进程:service ntpd start检查服务器同步状态:ntpq -p客户端的配置以root身份运行周期性任务:[root@supersun root]# crontab -e添加以下内容,每15分钟更新一下时间:*/15 * * * * ntpdate 192.168.7.244此处的ntpdate命令包含在ntp软件包中,记得确认系统中是否已安装。

检查服务器同步状态:ntptrace 192.168.server.ip关于错误8 Jul 18:20:45 ntpdate[4949]: no server suitable for synchronization found使用 -d 命令查看错误ntpdate -d 192.168.7.2448Jul18:20:45ntpdate[4949]:*********************************:14:10UTC2008(1)Looking for host 192.168.7.244 and service ntphost found : rac01transmit(192.168.7.244)receive(192.168.7.244)transmit(192.168.7.244)receive(192.168.7.244)transmit(192.168.7.244)receive(192.168.7.244)transmit(192.168.7.244)receive(192.168.7.244)transmit(192.168.7.244)192.168.7.244: Server dropped: strata too highserver 192.168.7.244, port 123stratum 16, precision -20, leap 11, trust 000refid [192.168.7.244], delay 0.02615, dispersion 0.00050transmitted 4, in filter 4reference time: 00000000.00000000 Thu, Feb 7 2036 14:28:16.000originate timestamp: cc1d6e5e.ef02c0d8 Tue, Jul 8 2008 12:41:02.933transmit timestamp: cc1dbdfd.3e598e10 Tue, Jul 8 2008 18:20:45.243filter delay: 0.02759 0.02615 0.02753 0.027450.00000 0.00000 0.00000 0.00000filter offset: -20382.3 -20382.3 -20382.3 -20382.30.000000 0.000000 0.000000 0.000000delay 0.02615, dispersion 0.00050offset -20382.3099958 Jul 18:20:45 ntpdate[4949]: no server suitable for synchronization found解决:How about issuing the command "ntpq -p" on the server that's not synchronizing and posting the output? That will tell us which internet servers it can see, if any. My first guess would be that if it's not synchronized, it's because it can't establish contact with anything to synchronize with.My second guess is that it might fail to synchronize because its own local clock is too far off. If it's more than five minutes off, set the local clock to approximately the correct time before starting ntp.Finally, it might be failing to synchronize because your local clock is drifting too fast. If the undisciplined local clock gains or loses toomuch, it will never synchronize and stay synchronized. The limit isabout 500 parts per million.用ntp同步时间, 出现the NTP socket is in use,exiting如果使用了计划任务在crontab里只执行,就关闭ntpd服务*/15 * * * * ntpdate 210.72.145.44service ntpd stopQ:I have a machine which serves as NTP server. This machine has more (3) Network interfaces (+ loopback). By default NTP "binds" itself to all available interfaces, i.e. it listens on port 123 on all interfaces:netstat -an|grep 123udp 0 0 127.0.0.1.123 *.*udp 0 0 1.2.3.4.123 *.*udp 0 0 *.123 *.*udp 0 0 1.2.5.4.123 *.*udp 0 0 1.2.6.4.123 *.*I would like to "bind" NTP to only one interface, say the 1.2.3.4. Is it possible? I do not find any hint on the net.P:As far as I know, no version of (x)ntpd can do this.As an alternative, you could use the "restrict" directive in /etc/ntp.conf file to make the NTP server ignore any communication that comes from the unauthorized interfaces. For example, to allow 1.2.3.4 and loopback only, you might add this to /etc/ntp.conf:# no restrictions for loopback...restrict 127.0.0.1 mask 255.0.0.0# no restrictions for 1.2.3.0/24restrict 1.2.3.4 mask 255.255.255.0# everything else is ignoredrestrict default ignoreP:ou might be able to exploit the fact that it only binds to the interfaces at start-up time .Not very pretty but you could stop the other interfaces comming up then start ntp then start the rest , or during rc2 ifconfig the ones you don't want down before ntp start then start ntp and then the other interfaces.以下转自:/c/410数据库服务器的时间与真实时间一旦出现差异,就要对数据库服务器进行时间同步。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

NTPD配置指南
NTPD(网络时间协议守护进程)是一个用于同步计算机的系统时钟的服务程序。

配置正确的NTPD是确保计算机时间准确性的重要步骤,尤其是在需要与其他计算机进行时间同步的情况下。

以下是一个NTPD配置指南,包括了一些常用的配置选项和参数。

1.安装NTPD:
在大多数Linux发行版中,NTPD都是默认安装的。

如果没有安装,可以使用以下命令安装它:
```
sudo apt-get install ntpd
```
或者
```
sudo yum install ntpd
```
2.配置NTPD:
3.选择NTP服务器:
NTPD从一个或多个NTP服务器同步时间。

可以在配置文件中指定要使用的NTP服务器。

例如:
```
```
可以使用多个server行指定多个NTP服务器,以提供冗余和更好的
时间源。

4.本地时钟源:
除了外部NTP服务器,NTPD还可以使用本地时钟源进行时间同步。

要启用本地时钟源,可以在配置文件中添加以下行:
```
server 127.127.1.0
fudge 127.127.1.0 stratum 10
```
这将使用NTPD的本地时钟进行时间同步,并将其宣布为stratum 10。

5.配置日志:
NTPD可以生成日志以记录时间同步的活动和错误信息。

可以配置NTPD以指定日志文件的位置和详细级别。

例如:
```
logfile /var/log/ntp.log
driftfile /var/lib/ntp/ntp.drift
```
这将将日志记录写入/var/log/ntp.log,并将时钟漂移数据保存在
/var/lib/ntp/ntp.drift中。

6.启用认证:
为了确保时间的准确性和安全性,可以启用NTPD的认证功能来验证传入的时间数据。

可以在配置文件中添加以下行来启用认证:```
keys /etc/ntp/keys
trustedkey 1
```
这将启用NTPD的认证功能,并使用/etc/ntp/keys文件存储密钥。

7.配置访问控制:
对NTP服务的访问进行适当的限制对于保护服务器的安全至关重要。

可以在配置文件中添加以下行来配置访问控制:
```
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict x.x.x.x
```
第一行限制了默认的访问权限,不允许修改、捕获控制台、对等点或查询。

第二行限制了只有本地主机可以使用NTP服务。

第三行限制了允许访问NTP服务的特定IP地址。

8.启动NTPD:
完成配置后,可以使用以下命令启动NTPD服务:
```
sudo systemctl start ntpd
```
或者
```
sudo service ntpd start
```
9.验证同步:
可以使用以下命令验证NTPD是否成功同步时间:
```
ntpq -p
```
该命令将显示已与NTP服务器同步的详细信息。

10.定期重新启动:
为了确保NTPD长期稳定运行,建议定期重新启动服务。

可以使用以下命令来定期重新启动NTPD:
```
sudo systemctl restart ntpd
```
或者
```
sudo service ntpd restart
```
通过按照以上步骤和配置选项,您将能够成功配置和管理NTPD服务,确保计算机时间的准确性和同步。

请记住,正确配置的NTPD是确保网络
中所有设备时间一致性的关键。

相关文档
最新文档