サーバの時刻を同期させるために、サーバ、他のサーバ(CentOSに6、RHEL7)を行うにはCentOS7時間

RHEL 7、CentOSの7デフォルトのネットワーク・タイム・プロトコルChrony

このチュートリアルでは、時間サーバーサーバーのホスト名:CentOS7-ノード3 IP:192.168.231.130

                           1つのクライアントのホスト名:RHEL7、ノード1

                           2クライアントのホスト名:CentOS6、ノード2

サーバー:

まずchronyの下でサービスの状態を確認

[root@CentOS7-Node3 ~]# systemctl status chronyd
Unit chronyd.service could not be found.
 

クエリがサービスされていない場合は、yumをインストールすることができます

[root@CentOS7-Node3 ~]# yum install -y chrony

chronyサービスを開始  

[root@CentOS7-Node3 ~]# systemctl start chronyd
 

状態をチェック

[root@CentOS7-Node3 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2018-06-07 10:20:28 CST; 2s ago Docs: man:chronyd(8) man:chrony.conf(5) Process: 6031 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS) Process: 6027 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 6029 (chronyd) CGroup: /system.slice/chronyd.service └─6029 /usr/sbin/chronyd Jun 07 10:20:28 CentOS7-Node3 systemd[1]: Starting NTP client/server... Jun 07 10:20:28 CentOS7-Node3 chronyd[6029]: chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +...DEBUG) Jun 07 10:20:28 CentOS7-Node3 chronyd[6029]: Initial frequency -29.914 ppm Jun 07 10:20:28 CentOS7-Node3 systemd[1]: Started NTP client/server. Jun 07 10:20:33 CentOS7-Node3 chronyd[6029]: Selected source 37.218.240.198 Jun 07 10:20:33 CentOS7-Node3 chronyd[6029]: System clock wrong by -3.020089 seconds, adjustment started Jun 07 10:20:30 CentOS7-Node3 chronyd[6029]: System clock was stepped by -3.020089 seconds Hint: Some lines were ellipsized, use -l to show in full.
 

タイムサーバーの設定次のように:

 [root@CentOS7-Node3 ~]# vim /etc/chrony.conf
25 # Allow NTP client access from local network.
26 allow 192.168.231.0/24
27 
28 # Serve time even if not synchronized to a time source. 29 local stratum 10
 

 

3台のサーバー時間、CentOS7、ノード3の通常時

写真.PNG

 

クライアントの構成:

クライアント1:

サーバー0.rhel.pool.ntp.org IBURST ---サーバー3.rhel.pool.ntp.org IBURST削除またはコメント

追加\設定を変更します。

サーバー192.168.231.130 iburt

192.168.231.0/24を許可します

[root@RHEL7-Node1 ~]# vim /etc/chrony.conf
  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.rhel.pool.ntp.org iburst 4 #server 1.rhel.pool.ntp.org iburst 5 #server 2.rhel.pool.ntp.org iburst 6 #server 3.rhel.pool.ntp.org iburst 7 server 192.168.231.130 iburst 8 # Ignore stratum in source selection. 9 stratumweight 0 10 11 # Record the rate at which the system clock gains/losses time. 12 driftfile /var/lib/chrony/drift 13 14 # Enable kernel RTC synchronization. 15 rtcsync 16 17 # In first three updates step the system clock instead of slew 18 # if the adjustment is larger than 10 seconds. 19 makestep 10 3 20 21 # Allow NTP client access from local network. 22 allow 192.168.231.0/24
 

保存し、編集した後、効果chronyを取るためにサービスを再起動します

[RHEL7-ノード1〜@ルート]#systemctl再起動chronyd

 

クライアント2 CentOS6、ノード2

CentOSの6はNTPです

実行にntpdate 192.168.231.130

[root@CentOS6-Node2 ~]# ntpdate 192.168.231.130
 7 Jun 16:59:34 ntpdate[1563]: the NTP socket is in use, exiting
 

上記のエラーが発生した場合は、NTPサービスが停止し、その後にntpdate 192.168.231.130を実行します

[root@CentOS6-Node2 ~]# service ntpd stop
Shutting down ntpd:                                        [  OK  ] [root@CentOS6-Node2 ~]# ntpdate 192.168.231.130 7 Jun 17:00:19 ntpdate[1578]: step time server 192.168.231.130 offset -13589998.9 54539 sec[root@CentOS6-Node2 ~]# service ntpd status ntpd is stopped [root@CentOS6-Node2 ~]# date Thu Jun 7 17:00:37 CST 2018
 

次にスケジュールされたタスクで時刻同期を追加

[root@CentOS6-Node2 ~]# crontab -e
0-59/10 * * * * /usr/sbin/ntpdate 192.168.231.130
 

一回10分の同期

 

今、次の3台のサーバを参照すると、時間と一致しています

写真.PNG