一、服务器配置
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
#