本文共 3047 字,大约阅读时间需要 10 分钟。
CDH集群搭建的时候,通过NTP配置时钟同步,从而可以使集群时间一致,保证集群运行基本条件。
Centos7.4
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/