在树莓派是安装并配置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(5) 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 1000 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 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.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 -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# 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服务器进程存在

[email protected]:/ $ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+cn.ntp.faelix.n 185.134.196.169  2 u    1   64  377  253.107   -7.402  23.282
+d.hnd.pobot.net 255.254.0.27     2 u   15   64  155  249.128   41.977   8.036
 static-5-103-13 .INIT.          16 u    -   64    0    0.000    0.000   0.000
*time5.aliyun.co 10.137.38.86     2 u    9   64  377   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/mq0036/p/9362706.html

时间: 2024-08-30 02:26:10

在树莓派是安装并配置NTP服务的相关文章

配置ntp服务

配置ntp服务(hadoop搭建可参考) 一:修改选定的服务器的本地时间 date -s '2016-10-07 16:29:30' +'%F %T' //需要设置的时间 二:修改后将时间写入到硬件时钟,确保重启有效 hwclock -w 三:安装并开启ntp服务 四:开启自动开启ntp服务开机启) chkconfig ntpd on //开机自动开启ntp服务 chkconfig --list ntpd //查看ntp状态 ntpd           0:关闭 1:关闭 2:启用 3:启用

Ubuntu集群 配置ntp服务

1.概述 NTP(Network Time Protocol)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击.(来自 百度百科) 2.集群状况 现在又4台Ubuntu主机,选择其中一台作为提供ntp服务的主机(server01). 3.安装ntp服务 在提供ntp服务的主机上安装ntpserver: apt-get in

配置NTP服务ntpd/ntp.conf(搭建Hadoop集群可参考)

本文原文出处: http://blog.csdn.net/bluishglc/article/details/41413031严禁任何形式的转载,否则将委托CSDN官方维护权益!本文拟定是在一个局域网内(比如一个Hadoop集群)设定一台NTP服务器作为整个网络的标准时间参考,使用网络(集群)内的所有机器保持时间一致!以下是详细的操作步骤: 1. 修改选定的服务器的本地时间 #date -s '2014-11-21 12:48:30' +'%F %T' #2014-11-21 12:48:30为

在RedHat Linux系统中安装和配置snmp服务

检查系统是否安装snmp服务 # rpm -qa|grep snmp net-snmp-5.3.2.2-17.el5 net-snmp-perl-5.3.2.2-17.el5 net-snmp-devel-5.3.2.2-17.el5 net-snmp-libs-5.3.2.2-17.el5 net-snmp-utils-5.3.2.2-17.el5 net-snmp-libs-5.3.2.2-17.el5 net-snmp-devel-5.3.2.2-17.el5 SNMP服务安装后会有以上安

CentOS 6.0安装和配置ssh服务

/* 传统的网络服务程序,如:ftp.pop和telnet在本质上都是不安全的,因为它们在网络上用明文传送口令和数据,别有用心的人非常容易就可以截获这些口令和数据.而且,这些服务程序的安全验证方式也是有其弱点的, 就是很容易受到“中间人”(man-in-the-middle)这种方式的攻击.所谓“中间人”的攻击方式, 就是“中间人”冒充真正的服务器接收你传给服务器的数据,然后再冒充你把数据传给真正的服务器.服务器和你之间的数据传送被“中间人”一转手做了手脚之后,就会出现很严重的问题.通过使用SS

OpenVAS漏洞扫描基础教程之OpenVAS概述及安装及配置OpenVAS服务

OpenVAS漏洞扫描基础教程之OpenVAS概述及安装及配置OpenVAS服务 OpenVAS基础知识 OpenVAS(Open Vulnerability Assessment System)是开放式漏洞评估系统,其核心部分是一个服务器.该服务器包括一套网络漏洞测试程序,可以检测远程系统和应用程序中的安全问题.OpenVAS不同与传统的漏洞扫描软件.所有的OpenVAS软件都是免费的,而且还采用了Nessus(一款强大的网络扫描工具)较早版本的一些开放插件.虽然Nessus很强大,但是该工具

Kali Linux常用服务配置教程安装及配置DHCP服务

Kali Linux常用服务配置教程安装及配置DHCP服务 在Kali Linux中,默认没有安装DHCP服务.下面将介绍安装并配置DHCP服务的方法. 1.安装DHCP服务 在Kali Linux中,用来提供DHCP服务的安装包名为isc-dhcp-server.所以,执行命令如下所示: [email protected]:~# apt-get install isc-dhcp-server –y 执行以上命令后,将开始安装DHCP服务.如果安装过程中没有报错的话,则该服务将被成功安装到系统中

大数据高可用集群环境安装与配置(02)——配置ntp服务

NTP服务概述 NTP服务器[Network Time Protocol(NTP)]是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击.时间按NTP服务器的等级传播.按照离外部UTC源的远近把所有服务器归入不同的Stratum(层)中. 安装部署 执行命令,安装ntp和ntpdate软件包 yum install ntp -

saltstack 安装部署及ntp服务批量部署过程实例

服务端安装salt-master yum install salt-master -y 客户端安装salt-minion  yum install salt-minion -y 启动服务: 服务端启动方式: /etc/init.d/salt-master start 客户端启动方式: /etc/init.d/salt-minion start master端 配置文件: cat /etc/salt/master | egrep -v '^#|^$' worker_threads: 60 cach