linux centos7 局域网时间同步服务,让局域网某几台机器都按照某一台我们自己配置的时间服务作为时间服务器去同步时间,非网络时间同步


所有机器安装ntp服务
yum install -y ntp
 
-------------------------------------时间服务器节点配置-------------------------------------
vi /etc/ntp.conf
放开注释,并修改成我们局域网的ip段
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

注释掉网络时间同步
#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 10
 
加上硬件同步
vi /etc/sysconfig/ntpd
添加如下配置
SYNC_HWCLOCK=yes
 
启动ntp服务
systemctl start ntpd
 
开机启动
systemctl enable ntpd
 
-------------------------------------其他节点配置-------------------------------------
配置其他节点每隔1分钟去上面的时间服务器节点同步时间
crontab -e
添加如下定时任务
*/1 * * * * /usr/sbin/ntpdate hadoop01
 
 --------------------------------------------------------------------------------------------
注意:
我们只需要启动作为时间服务器节点上的ntp服务,其他节点不用启动,其他节点只是去我们配置的时间服务器节点同步时间就行
 
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM