时间主机
(
服务器端
)
1.
首先检查系统中是否安装
ntp
包
rpm -q ntp
----
若没有执行
yum -y install ntp
进行安装再执行上面命令进行检查
2.
查看
ntp
是否设置为开启启动状态:
systemctl is-enabled ntpd
----
若默认是
disable
禁用开机启动的
disabled
,执行
chkconfig ntpd on
或者
systemctl enable ntpd
设置为开机自启动
3.
启动
ntp
服务
systemctl start ntpd.service
4.
编辑
ntp.conf
vim ntp.conf
时间服务器的
IP
:
172.24.6.141
执行
vim /etc/ntp.conf
打开
ntp
配置文件,找到
server
指定时间服务器的位置,这些条都注释掉;然后添加下面
2
行固定配置:
server 172.24.6.141
fudge 172.24.6.141
stratum 10
然后在
restrict
指定的两行下面追加一行:
restrict 1
7
2.
24
.1.1 mask 255.255.25
5
.0 nomodify notrap
(
这个配置根据自己的网关和网段配置,只要能保证局域网主机通信就可以
)
-
配置好之后,保存并退出,执行
systemctl restart ntpd.service
重启
ntp
服务即可
6.
查看
ntp
状态
ntpq -p(ntpstat)
客户端配置
1.
同样执行上面的一些命令对
ntp
进行安装、启动、自启配置、状态查看等操作,配置文件依然是:
/etc/ntp.conf
,打开进行如下配置:
同样注释默认的
server
服务器,添加一行指定时间服务器位置:
server
172.24.6.141
因为上面时间服务器地址是
172.24.6.141
-
配置好之后,保存,重启
ntp
服务即可
systemctl restart ntpd.service
-
查看
ntp
状态
ntpq -p(ntpstat)
所有客户端都进行以上配置,都启动之后,集群会自动定期进行服务的同步,这样集群的时间就保持一致了