Linux下NTP服务器配置详细过程
程序员文章站
2022-06-18 16:30:24
目录一、环境配置1.ntp服务器2.业务服务器二、ntp服务器配置1.查看chrony服务状态2.启动chrony服务3.关闭防火墙和selinux4.配置ntp服务文件5.重启服务三、业务服务器配置...
一、环境配置
1.ntp服务器
ntp服务器版本:red hat enterprise linux release 8.0 (ootpa) ntp服务器ip:192.168.8.11/24 ntp服务器hostname:node1
2.业务服务器
ntp服务器版本:red hat enterprise linux release 8.0 (ootpa) ntp服务器ip:192.168.8.12/24 ntp服务器hostname:node2
二、ntp服务器配置
1.查看chrony服务状态
[root@node1 ~]# systemctl status chronyd ● chronyd.service - ntp client/server loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled) active: inactive (dead) docs: man:chronyd(8) man:chrony.conf(5) [root@node1 ~]#
2.启动chrony服务
[root@node1 ~]# systemctl enable --now chronyd created symlink /etc/systemd/system/multi-user.target.wants/chronyd.service → /usr/lib/systemd/system/chronyd.service.
3.关闭防火墙和selinux
[root@node1 ~]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) active: inactive (dead) docs: man:firewalld(1) [root@node1 ~]# sed -i 's/selinux=enforcing/selinux=disabled/' /etc/selinux/config [root@node1 ~]# setenforce 0 setenforce: selinux is disabled [root@node1 ~]# getenforce disabled [root@node1 ~]#
4.配置ntp服务文件
[root@node1 ~]# vim /etc/chrony.conf [root@node1 ~]# cat /etc/chrony.conf |grep -ei '(allow|local)' # allow the system clock to be stepped in the first three updates # allow ntp client access from local network. #allow 192.168.0.0/16 allow 192.168.8.0/24 local stratum 10 [root@node1 ~]#
5.重启服务
[root@node1 ~]# systemctl restart chronyd [root@node1 ~]#
三、业务服务器配置
1.开启chrony服务
[root@node2 ~]# systemctl enable --now chronyd created symlink /etc/systemd/system/multi-user.target.wants/chronyd.service → /usr/lib/systemd/system/chronyd.service. [root@node2 ~]#
2.配置chrony服务文件
[root@node2 ~]# vim /etc/chrony.conf [root@node2 ~]# cat /etc/chrony.conf |grep pool # use public servers from the pool.ntp.org project. # please consider joining the pool (http://www.pool.ntp.org/join.html). pool 192.168.8.11 iburst [root@node2 ~]#
3.重启服务
[root@node2 ~]# systemctl restart chronyd [root@node2 ~]#
四、测试业务服务器时间状态
1.查看时间同步状态
[root@node2 ~]# chronyc sources 210 number of sources = 1 ms name/ip address stratum poll reach lastrx last sample =============================================================================== ^? 192.168.8.12 0 7 0 - +0ns[ +0ns] +/- 0ns [root@node2 ~]#
2.立即时间同步
[root@node2 ~]# chronyc sources 210 number of sources = 1 ms name/ip address stratum poll reach lastrx last sample =============================================================================== ^* 192.168.8.11 10 6 17 2 +249ns[ +141us] +/- 100us [root@node2 ~]# chronyc sources -v 210 number of sources = 1 .-- source mode '^' = server, '=' = peer, '#' = local clock. / .- source state '*' = current synced, '+' = combined , '-' = not combined, | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. || .- xxxx [ yyyy ] +/- zzzz || reachability register (octal) -. | xxxx = adjusted offset, || log2(polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ ms name/ip address stratum poll reach lastrx last sample =============================================================================== ^* 192.168.8.11 10 6 17 8 +249ns[ +141us] +/- 1103us [root@node2 ~]#
到此这篇关于linux下ntp服务器配置详细过程的文章就介绍到这了,更多相关linux ntp服务器配置内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
下一篇: 设计模式之依赖倒转原则
推荐阅读