|NO.R.00001|——————————|Navigation|————|服务启动导航.v01|————|NTP.v01|时间同步服务器配置:方案一|

一、配置主机时间同步:
### --- 查看当前服务端和客户端版本一致

[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
~~~     # 查看计划任务是否执行

[root@localhost ~]# grep "ntpdate" /var/log/cron

 
 
 
 
 
 
 
 
 

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

 

posted on   yanqi_vip  阅读(11)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示