1. 查看机器的Linux版本

查看集群内所有服务器的linux版本,确保相同,不要跨大版本。

[root@bigdata111 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2.设置时区

集群内所有机器,设置一下时区;

[root@bigdata111 ~]# timedatectl set-timezone Asia/Shanghai

3.查看是否安装NTP服务

集群内所有机器,查看是否安装ntp服务;

[root@bigdata111 ~]# rpm -qa | grep ntp

4.安装NTP服务

集群内所有机器,如果没有安装ntp服务,则执行以下命令安装;

[root@bigdata111 ~]# yum install ntp ntpdate -y

5.查看NTP服务状态

集群内所有机器,执行查看ntp服务状态命令,确定处于服务停止状态;

[root@bigdata111 ~]# systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)

6.修改主节点/主服务器的NTP配置文件;

找到集群的主节点配置NTP文件,编辑完毕,保存退出;

[root@bigdata111 ~]# vi /etc/ntp.conf

#找到如下内容注释掉
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
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
#添加以下内容,同步本地时间,ip写自己的
server 127.127.1.0 iburst

7.主节点同步网络时间

同步网络时间,此处以同步 阿里云的ntp为例;(注意:此操作只有在ntp服务停止的情况下执行,否则报错)

[root@bigdata111 ~]# ntpdate ntp1.aliyun.com
14 Oct 18:01:43 ntpdate[3909]: adjust time server 120.25.115.20 offset -0.020002 sec

8.启动主节点的NTP服务并设置开机启动

[root@bigdata111 ~]# systemctl start ntpd.service
[root@bigdata111 ~]# systemctl enable ntpd.service

9.查看主节点的NTP服务状态

确保主节点的NTP服务状态是 active(running) 状态,才能执行下一步;

[root@bigdata111 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2019-10-14 18:03:22 CST; 1min 31s ago
Main PID: 3916 (ntpd)
CGroup: /system.slice/ntpd.service
└─3916 /usr/sbin/ntpd -u ntp:ntp -g 10月 14 18:03:22 bigdata111 ntpd[3916]: Listen and drop on 1 v6wildcard :: UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 2 lo 127.0.0.1 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 3 eno16777736 192.168.1.111 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 4 lo ::1 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listen normally on 5 eno16777736 fe80::20c:29ff:fec9:1f12 UDP 123
10月 14 18:03:22 bigdata111 ntpd[3916]: Listening on routing socket on fd #22 for interface updates
10月 14 18:03:22 bigdata111 ntpd[3916]: 0.0.0.0 c016 06 restart
10月 14 18:03:22 bigdata111 ntpd[3916]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
10月 14 18:03:22 bigdata111 ntpd[3916]: 0.0.0.0 c011 01 freq_not_set
10月 14 18:03:23 bigdata111 ntpd[3916]: 0.0.0.0 c514 04 freq_mode

10.查看主节点是否同步;

如果没有同步,则关闭防火墙或者开放123端口;

[root@bigdata111 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 5 l 16 64 37 0.000 0.000 0.000

11.修改从机的NTP配置文件

修改其他机器的NTP配置文件,确保NTP服务是在停止状态进行该操作;(根据中文注释操作)修改完毕保存退出;

[root@bigdata111 ~]# vi /etc/ntp.conf

# 注释掉如下内容
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
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
#配置上游时间服务器为本地的ntpd Server服务器(写自己主服务器的IP地址即可)
server 192.168.1.111
#配置允许上游时间服务器主动修改本机的时间(写自己主服务器的IP地址即可)
restrict 192.168.1.111 nomodify notrap noquery

12.从机同步主服务器的时间

从机同步主服务器的时间。(IP就写自己上面配置的主服务器的IP)

[root@bigdata112 ~]# ntpdate -u 192.168.1.111
14 Oct 18:14:23 ntpdate[4608]: adjust time server 192.168.1.111 offset -0.000193 sec

13.启动从机的NTP服务&配置开机启动NTP

从机启动NTP服务和配置开机启动;

[root@bigdata112 ~]# systemctl start ntpd.service
[root@bigdata112 ~]# systemctl enable ntpd.service

13.查看从机的NTP服务状态

[root@bigdata112 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2019-10-14 21:51:50 CST; 4min 17s ago
Process: 860 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 862 (ntpd)
CGroup: /system.slice/ntpd.service
└─862 /usr/sbin/ntpd -u ntp:ntp -g 10月 14 21:51:49 bigdata112 ntpd[862]: Listen normally on 2 lo 127.0.0.1 UDP 123
10月 14 21:51:49 bigdata112 ntpd[862]: Listen normally on 3 lo ::1 UDP 123
10月 14 21:51:49 bigdata112 ntpd[862]: Listening on routing socket on fd #20 for interface updates
10月 14 21:51:49 bigdata112 ntpd[862]: 0.0.0.0 c016 06 restart
10月 14 21:51:49 bigdata112 ntpd[862]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
10月 14 21:51:49 bigdata112 ntpd[862]: 0.0.0.0 c011 01 freq_not_set
10月 14 21:51:50 bigdata112 systemd[1]: Started Network Time Service.
10月 14 21:51:55 bigdata112 ntpd[862]: Listen normally on 4 eno16777736 192.168.1.112 UDP 123
10月 14 21:51:55 bigdata112 ntpd[862]: Listen normally on 5 eno16777736 fe80::20c:29ff:fe15:e831 UDP 123
10月 14 21:51:55 bigdata112 ntpd[862]: new interface(s) found: waking up resolver

14.查看从机的NTP服务是否同步

[root@bigdata112 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*bigdata111 LOCAL(0) 6 u 17 64 17 0.527 0.035 0.007

至此,所有的NTP操作就全部完毕了。

最新文章

  1. bash学习
  2. herbnate session.createSQLQuery(sql) 和 session.createQuery(sql)使用
  3. DOM和DHTML等,复习总结
  4. Android Apk反编译得到Java源代码
  5. 如何由jdk的安装版本改成非安装版本
  6. Ubuntu创建launcher
  7. python time模块详解(转)
  8. C# 颜色转换
  9. Error: rpmdb open failed
  10. Web--->>>Cookie与Session
  11. mac下安装 resin 奇葩问题总结
  12. 扩展Python模块系列(二)----一个简单的例子
  13. python基础7之python3的内置函数
  14. 【PL/SQL基础知识】结构
  15. Mysql Binlog三种格式介绍及分析【转】
  16. sql server Local Service, Local System or Network Service
  17. Jamie and Tree CodeForces - 916E (换根)
  18. lnmp服务器配置HTTPS
  19. 微软BI 之SSAS 系列 - 在 SQL Server 2012 下查看 SSAS 分析服务的模型以及几个模型的简单介绍
  20. AT&T汇编和Intel汇编语法主要区别

热门文章

  1. 在Visual Studio Code 运行 webpack ./src/main.js --output-filename ./dist/bundle.js --output-path . --mode development 提示 Module no t found:Error:Can't resolve' 'jquery' 是因为vs code还没安装jquery
  2. C# 异步编程 (12)
  3. flutter 跳转至根路由
  4. BZOJ 3630: [JLOI2014]镜面通道 (网络流 +计算几何)
  5. TypeError: Object of type 'ListSerializer' is not JSON serializable
  6. [Spring] Spring Data JPA
  7. HDU 6068 - Classic Quotation | 2017 Multi-University Training Contest 4
  8. linux系统相关文件和操作
  9. React组件式编程Demo-用户的增删改查
  10. Mac中iterm2显示彩色