NTP配置时间同步
来源:互联网 发布:人工智能会消灭人类 编辑:程序博客网 时间:2024/05/22 15:38
NTP是用来使计算机时间同步化的一种协议
节点2(客户端)向节点1(服务器端)同步
节点1(服务器端)的配置:
vim /etc/ntp.conf
restrict 127.0.0.1
restrict -6 ::1
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap -------------允许任何IP的客户机都可以进行时间同步
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
server 127.127.1.0 # local clock -------------本地时间
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
启动:/etc/init.d/ntpd start
停止:/etc/init.d/ntpd stop
重启:/etc/init.d/ntpd restart
节点2(客户端)配置:
vim /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquerya
restrict 127.0.0.1
restrict -6 ::1
server 10.162.67.108 prefer # local clock -------------指向这台服务器
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
节点2需要关闭NTP服务,否则使用ntpdate连接时会报错如下:
ntpdate[3556]: the NTP socket is in use, exiting
ntpdate 10.162.67.108 -----------向该地址同步
13 Apr 18:32:32 ntpdate[22248]: adjust time server 10.162.67.108 offset 0.017031 sec 成功
省略不配置 //节点2在/etc/crontab
加这样一句话:
*/2 * * * * root ntpdate 10.162.67.108 ----------表示每隔2分钟在节点2以root身份执行ntpdate 10.162.67.108
重启crond服务:
[root@node2 ~]# /etc/init.d/crond restart
Stopping crond: [ OK ]
Starting crond: [ OK ]
观察cron的日志:/var/log
tail -f cron
Apr 13 18:24:01 OSS-4A-20 CROND[20963]: (root) CMD (ntpdate 192.168.3.201)
Apr 13 18:26:01 OSS-4A-20 CROND[21277]: (root) CMD (ntpdate 192.168.3.201)
Apr 13 18:28:01 OSS-4A-20 CROND[21624]: (root) CMD (ntpdate 192.168.3.201)
两个节点之间已实现同步
- NTP时间同步配置
- NTP 时间同步 配置
- NTP配置时间同步
- linux NTP 配置时间同步
- CentOS配置时间同步NTP
- NTP 时间同步协议配置
- 配置NTP,同步服务器时间
- 配置NTP服务器(时间同步)
- ntp配置时间同步服务器
- 配置统一的时间同步NTP节点: pool.ntp.org
- NTP 服务介绍和配置时间同步
- ntp时间同步,各种配置方法
- Linux配置NTP服务器,时间同步
- centos7 配置时间同步服务器ntp
- Windows server2012时间同步NTP配置
- ntp配置内网集群时间同步
- 配置NTP服务时间同步(suse)
- 计算机NTP时钟同步(NTP服务器-NTP时间服务器)的重要性及其配置方法
- 常用Linux命令
- hdu 2010
- kubernetes list-watch(三)
- 爬虫
- 单周期CPU实验之学习之旅
- NTP配置时间同步
- Java数组练习(八)将输入的数组逆序输出
- 温习HTML(二)
- Java设计模式之单例模式
- HTTP协议的缓存机制(Client端)
- linux 空格
- HBase伪分布式配置
- 微信小程序开发手记之三:backgroud和border属性
- An ffmpeg and SDL Tutorial 05