在树莓派是安装并配置NTP服务
我们都知道树莓派的小巧和省电节省空间等太多的优势,这里就不一一列举了,那么树莓派就需要长时间的运行,可以7×24的方式运行,那么我们就把树莓派当作一个小的服务器来运行,可以跑一些小的应用,例如可以在局域网中当作NTP服务器,哈哈,这个想法不错!
初步设想:
1)树莓派连接网络之后,时间通过网络自动同步,那么树莓派本身的时间就正常了。(不会的自己上网查,类似的文章一堆,不是本文重点)
2)在内部局域网中的其他计算机(包含win,Linux,mac等)都可以以树莓派作为ntp服务器进行时间同步了。
一、配置局域网NTP服务器
1.安装ntp服务
通过如下命令安装ntp服务
sudo apt-get install ntp
2.修改配置文件ntp.conf
安装完成后,打开/etc/ntp.conf文件,在命令处输入:
cd /
cd etc/
sudo nano ntp.conf
显示内容如下:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf() for help driftfile /var/lib/ntp/ntp.drift # Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable # You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example # pool.ntp.org maps to about low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server .debian.pool.ntp.org iburst
server .debian.pool.ntp.org iburst
server .debian.pool.ntp.org iburst
server .debian.pool.ntp.org iburst # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration.
restrict - default kod notrap nomodify nopeer noquery
restrict - default kod notrap nomodify nopeer noquery # Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict :: # Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust # If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255 # If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
以上是安装ntp服务完成后的默认配置。
我自己参考了网上其他人的配置参数,修改成了如下的样子,参考文章在最后给出了地址:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf() for help driftfile /var/lib/ntp/ntp.drift # Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable # You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example # pool.ntp.org maps to about low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server .debian.pool.ntp.org iburst
server .debian.pool.ntp.org iburst
server .debian.pool.ntp.org iburst
server .debian.pool.ntp.org iburst
server time.asia.apple.com prefer
server ntp.sjtu.edu.cn prefer
server 127.127.1.0
fudge 127.127.1.0 stratum # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration.
restrict - default kod notrap nomodify nopeer noquery
restrict - default kod notrap nomodify nopeer noquery
#restrictdefault nomodify # Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict :: # Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust # If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255 # If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
根据自己的网络情况,以及使用情况,请自行修改ntp配置,本文章末尾处给出了配置的参考连接。
3.重启NTP服务
使用命令重启ntp服务:sudo service ntp restart
4.本地测试
1)先确认ntp是否已启动,命令:ps -ef | grep ntp,应该可以看到两行内容(如果一行太长显示不完,会显示成两行,注意分辨!)
2)命令行输入:ntpq -p
结果如下,说明NTP服务器进程存在
pi@raspberrypi36:/ $ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+cn.ntp.faelix.n 185.134.196.169 u 253.107 -7.402 23.282
+d.hnd.pobot.net 255.254.0.27 u 249.128 41.977 8.036
static--- .INIT. u - 0.000 0.000 0.000
*time5.aliyun.co 10.137.38.86 u 30.167 3.322 3.654
重启系统
重启命令:reboot
5.在其它PC同步树莓派上的时间
在其它PC端填入我的树莓派IP。
在Windows下即设置时间时选择Internet时间,并填入树莓派的IP。
=========================================================
参考:
https://blog.csdn.net/rk2900/article/details/8658110
https://www.linuxidc.com/Linux/2016-10/135945.htm
https://blog.csdn.net/gsls200808/article/details/51057359
https://www.cnblogs.com/quchunhui/p/7658853.html
https://blog.csdn.net/yjgithub/article/details/54613172
https://www.cnblogs.com/rongpmcu/p/7662141.html
在树莓派是安装并配置NTP服务的更多相关文章
- CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-4配置NTP服务
配置NTP服务.标准的做法是配置NTP服务器,但是这里为了方便就用简化的方式配置了. 这个在安装初期,不是必须的,只要保证各机器的时间同步就行,使用如下命令可以查看时间是否同步: [root@cdh1 ...
- 基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】搭建HAWQ数据仓库——安装配置NTP服务,保证集群时间保持同步
一.所有节点上使用yum安装配置NTP服务yum install ntp -y 二.选定一台节点作为NTP server, 192.168.58.11修改/etc/ntp.conf vim /etc/ ...
- CentOS7系列--2.1CentOS7中安装配置NTP服务
CentOS7安装配置NTP服务 NTP服务是时间同步服务 1. 安装NTPd [root@centos7 ~]# yum install -y ntp [jack@centos7 ~]$ vi /e ...
- 配置ntp服务
配置ntp服务(hadoop搭建可参考) 一:修改选定的服务器的本地时间 date -s '2016-10-07 16:29:30' +'%F %T' //需要设置的时间 二:修改后将时间写入到硬件时 ...
- 配置NTP服务ntpd/ntp.conf(搭建Hadoop集群可参考)
本文拟定是在一个局域网内(比如一个Hadoop集群)设定一台NTP服务器作为整个网络的标准时间参考,使用网络(集群)内的所有机器保持时间一致!以下是详细的操作步骤: 1. 修改选定的服务器的本地时间 ...
- Hadoop3集群搭建之——配置ntp服务
上篇: Hadoop3集群搭建之——虚拟机安装 Hadoop3集群搭建之——安装hadoop,配置环境 下篇: Hadoop3集群搭建之——hive安装 Hadoop3集群搭建之——hbase安装及简 ...
- Ubuntu集群 配置ntp服务
1.概述 NTP(Network Time Protocol)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN ...
- OpenVAS漏洞扫描基础教程之OpenVAS概述及安装及配置OpenVAS服务
OpenVAS漏洞扫描基础教程之OpenVAS概述及安装及配置OpenVAS服务 1. OpenVAS基础知识 OpenVAS(Open Vulnerability Assessment Sys ...
- Kali Linux常用服务配置教程安装及配置DHCP服务
Kali Linux常用服务配置教程安装及配置DHCP服务 在Kali Linux中,默认没有安装DHCP服务.下面将介绍安装并配置DHCP服务的方法. 1.安装DHCP服务 在Kali Linux中 ...
随机推荐
- loadrunner json中文无法识别问题
http://blog.sina.com.cn/s/blog_6ff7a3b50101awmy.html
- struts请求参数注入的三种方式
.请求参数的注入 在Struts2框架中,表单的提交的数据会自动注入到与Action对象相对应的属性.它与Spring框架中的IoC的注入原理相同,通过Action对象为属性提供setter方法注入 ...
- 一、TCP扫描技术
一.TCP扫描技术 常用的端口扫描技术有很多种,如 TCP connect() 扫描 .TCP SYN 扫描.TCP FIN 扫描 等,网络上也有很多文章专门介绍,比如 :http://www.ant ...
- L275 Climate Change Is Having a Major Impact on Global Health
Climate Change Is Having a Major Impact on Global Health A devastating heat wave swept across Europe ...
- oracle 12c中种子数据库的隐藏与保护
Oracle 12c种子数据库(pdbseed)的状态是read only,这是因为Oracle对种子数据库进行了保护,避免遭到破坏.保护好种子数据库的目的,是为了以此为模板,新建pdb数据库. 新的 ...
- Python Algorithms – chapter2 基础知识
一.渐进记法 三个重要的记号 Ο.Ω.Θ,Ο记法表示渐进上界,Ω记法表示渐进下界,Θ记法同时提供了函数的上下界 几种常见的渐进运行时间实例 三种重要情况 最好的情况,最坏的情况,平均情况 最坏的情况通 ...
- windows下利用nodejs压缩.min文件
利用nodejs中的npm工具,压缩文件,必须在node环境下 压缩js文件 1.在全局中安装uglify-js模块 npm install uglify-js -g 2.可以直接使用uglifyjs ...
- Spring MVC — @RequestMapping原理讲解-1
转载地址 :http://blog.csdn.net/j080624/article/details/56278461 为了降低文章篇幅,使得文章更目标化,简洁化,我们就不例举各种@RequestMa ...
- SQL注入之Sqli-labs系列第一关
在开始接触渗透测试开始,最初玩的最多的就是Sql注入,注入神器阿D.明小子.穿山甲等一切工具风靡至今.当初都是以日站为乐趣,从安全法实施后在没有任何授权的情况下,要想练手只能本地环境进行练手,对于sq ...
- 如何用DAX实现查看每个月中不同类别排名前一位,以及一个简单的svg案例
现在给大家带来的是如何用DAX实现查看每个月中不同类别的排名前一位,最终完成效果如下!!! 首先我们需要两张简单的表 基数表 和类别表 当我们创建好表之后,我们再创建一个表格,然后我们将类别表里的列值 ...