ntp

使用 NTP/Chrony 同步 Centos7 网络时间

放肆的年华 提交于 2019-12-12 19:36:39
Network Time Protocol(NTP)是用来使计算机 时间同步 化的一种协议,它可以使 计算机 对其 服务器 或 时钟源 (如石英钟,GPS等等)做同步化,提供高精准度的时间校正服务。 在 Centos7 中,搭建 NTP 服务器可以通过 NTP 或 Chrony 这两种方式。Chrony 是在 7 中新加上的网络同步功能,并且代替了 NTP 作为默认的时间同步进程。Chrony 相对于 NTP 在同步系统时间和准确性上都有了进一步的提高。 注意:NTP 是一种网络协议,在 Linux 中搭建的是 NTP 服务器,有时简称为 NTP,这里不要和 NTP 网络协议的概念弄混。 下面将分别介绍这两种方式: 使用 Chrony 同步网络时间 Chrony 的配置很简单,通常加入同步 IP ,再重启下服务就可以了。 安装 Chrony # centos7 默认已经安装 yum install chrony systemctl enable chronyd systemctl start chronyd 配置 NTP 源 vim /etc/chrony.conf # 注释提供的 ip ,服务器大多数是内网环境, 添加内网可以同步的服务器地址 server time.cisco.com iburst # 允许那些网段的服务器可以从本地同步时间 # allow 192.168

Ubuntu 设置PTP时间同步

寵の児 提交于 2019-12-12 11:12:55
注:本文重点在设置PTP时间同步,有关ptp协议的介绍,可以参见 参考链接2 一、NTP 1 查看NTP状态: $ timedatectl status 2 关闭NTP同步: $ sudo timedatectl set-ntp false 可以看到Network time on已经处于no的状态。 二、PTP 1 安装PTP $ sudo apt install ptpd 2 挑选一台机器作为master节点,在其上启动(其中eth0是选择同步使用的网卡,注意,这里要求该网卡相连的交换机支持PTP协议): $ sudo ptpd -M -i eth0 3 在其他的slave节点,启动: $ sudo ptpd -g -i eth0 如果在master和slave上加入-C参数的话,会在前台运行,并打印输出,如在master端: 此外,ptpd还支持单播模式,需加入-u参数,如: $ sudo ptpd -u 192.168.13.206 -g -i eth0 三、开机自启动 设置开启自启动见: Ubuntu 16.04添加开机启动脚本的方法 脚本内容为 #!/bin/bash ptpd -g -i eth0 exit 0 参考: 1 Linux 关闭系统时间同步-timedatectl的使用 2 PTP(Precision Time Protocol)高精度时间同步协议

Synchronizing time between two Windows 7 machines connected with a LAN cable

半腔热情 提交于 2019-12-12 07:38:20
问题 I have a number laptops that run our application while connected to each other in pairs with an ethernet cable, but not connected to any external network or the internet. T I need the connected pair to synchronize their system times, but since every computer needs to be able to synch with any other computer, I can't define one computer to be a time-server and the other to be a client. Is there a way to do this with NTP? Or some other way? 回答1: NET TIME is the way to go. If you do NET TIME

18 digit timestamp to Local Time

青春壹個敷衍的年華 提交于 2019-12-12 06:37:27
问题 I came across Sq-lite database.I found our date time is stored in 18 digit time-stamp. Please help me how to convert it to Local Time. (I tried to convert it(No.of milliseconds from 1900). But i did not get it.It shows 29 days difference. I added 29 days of milliseconds to time. But time output is wrong.My assumption is, it will be NTP time.) Here i give 18-digit time-stamp and its equivalent date time. Time-Stamp Date-Time 362087070028927400 27-10-2014 15:06:57 362087302762879170 27-10-2014

Is there a way to ensure ntp synced clock never moves backwards?

老子叫甜甜 提交于 2019-12-12 05:27:55
问题 Let say I have code that uses the clock to generate ids. Or I have code that calculates time elapsed since an event happened. Or any other logic that expects system time to only move forwards, never backwards. If time does move backwards, and the program notices it, lets say it crashes or hangs. I'd like to use an NTP service with such programs. Is there a way that NTP can be configured so that it is guaranteed never to adjusts time backwards? Slowing down the system clock would be fine. So a

Convert boost::posix_time::ptime to NTP datestamp

跟風遠走 提交于 2019-12-12 02:18:51
问题 I need to convert a boost::posix_time::ptime into a NTP Date stamp according to RFC 5905 represented by the following structure: struct NtpDatestamp { std::int32_t era_number; std::uint32_t seconds_since_era_epoch; std::uint64_t fraction_of_second; }; RFC 5905 states the following: To convert system time in any format to NTP date and timestamp formats requires that the number of seconds s from the prime epoch to the system time be determined. To determine the integer era and timestamp given s

3.in.pool.ntp.org sometimes fails to return date in android device

陌路散爱 提交于 2019-12-12 00:17:27
问题 I am fetching UTC date from ntp servers from a long time now. But I have noticed that I am getting empty string sometimes(once in 100 times) as I run my code. My code is DateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); SntpClient client = new SntpClient(); if (client.requestTime("3.in.pool.ntp.org", 10000)) { Date actualD = new Date(client.getNtpTime()); actualDate = outputFormat.format(actualD).trim(); } Can u suggest me some situation where this code has its limitations. And

Re-synchronize Linux to NTP server

点点圈 提交于 2019-12-11 17:12:35
问题 We're planning to re-synchronize 2 of our machines that's having a 19ms delay from the NTP server (this involves SMS transaction). Those servers are having discrepancy with analytics results and we're suspecting it's one of the cause. So my question is, is it service affecting to re-sync the server to the NTP server? Thanks in advance! Have a great day! 回答1: If NTP is not already installed, use the following command to install: // Ubuntu or other Debian-based system sudo apt-get install ntp /

NTP client is not syncing with server in broadcast mode

痴心易碎 提交于 2019-12-11 14:48:21
问题 I have configured NTP version 4.2.6 server on fedora 20 machine. server side I am using local system time and given a broadcast subnet and all other options are disabled and on client's side I enabled only broadcast client. I haven't given server's address as according to my understanding server should broadcast NTP packets and client will automatically listen NTP packets and will get sync. but my NTP client is not syncing with server. please help me with all possibilities. 回答1: you can just

Java, android, get atomic time from itnernet server

假如想象 提交于 2019-12-11 09:42:03
问题 i trying to synchronize two apps. How can i get the server time of any server with an accuracy up to 1ms? or maybe just 10ms? i tried this some SNTP Clients, but they give me only my destination time or only with an accuracy up to 1s. Pls help. 回答1: You need to configure your SNTP client to follow a time server out there. There are 2 ways to sync your time. SLAM, or SLEW. SLAM, just takes the server time and throws it on the client. SLEW, takes the server time and corrects your client time,