質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
NTP

NTP (Network Time Protocol) とは、時計の時刻をネットワーク上のNTPサーバーの持つ正しい時刻に同期するためのプロトコルです。

Q&A

2回答

395閲覧

RasberryPi 4でChornyを使ってNTPサーバーを運用したいが GPS未受信時に時刻同期が止められない

Tokizane

総合スコア0

NTP

NTP (Network Time Protocol) とは、時計の時刻をネットワーク上のNTPサーバーの持つ正しい時刻に同期するためのプロトコルです。

1グッド

1クリップ

投稿2023/11/09 09:28

編集2023/11/10 00:46

実現したいこと

RasberryPi 4でChornyを使ってNTPサーバーを運用したいが
GPS未受信時に時刻同期が止められない

前提

GPSデータ(USB接続のGPS Unit)をLAN内で共有したいのですが、
もしGPSの受信が出来ない場合は、時刻データの同期を停止したいです。
RTCを持ったカメラがLAN内にあり、信頼度が低い時刻データで上書きすることになってしまうため。(RaspberryPiは10日程度、電源を入れないことがあるため)
これがどうやって実現したらいいか、知りたいです

lang

1# Welcome to the chrony configuration file. See chrony.conf(5) for more 2# information about usable directives. 3 4# Include configuration files found in /etc/chrony/conf.d. 5confdir /etc/chrony/conf.d 6 7# Use Debian vendor zone. 8#pool 2.debian.pool.ntp.org iburst 9 10# use the local instance NTP service, if available 11server 127.127.28.2 minpoll 6 maxpoll 10 prefer iburst xleave 12server 127.127.28.0 minpoll 6 maxpoll 10 prefer iburst xleave 13server 127.127.22.0 minpoll 6 maxpoll 10 prefer iburst xleave 14refclock SHM 0 refid GPS poll 3 precision 1e-1 offset 0.9999 delay 0.2 stratum 1 15refclock PPS /dev/pps0 lock NMEA refid PPS trust require stratum 0 16#refclock SOCK /var/run/chrony.ttyAMA0.sock stratum 1 17 18#initstepslew 10 2.debian.pool.ntp.org 127.127.22.0 127.127.28.0 127.127.28.2 19initstepslew 10 127.127.22.0 127.127.28.0 127.127.28.2 20 21# Use time sources from DHCP. 22sourcedir /run/chrony-dhcp 23 24# Use NTP sources found in /etc/chrony/sources.d. 25sourcedir /etc/chrony/sources.d 26 27# Use NTP udp port. 28port 123 29 30# Use NTP cmd udp port. 31cmdport 123 32cmdport 323 33 34# Use NTP acquisiton udp port. 35acquisitionport 123 36acquisitionport 1123 37 38# Uncomment the manual time input 39manual 40 41# This directive specify the location of the file containing ID/key pairs for 42# NTP authentication. 43# THIS SETTING IS LEGACY. Enable by <=2.2. 44keyfile /etc/chrony/chrony.keys 45#commandkey 1 46#generatecommandkey 47 48# This directive specify the file into which chronyd will store the rate 49# information. 50driftfile /var/lib/chrony/chrony.drift 51 52# save data between restarts for fast re-load 53dumponexit 54dumpdir /var/lib/chrony 55 56# Save NTS keys and cookies. 57ntsdumpdir /var/lib/chrony 58 59# Uncomment the following line to turn logging on. 60log tracking measurements statistics rtc refclocks tempcomp 61 62# Log files location. 63logdir /var/log/chrony 64 65# Send a message tp syslog if a clock adjustment is larger than seconds. 66logchange 0.5 67 68# Serve time even if not syncronized to any NTP server. 69local stratum 10 70 71# Stop bad estimates upsetting machine clock. 72#maxdrift 100 73#maxchange 1000 1 2 74maxupdateskew 1000.0 75maxslewrate 83333.333 76 77# Allow high root dispersion (ex. on Windows NTP sources). 78maxdistance 16.0 79 80# This directive tells chrony to regulate the real-time clock and tells it 81# Where to store related data. It may not work on some newer motherboards 82# that use the HPET real-time clock. It requires enhanced real-time 83# support in the kernel. 84#rtcfile /var/lib/chrony/chrony.rtc 85 86# If the last line of this file reads 'rtconutc' chrony will assume that 87# the CMOS clock is on UTC (GMT). If it reads '# rtconutc' or is absent 88# chrony will assume local time. The line (if any) was written by the 89# chrony postinst based on what it found in /etc/default/rcS. You may 90# change it if necessary. 91#rtconutc 92 93# This directive enables kernel synchronisation (every 11 minutes) of the 94# real-time clock. Note that it can’t be used along with the 'rtcfile' directive. 95rtcsync 96 97# Enable hardware timestamping on all interfaces that support it. 98hwtimestamp * 99 100# Step the system clock instead of slewing it if the adjustment is larger than 101# 1 second. 102#makestep 1 3 103makestep 1.0 -1 104 105# Get TAI-UTC offset and leap seconds from the system tz database. 106# This directive must be commented out when using time sources serving 107# leap-smeared time. 108leapsectz right/UTC 109 110# Listen for commands only on localhost. 111bindcmdaddress 127.0.0.1 112bindcmdaddress ::1 113 114# Allow monitoring network group. 115cmdallow 127.0.0.1/32 116cmdallow 192.168.1.0/24 117cmdallow 192.168.2.0/24 118 119# Allow network group. 120allow 127.0.0.1/32 121allow 192.168.1.0/24 122allow 192.168.2.0/24 123allow ::1

試したこと

GPSの断線などを含むトリガーは取れたが、GPSの時刻情報未受信のトリガーが取れなかった
stratum 16を入れてみたが、だめだった

補足情報(FW/ツールのバージョンなど)

RaspberryPi 4B
Rasbian Bullseye
Chorny

RaspberryPiでGPSの時刻情報を使って、定点計測しているカメラの録画時刻の精度を上げています。
カメラとRaspberryPiはEthernet
RaspberryPiとGPS ModuleはUSB
で接続されています

tkmtmkt👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Tokizane

2023/11/09 16:51

失礼しました。後ほど修正します
ikedas

2023/11/10 00:59

「時刻同期が止まる」というのは、何がどのような動作をすることを指すのでしょうか。
guest

回答2

0

ちょっと状況がよくわからないんですが、

RaspberryPiは10日程度、電源を入れないことがあるため

というのは

  • 電源を入れてからGPSのデータを受信するまでは、chronydが信頼度が低い時刻データを提供してしまう。

ということかと思います。

  • 動作し続ける限りは、一時的にGPS信号を受信できないからといって時刻の精度が極端に下がるわけでもないでしょう。
    Raspberry Piの電源を入れっぱなしにしておけばいいです。電源の喪失が予想されるのなら、バッテリーで給電すればよいと思います。

  • Raspberry PiにRTCモジュールを付加してもよいと思います。再起動時にはバッテリーで維持された時刻を参照できます。

  • 起動直後は時刻情報の提供を停めておき、十分に時刻の精度が上がったころを見計らって提供を開始するようにするのもいいかもしれません。

投稿2023/11/16 00:22

ikedas

総合スコア4337

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

gpsdを定周期監視して、最近受信してないようならchronyc denyを叩いてntpの応答を止めるとか?

投稿2023/11/10 01:06

matukeso

総合スコア1590

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Tokizane

2023/11/11 00:37

「最近受信していないなら」のところのトリガーになるものが分からず、困っております
matukeso

2023/11/12 23:19

chronyc sourcesのreachが377から376とか0とかになったりしない?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問