ntp服务器宕了oracle,ntp服务器设置

本文详细指导如何在Linux系统中设置NTP服务器192.168.56.200,配置ntp.conf,启动服务并确保客户端192.168.56.11和192.168.56.12同步,包括检查包安装、防火墙设置和定时同步。
摘要由CSDN通过智能技术生成

192.168.56.11   ntp服务器

192.168.56.200  ntp服务器上层同步ip

192.168.56.12   客户端

1:查看客户端和服务器端ntp rpm包是否安装

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

fontpackages-filesystem-1.41-1.1.el6.noarch

ntp-4.2.4p8-3.el6.x86_64

ntpdate-4.2.4p8-3.el6.x86_64

如果没有后面两个,需要安装,注意是客户端和服务器端都要查看

2:在需要做ntp服务器的主机 编辑 /etc/ntp.conf

[root@11g ~]# cp /etc/ntp.conf /etc/ntp.conf.bak  先拷贝一份做备份

[root@11g ~]# rm -rf /etc/ntp.conf                显出原始ntp配置文件

[root@11g ~]# vi /etc/ntp.conf                    重新编辑一份ntp配置文件

driftfile /var/lib/ntp/drift

restrict 192.168.56.12

restrict 127.0.0.1

restrict -6 ::1

server 192.168.56.200

fudge 192.168.56.200 stratum 8

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

注释:

restrict 192.168.56.12

restrict 127.0.0.1

restrict -6 ::1

server 192.168.56.200

fudge 192.168.56.200 stratum 8

还有一种方案是:

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

driftfile /var/lib/ntp/drift

restrict default  nomodify notrap

restrict 127.0.0.1

restrict -6 ::1

server 192.168.56.200

fudge 192.168.56.200 stratum 8

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

3:启动ntp服务器

[root@11g ~]# /etc/init.d/ntpd start       启动

Starting ntpd:                                             [  OK  ]

[root@11g ~]# chkconfig ntpd on            设置开机自启动ntpd服务

[root@11g ~]# lsof -i:123                   查看123端口

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

ntpd    2862  ntp   16u  IPv4  22529      0t0  UDP *:ntp

ntpd    2862  ntp   17u  IPv6  22530      0t0  UDP *:ntp

ntpd    2862  ntp   18u  IPv6  22534      0t0  UDP localhost6.localdomain6:ntp

ntpd    2862  ntp   19u  IPv6  22535      0t0  UDP [fe80::a00:27ff:fe8a:b4f0]:ntp

ntpd    2862  ntp   20u  IPv6  22536      0t0  UDP [fe80::a00:27ff:feb9:c941]:ntp

ntpd    2862  ntp   21u  IPv4  22537      0t0  UDP localhost.localdomain:ntp

ntpd    2862  ntp   22u  IPv4  22538      0t0  UDP 11g:ntp

ntpd    2862  ntp   23u  IPv4  22539      0t0  UDP 192.168.110.12:ntp

[root@11g ~]# ntpq -p        如果出现这样的情况,ntp服务器最后设置才算成功

remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

*192.168.56.200  LOCAL(0)        11 u    9   64  377    1.362    2.822   0.449

以下是失败的设置:

[root@11g ~]# ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

192.168.56.200  .INIT.          16 u   41   64    0    0.000    0.000   0.000

4:防火墙设置

iptables -I INPUT -p udp -m udp --sport 123 -j ACCEPT    对外开放123端口

最好的办法是将所有linux系统的防火墙都关闭:

chkconfig --level 2345 ip6tables off

chkconfig --level 2345 iptables off

service ip6tables stop

service iptables stop

查看是否关闭成功:

[root@mysql ~]# chkconfig --list | grep ip

ip6tables      0:off1:off2:off3:off4:off5:off6:off

iptables      0:off1:off2:off3:off4:off5:off6:off

3:客户端设置

[root@mysql ~]# ntpdate 192.168.56.11  设置同步

22 Jul 06:53:14 ntpdate[5611]: no server suitable for synchronization found

[root@mysql ~]# ntpdate -d 192.168.56.11  查看原因

22 Jul 02:55:01 ntpdate[2096]: ntpdate 4.2.4p8@1.1612-o Thu Jan 10 15:17:41 UTC 2013 (1)

Looking for host 192.168.56.11 and service ntp

host found : 11g

transmit(192.168.56.11)

receive(192.168.56.11)

transmit(192.168.56.11)

receive(192.168.56.11)

transmit(192.168.56.11)

receive(192.168.56.11)

transmit(192.168.56.11)

receive(192.168.56.11)

transmit(192.168.56.11)

192.168.56.11: Server dropped: strata too high

server 192.168.56.11, port 123

stratum 16, precision -24, leap 11, trust 000

refid [192.168.56.11], delay 0.02599, dispersion 0.00005

transmitted 4, in filter 4

reference time:    00000000.00000000  Thu, Feb  7 2036 14:28:16.000

originate timestamp: d777e086.0c12c80f  Tue, Jul 22 2014  2:55:02.047

transmit timestamp:  d777e086.0bf476b0  Tue, Jul 22 2014  2:55:02.046

filter delay:  0.02658  0.02638  0.02602  0.02599

0.00000  0.00000  0.00000  0.00000

filter offset: 0.000135 -0.00003 0.000137 0.000145

0.000000 0.000000 0.000000 0.000000

delay 0.02599, dispersion 0.00005

offset 0.000145

22 Jul 02:55:02 ntpdate[2096]: no server suitable for synchronization found

如果stratum 设置没有问题的话,第一次执行

[root@mysql ~]# ntpdate 192.168.56.11

22 Jul 06:53:14 ntpdate[5611]: no server suitable for synchronization found

需要再等上3-5分钟再次执行

[root@mysql ~]# ntpdate 192.168.56.11

22 Jul 06:54:45 ntpdate[5627]: adjust time server 192.168.56.11 offset -0.119003 sec

4:客户端设置定时同步时间

[root@mysql ~]# vi /root/ntpupdate.sh    编辑定时脚本

/usr/sbin/ntpdate 192.168.56.11

[root@mysql ~]# cat /root/ntpupdate.sh   编辑完之后查看

/usr/sbin/ntpdate 192.168.56.11

[root@mysql ~]# crontab -e               编辑定时任务,每分钟执行一次

*/1 * * * * /root/ntpupdate.sh

[root@mysql ~]# crontab -l

*/1 * * * * /root/ntpupdate.sh            编辑后查看

注意:

1:本身主机设置成ntp服务器:

[root@oracle11g ~]# cat /etc/ntp.conf

idriftfile /var/lib/ntp/drift

restrict default  nomodify notrap

restrict 127.0.0.1

restrict -6 ::1

server 127.127.1.0

fudge 127.127.1.0 stratum 8

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

2:客户端手工设置ntpdate时,需要stop 客户端的ntpd服务

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值