実践:時刻合わせ NTPサーバーの設定

実践:時刻合わせ NTPサーバーの設定

時刻合わせ

  1. chronyのインストール状態と自動起動の確認
  2. chrony定義ファイルの編集(NTPサーバの指定)
  3. NTPサーバーの設定と確認

chronyのインストール状態と自動起動の確認

インストール状態の確認と自動起動の確認

1[root@localhost ~]#rpm -qa | grep chrony
2chrony-3.4-1.el7.centos.x86_64
3 
4[root@localhost ~]#systemctl status chronyd
5● chronyd.service - NTP client/server
6   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
7   Active: active (running) since 日 2020-01-19 13:15:43 JST; 8min ago
8     Docs: man:chronyd(8)
9              man:chrony.conf(5) 以下省略

インストールされていない場合

1[root@localhost ~]♯yum -y install chrony

chrony定義ファイルの編集

設定ファイル:「/etc/chrony.conf」

1.バックアップを取り、ファイルを開きます
1[root@localhost ~]♯cp -p /etc/chrony.conf /etc/chrony.conf.org
2[root@localhost ~]♯diff /etc/chrony.conf /etc/chrony.conf.org
3 
4[root@localhost ~]♯vi /etc/chrony.conf

2.NTPサーバーの指定を行います

1# Use public servers from the pool.ntp.org project.
2# Please consider joining the pool (http://www.pool.ntp.org/join.html).
3#server 0.centos.pool.ntp.org iburst
4#server 1.centos.pool.ntp.org iburst
5#server 2.centos.pool.ntp.org iburst
6#server 3.centos.pool.ntp.org iburst
7#日本標準時を提供しているNTPサーバー(stratum 1)
8server ntp.nict.jp iburst
9#上記サーバーと直接同期しているNTPサーバー(stratum 2)
10server ntp.jst.mfeed.ad.jp iburst
11 
12# Allow NTP client access from local network.
13#allow 192.168.0.0/16
14allow 192.168.135.128/24

NTPサーバーの設定と確認

1[root@localhost ~]# yum -y install ntpdate
2[root@localhost ~]# systemctl start ntpd
3[root@localhost ~]# ntpdate ntp.nict.jp
419 Jan 14:01:46 ntpdate[1581]: adjust time server 133.243.238.244 offset 0.002513 sec
5[root@localhost ~]# systemctl start chronyd
6[root@localhost ~]# systemctl enable chronyd
7[root@localhost ~]# chronyc sources
8210 Number of sources = 4
9MS Name/IP address         Stratum Poll Reach LastRx Last sample
10===============================================================================
11^+ static.219.237.251.148.c>     2   9   377   207  -2092us[-2092us] +/-  197ms
12^+ 185.73.240.223                3   8   377   209  +5409us[+5409us] +/-  178ms
13^+ y.ns.gin.ntt.net              2   9   377   674  -8919us[-9789us] +/-  134ms
14^* mx.execve.net                 3   9   377   414  -4495us[-5465us] +/-   89ms

以上でこの章が完了します。


NEXT>> 11章 Linuxの保守

f