Centos 7 Ntp 服务器的配置

我的hadoop 节点有两个, 两个cdhslave节点,一个master节点;

cdh02,cdh03为slave节点,cdh01为master节点

ntp服务器和两个节点,两个节点的时间从master节点获取时间并进行同步。

在master节点  先检查有没有ntp fuwu安装

rpm -qa | grep ntp 

以上代码如果有这个安装包,先进行清理;

后安装ntp

yum install -y ntp
[[email protected] ~]# yum install -y ntp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-29.el7.centos will be installed
--> Processing Dependency: ntpdate = 4.2.6p5-29.el7.centos for package: ntp-4.2.6p5-29.el7.centos.x86_64
--> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-29.el7.centos.x86_64
--> Running transaction check
---> Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
---> Package ntpdate.x86_64 0:4.2.6p5-29.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

# Please consider joining the pool (http://www.pool.ntp.org/join.html).
===========================================================================================================================
 Package                         Arch                   Version                                 Repository            Size
===========================================================================================================================

以上为安装日志

安装完后

进行配置

vi /etc/ntp.conf

在根目录进行以上配置

配置文件如下

# 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 172.16.9.130 mask 255.255.255.0 nomodify notrap  #这里把ip地址改成你的master(本机)de ip地址
#########################################
# Use public servers from the pool.ntp.org project.
# 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
#++++++++++++++++++++++++++++++++++
#注释在这里结束+++++++++++++++++++++++++
#broadcast 192.168.1.255 autokey        # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 autokey            # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor
#+++++++++++++++++++++++++++++++++++++++++++++++
#+++++最后加上这两句+++++++++++++++++++++++++++++++++
server 127.127.1.0
fudge 127.127.1.0 stratum 10
#以上所有的配置,先吧时间区域改成上海,再进行

然后把服务设置成开机启动...

chkconfig ntpd on

然后 启动服务

systemctl start ntpd

----------------------------------------------------

master节点配置结束

接下来我们配置slave节点

在slave节点一下命令进行配置

crontab -e

然后文件内容输入一下内容:

0-59/5 * * * * /usr/sbin/ntpdate cdh01

# cdh01 为maister节点的hostname(之前在hosts文件里已经配置过映射)

0-59为 任何一秒

5 为每个五分钟同步一次时间

cdh02,cdh03两个节点都进行这个配置。

ntp服务配置完毕

原文地址:https://www.cnblogs.com/MegaByte/p/12234106.html

时间: 2024-07-30 17:33:32

Centos 7 Ntp 服务器的配置的相关文章

实例节点的NTP服务器地址配置正确,而且能够ping通, 但是在chronyc sources指令中显示NTP服务器状态为“?”

问题:如果实例节点的NTP服务器地址配置正确,而且能够ping通,   但是在chronyc sources指令中显示NTP服务器状态为“?”, 该如何检查并操作. 1)在chrony配置文件中,检查NTP服务器在当前网段是否打开allow的功能. 2)检查防火墙是否关闭. 原文地址:https://www.cnblogs.com/l-a-s/p/11525514.html

NTP服务器的配置

安装cloudera Manager的时候,必须要求集群的主机之间时间同步,搭建一个NTP服务器的思路是,首先通过一台主机master与外网进行时间同步,然后其他的slaver主机与主机master进行时间同步. 1.所有节点配置NTP服务 集群中所有主机必须保持时间同步,如果时间相差较大会引起各种问题. 具体思路如下: master节点作为ntp服务器与外界对时中心同步时间,随后对所有datanode节点提供时间同步服务. 所有datanode节点以master节点为基础同步时间. 所有节点安

CentOS搭建NTP服务器

一.搭建时间同步服务器1.编译安装ntp serverrpm -qa | grep ntp若没有找到,则说明没有安装ntp包,从光盘上找到ntp包,使用rpm -Uvh ntp***.rpm进行安装2.修改ntp.conf配置文件vi /etc/ntp.conf①.第一种配置:允许任何IP的客户机都可以进行时间同步将"restrict default nomodify notrap noquery"这行修改成:restrict default nomodify notrap配置文件示例

Centos 6.5 服务器下面配置邮件客户端 发送报警邮件

以Centos 系统为例,确保服务器可以正常连接外网 Centos 6.5 下面默认 安装 postfix 查看 rpm -qa | grep postfix postfix-2.6.6-2.2.el6_1.x86_64 配置邮件客户端 set [email protected] set smtp=smtp.163.com set [email protected] set smtp-auth-password=UserPassword set smtp-auth=login 发送测试邮件  e

CentOS 越南韩国服务器时间同步配置方法

由于公司的游戏需要在越南和韩国上线,越南的时间比我们慢一个小时,韩国的时间比我们快一个小时,所以服务器配置系统环境的时候需要设置越南服务器同步越南的时间点,韩国服务器同步韩国的时间点,下面设置方法如下: 一.设置越南服务器时间同步: cat > /var/spool/cron/root <<EOF*/30 * * * *  /usr/sbin/ntpdate ntp0.cs.mu.OZ.AU > /dev/null 2>&1EOF service crond rest

AIX6.1同步远程NTP服务器时钟配置

AIX6.1上ntp服务进程名叫xntp,默认这个进程是不启动的,那么首先要启动xntpd这个守护进程 startsrc -s xntp 最好做成随系统自动启动 编辑/etc/net.conf配置,增加一个远程 NTP时钟源,在最下面增加以下四行 broadcastclientserver  120.4.8.1   #远程NTP时钟源IPdriftfile /etc/ntp.drifttracefile /etc/ntp.trace 使用lssrc -ls xntpd   查看详细情况,(注意刚

Centos安装FTP服务器和配置

安装 yum install vsftpd 启动/重启/关闭 /sbin/service vsftpd start /sbin/service vsftpd restart /sbin/service vsftpd stop 配置文件 /etc/vsftpd/vsftpd.conf 匿名上传下载 修改配置文件即可vsftpd.conf anonymous_enable=yes anon_upload_enable=yes anon_mkdir_write_enable=yes anon_umas

CentOS7搭建NTP服务器及客户端同步时间

一.服务器配置 1.查看服务器.客户端操作系统版本 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) 2.查看服务器是否安装ntp,系统默认安装ntpdate: [[email protected] ~]# rpm -qa | grep ntp fontpackages-filesystem-1.44-8.el7.noarch ntpdate-4.2.6p5-28.el7.cen

centos配置ntp服务器教程

当服务器多了,时间准确与否,一致与否是个大问题.虽然这个问题总是被忽略,但是统一一致的时间是很有必要的.下面说一下在局域网内配置Linux时间服务器的方法. NtpServer篇: #1.安装ntp yum -y install ntp #2.修改配置文件 vi /etc/ntp.conf #更改配置文件如下: #上级同步服务器:北京大学同步地址 server s2m.time.edu.cn #上级服务器不通时使用本地服务 server 127.127.1.0 # local clock fud