CentOS7.6にntpd 4.2サーバーをインストールする方法

1.ntpのインストール
# sudo yum install ntp
Loaded plugins: fastestmirror, langpacks, priorities
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* centosplus: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* remi-safe: ftp.riken.jp
* updates: ftp.iij.ad.jp
1 packages excluded due to repository priority protections
Resolving Dependencies
–> Running transaction check
—> Package ntp.x86_64 0:4.2.6p5-28.el7.centos will be installed
–> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-28.el7.centos.x86_64
–> Running transaction check
—> Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Installing:
ntp x86_64 4.2.6p5-28.el7.centos base 549 k
Installing for dependencies:
autogen-libopts x86_64 5.18-5.el7 base 66 k

Transaction Summary
=============================================================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 615 k
Installed size: 1.5 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): autogen-libopts-5.18-5.el7.x86_64.rpm | 66 kB 00:00:00
(2/2): ntp-4.2.6p5-28.el7.centos.x86_64.rpm | 549 kB 00:00:00
—————————————————————————————————————————–
Total 997 kB/s | 615 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : autogen-libopts-5.18-5.el7.x86_64 1/2
Installing : ntp-4.2.6p5-28.el7.centos.x86_64 2/2
Verifying : autogen-libopts-5.18-5.el7.x86_64 1/2
Verifying : ntp-4.2.6p5-28.el7.centos.x86_64 2/2

Installed:
ntp.x86_64 0:4.2.6p5-28.el7.centos

Dependency Installed:
autogen-libopts.x86_64 0:5.18-5.el7

Complete!

2.設定ファイルを編集する
#vim /etc/ntp.conf

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#同期サーバを変更
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst

3.ntpd起動
# systemctl start ntpd

状態の確認
# systemctl status ntpd
* ntpd.service – Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2018-12-27 15:23:17 JST; 12s ago
Process: 11879 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 11880 (ntpd)
CGroup: /system.slice/ntpd.service
`-11880 /usr/sbin/ntpd -u ntp:ntp -g

4.自動起動設定
# systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

5.NTPサービスを許可する
# firewall-cmd –add-service=ntp –permanent
success
# firewall-cmd –reload
success

6.バージョン確認
# ntpd –version
ntpd 4.2.6p5

動作確認
# ntpq -p
remote refid st t when poll reach delay offset jitter
=================================================================
*ntp-a2.nict.go. .NICT. 1 u 34 64 37 16.967 -0.064 0.952
+ntp1.jst.mfeed. 133.243.236.17 2 u 29 64 37 18.033 1.365 0.055
+ntp2.jst.mfeed. 133.243.236.17 2 u 27 64 37 18.068 0.818 0.043

Linux

Posted by arkgame