CentOS7内网搭建集群NTP服务器及客户端同步时间

本文详细介绍了如何在CentOS7环境下搭建NTP服务器,并配置客户端进行时间同步。步骤包括服务器和客户端的配置,设置开机启动,开放防火墙端口,以及通过crontab设置定时同步。
摘要由CSDN通过智能技术生成

一、服务器配置

1、查看服务器、客户端操作系统版本

[root@hadoop101 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core) 

2、查看服务器是否安装ntp,系统默认安装ntpdate;

[root@hadoop101 ~]# rpm -qa | grep ntp
fontpackages-filesystem-1.44-8.el7.noarch
ntpdate-4.2.6p5-28.el7.centos.x86_64
python-ntplib-0.3.2-1.el7.noarch
ntp-4.2.6p5-28.el7.centos.x86_64

3、安装ntp ntpdate,其中ntpdate默认安装,可以只安装ntp;

yum install ntp ntpdate -y

4、查看是否已安装完成,与第2步对比

[root@hadoop101 mysql-libs]# rpm -qa | grep ntp
fontpackages-filesystem-1.44-8.el7.noarch
ntpdate-4.2.6p5-28.el7.centos.x86_64
ntp-4.2.6p5-28.el7.centos.x86_64
python-ntplib-0.3.2-1.el7.noarch

5、查看ntp服务器状态,两条命令效果一样

[root@hadoop101 ~]# systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)

[root@hadoop101 ~]# service ntpd status
Redirecting to /bin/systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)

6、修改配置文件,使该NTP服务器在不联网的情况下,使用本服务器的时间作为同步时间

vim /etc/ntp.conf

把如下四行代码注释掉

#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 127.127.1.0 
fudge  127.127.1.0 stratum 0

配置后:

[root@hadoop101 ~]# vim /etc/ntp.conf
# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值