CRH5.1_x64_CentOS7集群上搭建ntp服务器实现时间同步
2018-03-27 10:19
621 查看
分有外网和无外网情况。
注意配置ip映射1. 有外网
每台机器直接安装使用ntp服务,让时间与网络时间同步。安装 [root@redoop01 ~]# for ip in $(cat hosts);do ssh ${ip} yum install -y ntp; done 启动 [root@redoop01 ~]# for ip in $(cat hosts);do ssh ${ip} systemcntl start ntpd ; done 开机自启动 [root@redoop01 ~]# for ip in $(cat hosts);do ssh ${ip} systemcntl enable ntpd ; done
2. 无外网,选一台机器做ntp server,其他机器做 ntp client
集群所有机器安装 ntp[root@redoop01 ~]# for ip in $(cat hosts);do ssh ${ip} yum install -y ntp; done
启动ntp server节点 ntp服务
systemctl start ntpd systemctl enable ntpd
在server节点上设置其ntp服务器为其自身,同时设置可以接受连接服务的客户端,通过更改/etc/ntp.conf文件来实现,其中server设置127.127.1.0为其自身,新增加一个restrict段为可以接受服务的网段
# For more information about this file, see the man pages # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). driftfile /var/lib/ntp/drift # Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. restrict default nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict ::1 restrict 192.168.0.0 mask 255.255.0.0 # Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). server 127.127.1.0 #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 ###
重启ntp server 节点的 ntp 服务
systemctl restart ntpd
在client节点上设置ntp server机器为 授时服务器
# For more information about this file, see the man pages # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). driftfile /var/lib/ntp/drift # Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. restrict default nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict ::1 # Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). server redoop03 #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst
在client节点上同步server的时间
ntpdate redoop03
client节点启动ntpd服务
systemctl start ntpd systemctl enable ntpd
所有节点启动时间同步
timedatectl set-ntp yes
查看同步效果
[root@redoop01 ~]# for ip in $(cat hosts);do ssh ${ip} date -R;done Mon, 26 Mar 2018 16:03:08 +0800 Mon, 26 Mar 2018 16:03:08 +0800 Mon, 26 Mar 2018 16:03:09 +0800 [root@redoop01 ~]#
更多精彩原创文章,详见红象云腾社区
相关文章推荐
- centos7.2上搭建ntp服务器,并实现时间同步
- 通过NTP服务器实现时间同步
- Centos7上搭建SVN服务器并实现自动同步至web目录
- NTP服务器时间集群借节点之间同步
- linux集群时间同步搭建
- 为嵌入式开发板客户端自己动手在虚拟机上搭建时间同步NTP服务器
- linux集群时间同步搭建
- 基于windows 2008R搭建NTP服务器,同步时间
- [linux]通过ssh远程设定各服务器时间,从而实现集群时间同步
- Linux集群的NTP服务器时间同步
- 基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】搭建HAWQ数据仓库——安装配置NTP服务,保证集群时间保持同步
- Centos7部署ntp服务器同步时间以及直接将本地时间同步为北京时间
- 搭建NTP服务器实现时钟同步
- 在Centos7上搭建SVN服务器并实现自动同步至web目录
- Centos7上搭建SVN服务器并实现自动同步至web目录
- Linux上搭建ntp服务,实现时间同步
- CentOS6.5搭建NTP服务器,并为思科交换机提供时间同步
- centos7集群中NTP设置时间同步