博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Centos7.4 集群ntp时间同步配置
阅读量:4280 次
发布时间:2019-05-27

本文共 3047 字,大约阅读时间需要 10 分钟。

一、实现功能

CDH集群搭建的时候,通过NTP配置时钟同步,从而可以使集群时间一致,保证集群运行基本条件。

二、环境

Centos7.4

三、配置ntp服务器

1.查看系统是否安装ntp

rpm -qa | grep ntp

2.安装ntp和ntpdate

yum -y install ntp ntpdate

3.查看是否已安装完成

[root@cdh1 ~]# rpm -qa | grep ntp        ntp-4.2.6p5-29.el7.centos.x86_64ntpdate-4.2.6p5-29.el7.centos.x86_64

4.配置ntp服务器

vim /etc/ntp.conf

注释

#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 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 iburstserver 127.127.1.0 iburst

5.启动ntp服务并且设置开机启动

systemctl start ntpdsystemctl enable ntpd

6.查看状态

[root@cdh1 ~]# systemctl status ntpd● ntpd.service - Network Time Service   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)   Active: active (running) since Tue 2020-02-11 19:38:22 CST; 19s ago Main PID: 1491 (ntpd)   CGroup: /system.slice/ntpd.service           └─1491 /usr/sbin/ntpd -u ntp:ntp -gFeb 11 19:38:22 cdh1 ntpd[1491]: Listen and drop on 1 v6wildcard :: UDP 123Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 2 lo 127.0.0.1 UDP 123Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 3 ens33 192.168.0.108 UDP 123Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 4 lo ::1 UDP 123Feb 11 19:38:22 cdh1 ntpd[1491]: Listen normally on 5 ens33 fe80::e37b:3e48:9646:7eff UDP 123Feb 11 19:38:22 cdh1 ntpd[1491]: Listening on routing socket on fd #22 for interface updatesFeb 11 19:38:22 cdh1 ntpd[1491]: 0.0.0.0 c016 06 restartFeb 11 19:38:22 cdh1 ntpd[1491]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPMFeb 11 19:38:22 cdh1 ntpd[1491]: 0.0.0.0 c011 01 freq_not_setFeb 11 19:38:23 cdh1 ntpd[1491]: 0.0.0.0 c514 04 freq_mode

7. 查看是否同步

ntpq -p

备注:ntp服务器启动后,可能要等3-5min,才能检测到启动服务

 

四、客户端配置

1.查看系统是否安装ntp

rpm -qa | grep ntp

2.安装ntp和ntpdate

yum -y install ntp ntpdate

3.查看是否已安装完成

rpm -qa | grep ntp

4.配置ntp服务器

vim /etc/ntp.conf

修改

#注释掉其他时间服务器#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 iburstserver 10.2.31.25 #配置本地ntp服务器为时间同步服务器restrict 10.2.31.25 nomodify notrap noquery #允许本地时间服务器主动修改本机的时间【cdh集群】#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 iburstserver 192.168.0.108 #配置本地ntp服务器为时间同步服务器restrict 192.168.0.108 nomodify notrap noquery #允许本地时间服务器主动修改本机的时间

5.手动同步一下

systemctl stop ntpdntpdate 10.2.31.25systemctl start ntpd【cdh集群】[root@cdh2 ~]# systemctl stop ntpd[root@cdh2 ~]# ntpdate 192.168.0.10811 Feb 21:55:26 ntpdate[1266]: adjust time server 192.168.0.108 offset -0.000086 sec[root@cdh2 ~]# systemctl start ntpd

6.检测与本地ntpd Server同步

ntpdate -u 10.2.31.25centos7.4[root@cdh3 ~]#  ntpdate -u 192.168.0.10811 Feb 21:50:09 ntpdate[1215]: adjust time server 192.168.0.108 offset -0.140448 sec

7.启动ntp并且设置开机启动

systemctl start ntpdsystemctl enable ntpd

8.查看同步状态

ntpq -p

备注:服务器初次启动,大概要等3-5min,然后时间会自动同步,偏差会逐渐缩小

转载地址:http://mgygi.baihongyu.com/

你可能感兴趣的文章
To Install Android Studio in Ubuntu 16.04 and Ubuntu 17.04
查看>>
how to extract code of apk file
查看>>
android 相關網址
查看>>
動態開關android log level
查看>>
how to mount /system as read/write in android?
查看>>
Android 線上的opengrok
查看>>
Android 好的文章網誌
查看>>
vim 常用指令
查看>>
Glib相關
查看>>
Android的权限机制之—— “沙箱”机制sharedUserId和签名
查看>>
Android探索之旅 | AIDL原理和实例讲解
查看>>
devmem ioremap
查看>>
gpg 金鑰管理
查看>>
put file from local to remote server
查看>>
java學習
查看>>
c11新書
查看>>
語言編碼
查看>>
GNOME frontend for the rdesktop client (從ubuntu遠端桌面windows)
查看>>
安裝Ubuntu DHCP Server
查看>>
where does ansroid.os.SystemProperties store its key/values?
查看>>