|NO.Z.00009|——————————|NavigationLog|——|NTP.V02|
一、配置主机时间同步:
### --- 查看当前服务端和客户端版本一致
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
二、ntp.server端配置:hadoop01
### --- 进行外网时间同步
~~~ # Hadoop01安装ntpdate
[root@localhost ~]# yum install -y ntpdate
~~~ # 启动ntpdate
[root@localhost ~]# systemctl start ntpdate
[root@localhost ~]# systemctl enable ntpdate
~~~ # 通过网络连接外网进行时钟同步,必须保证虚拟机连上外网
[root@localhost ~]# ntpdate us.pool.ntp.org;
17 Oct 12:56:25 ntpdate[7683]: adjust time server 50.205.57.38 offset 0.007918 sec
~~~ # 阿里云时钟同步服务器
[root@localhost ~]# ntpdate ntp4.aliyun.com
17 Oct 12:57:22 ntpdate[7684]: adjust time server 203.107.6.88 offset -0.007126 sec
~~~ 注:集群中其他机器与这台机器定时的同步时间,比如,每 隔十分钟,同步一次时间。
### --- 时间服务器配置(必须root用户)
~~~ # 安装ntpd服务
[root@localhost ~]# yum -y install ntp
### --- 编辑/etc/ntp.conf
~~~ # 编辑/etc/ntp.conf配置文件
[root@localhost ~]# vim /etc/ntp.conf
restrict default nomodify notrap nopeer noquery //第8行:开启配置始终同步广播地址
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap //开启17行;同步源:配置同步源
# server 0.centos.pool.ntp.org iburst //第21~24行:注释掉
# 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 # local clock //第25~26行:添加这两行
fudge 127.127.1.0 stratum 10
### --- 配置以下内容,保证BIOS与系统时间同步 vim /etc/sysconfig/ntpd添加一行内容
~~~ # 配置BIOS时间与系统时间同步
[root@localhost ~]# vim /etc/sysconfig/ntpd
SYNC_HWLOCK=yes
### --- 启动ntpd并设置开机自启动
~~~ # 启动ntpd服务
[root@localhost ~]# systemctl restart ntpd
[root@localhost ~]# systemctl enable ntpd
三、配置ntp.client端配置
### --- 配置ntp.client端服务:Hadoop02,Hadoop03
~~~ # 安装ntpdate服务
[root@localhost ~]# yum install -y ntpdate
~~~ # 启动ntpdate
[root@localhost ~]# systemctl start ntpdate
[root@localhost ~]# systemctl enable ntpdate
~~~ # 在其他机器配置10分钟与时间服务器同步一次
[root@localhost ~]# crontab -e
*/10 * * * * /usr/sbin/ntpdate 192.168.1.121 //注:另外两台机器与192.168.1.121进行时钟同步
~~~ # 修改任意机器时间
[root@localhost ~]# date -s "2020-06-20 11:11:11"
~~~ # 十分钟后查看机器是否与时间服务器同步
[root@localhost ~]# date
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」