Centos6.5 配置NTP服务器

配置NTP-server

环境:

[[email protected] ~]# cat/etc/redhat-release 
CentOS release 6.5 (Final)
[[email protected] ~]# uname -r
2.6.32-431.el6.x86_64
[[email protected] ~]# uname -m
x86_64

安装NTP软件:

[[email protected] ~]# yum install -yntp

检查远程ntp服务器是否可用:

[[email protected] ~]# ntpdate -q ntp5.aliyun.com
server 182.92.12.11, stratum2, offset -0.011808, delay 0.03224
20 Apr 21:15:37ntpdate[3429]: adjust time server 182.92.12.11 offset -0.011808 sec

配置ntp服务之前,先手动同步一下时间:

[[email protected] ~]# ntpdate ntp5.aliyun.com

编辑NTP配置文件:(文件位置在/etc/ntp.conf,编辑前备份)

[[email protected] ~]# cp/etc/ntp.conf /etc/ntp.conf.ori
[[email protected] ~]# vim/etc/ntp.conf
restrict 192.168.22.0 mask255.255.255.0 nomodify notrap
server ntp1.aliyun.com
server ntp2.aliyun.com
server ntp3.aliyun.com
server ntp4.aliyun.com
server ntp5.aliyun.com
server ntp6.aliyun.com
server ntp7.aliyun.com
# UndisciplinedLocal Clock. This is a fake driver intended for backup
# and when nooutside source of synchronized time is available.
# 外部时间服务器不可用时,以本地时间作为时间服务
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10

把之前的参数注释掉:

#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

检查服务状态:

[[email protected] ~]# netstat-lntup|grep ntp
udp        0     0 192.168.22.134:123         0.0.0.0:*                              1186/ntpd           
udp        0     0 127.0.0.1:123              0.0.0.0:*                              1186/ntpd           
udp        0     0 0.0.0.0:123                 0.0.0.0:*                               1186/ntpd           
udp        0     0 fe80::20c:29ff:fe51:259b:123 :::*                                   1186/ntpd           
udp        0     0 ::1:123                    :::*                                    1186/ntpd           
udp        0     0 :::123                     :::*                                   1186/ntpd
[[email protected] ~]# ntpq -p
     remote           refid      st t when poll reach   delay  offset  jitter
==============================================================================
*time5.aliyun.co10.137.38.86     2 u  181 256  377    9.293  -1.990   1.154
+120.25.115.19   10.137.38.86     2 u 138  256  377  45.598   -1.924   1.010
+120.25.115.20   10.137.38.86     2 u 157  256  377  45.795   -1.713   1.113
-time4.aliyun.co10.137.38.86     2 u  247 256  377   45.650  -5.136   2.278
-time6.aliyun.co10.137.38.86     2 u    6 256  377   74.053   8.728   3.008
 LOCAL(0)       .LOCL.          10 l 128m   64   0    0.000    0.000  0.000

ntpstat 命令查看时间同步状态,这个一般需要5-10分钟后才能成功连接和同步。所以,服务器启动后需要稍等下。

[[email protected] ~]# ntpstat
synchronised to NTP server(182.92.12.11) at stratum 3 
time correct to within 30 ms
polling server every 256 s

如果服务器当前时间和远程ntp服务器时间相差很多或者服务器时间比远程ntp服务器时间要快的话,那么服务器是不会与远程ntp服务器同步时间的

需要在ntp.conf中加上一行参数:

tinker panic 0

将同步的时间与硬件时钟进行同步:

[[email protected] ~]# vim /etc/sysconfig/ntpd
添加一行
SYNC_HWCLOCK="yes"
保存退出,重启ntp服务

至此,NTP-server时间服务器配置完成!

配置内网NTP-client

首先需要安装NTPD服务,然后配置为自启动(与NTP-Server完全一样)。然后找其中一台配置/etc/ntp.conf文件,配置完成验证通过后,拷贝到其他客户端机器,直接使用即可。

[[email protected] ~]# grep -Ev ‘#‘/etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict 127.0.0.1 
restrict -6 ::1
server 192.168.22.134
restrict 192.168.22.134nomodify notrap noquery
fudge 127.127.1.0 stratum 10
includefile/etc/ntp/crypto/pw
keys /etc/ntp/keys

将同步的时间与硬件时钟进行同步:

[[email protected] ~]# vim/etc/sysconfig/ntpd
添加一行:
SYNC_HWCLOCK="yes"
保存退出,重启ntp服务。

检查ntp服务状态:

[[email protected] ~]# netstat-lntup|grep ntp
udp        0     0 192.168.22.136:123         0.0.0.0:*                              2833/ntpd           
udp        0     0 127.0.0.1:123               0.0.0.0:*                               2833/ntpd           
udp        0     0 0.0.0.0:123                0.0.0.0:*                              2833/ntpd           
udp        0     0 fe80::20c:29ff:feff:3bf5:123 :::*                                    2833/ntpd           
udp        0     0 ::1:123                    :::*                                   2833/ntpd           
udp        0     0 :::123                     :::*                                   2833/ntpd
[[email protected] ~]# ntpq -p
     remote           refid      st t when poll reach   delay  offset  jitter
==============================================================================
 192.168.22.134 173.255.246.13   3 u   20  64   17    0.218  24.195   0.084
*LOCAL(0)        .LOCL.          10 l  24   64   17   0.000    0.000   0.000
[[email protected] ~]# ntpstat
synchronised to NTP server(192.168.22.134) at stratum 4 
time correct to within 53 ms
polling server every 128 s
时间: 2024-08-07 16:59:08

Centos6.5 配置NTP服务器的相关文章

CentOS6.4 配置mysql服务器启动多个端口,同步单表数据

============================================================ ====多端口启动==== ============================================================ 创建数据目录 mkdir /usr/local/mysql/var1/ mkdir /usr/local/mysql/var2/ =================================================

Linux配置NTP服务器

Linux配置NTP服务器   背景 当服务器多了,时间准确与否,一致与否是个大问题.虽然这个问题总是被忽略,但是统一一致的时间是很有必要的.下面说一下在局域网内配置Linux时间服务器的方法. 配置的环境及要求: 1.假设在192.168.0.0网段内,要以IP为192.168.0.240的Linux机器时间服务器. 2.192.168.0.240服务器能上外网,能与比较权威的公网时间服务器同步 3.同网段内的其他机器每小时自动向192.168.0.240同步时间 配置方法 一.配置NTP服务

用命令设置esxi主机时间和配置NTP服务器

一.设置esxi主机时间 设置esxi主机时间为 2016 年03月8日16:01: 更改esxi系统时间: ~ #  esxcli system time set -d 08 -H 16 -m 01 -M 03 -y 2016 如果同步系统时间到主板上,使用下面命令: ~ # esxcli system time get 更改esxi主机主板上的时间: ~ # esxcli hardware clock set -d 10 -H 10 -m 18 -M 04 -y 2016  如果同步主板到e

搭建配置NTP服务器

1.yum install -y ntp 2.关闭防火墙     service iptables stop     service ip6tables stop     chkconfig iptables off     chkconfig ip6tables off     vim /etc/selinux/config          修改SELINUX=disabled           3.备份ntp.conf配置文件     cp /etc/ntp.conf /etc/ntp.

linux 11G R2 RAC 配置NTP服务器

11G RAC  配置NTP服务器 tip01的IP:162.20.1.228  NTP服务端 tip02的IP:162.20.1.229  NTP客户端 配置NTP服务器之前,确认服务器已装好NTP包 [[email protected] ~]# rpm -qa  | grep ntp ntp-4.2.2p1-9.el5_4.1 chkfontpath-1.10.1-1.1 然后再把服务器的系统时钟与硬件时间同步一下 先查看下系统 [[email protected] ~]# date 201

windows配置NTP服务器

将 Windows 时间服务配置为使用外部时间源管理员可以对位于林根的 PDC 操作主机上的 Windows 时间服务进行配置,使其将外部简单网络时间协议 (SNTP) 时间服务器识别为权威时间服务器.例如,可以将 Microsoft 时间服务器 (time.windows.com) 用作外部 SNTP 时间服务器.要将 Windows 时间服务配置为使用外部 SNTP 时间服务器,请按照下列步骤操作: 1.        单击"开始",单击"运行",键入 rege

日常工作问题解决:配置NTP服务器以及一些常见错误解决

1.配置NTP服务端 环境:redhat 6.5 服务器主机名 ip地址 说明 server 192.168.57.20 NTP服务端 client 192.168.57.21 NTP客户端 搭建说明: 本地server使用外网ntp源同步时间,再作为NTP服务端同步时间给本地client服务器NTP客户端 1.1 安装NTP服务 在ntp服务器查看系统是否安装NTP服务 [[email protected]~]# rpm -qa|grep ntp ntpdate-4.2.6p5-1.el6.x

安装配置NTP服务器

S端: 192.168.1.193 [[email protected] ~]# yum install ntp -y &>/dev/null [[email protected] ~]# rpm -ql ntp /etc/dhcp/dhclient.d /etc/dhcp/dhclient.d/ntp.sh /etc/ntp.conf                        #主配置文件 /etc/ntp/crypto /etc/ntp/crypto/pw /etc/rc.d/ini

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