CDH--彻底解决问题----时钟异常

第 1 章. NTP服务器安装及客户机配置

配置之前要确定时间和现实时间一致,手动配置时间命令sudo date -s "2018-04-18 14:50:02"

配置时区https://www.cnblogs.com/dyj0201/p/6440632.html

如果已有NTP服务器,则使用已有NTP服务器,不使用集群内部重新搭建的NTP服务器。

已有NTP服务器地址为:10.131.11.48,端口为123。

lsof -i:123(端口号)   查看该端口下面对应的进程

1.1. 搭建NTP服务器(NTP服务器) 

1.1.1. 安装NTP

[cdh@bigdata-1 ~]$sudo yum install -y ntp

以下表示系统自带已经安装:

1.1.2. 修改ntp.conf配置文件

[cdh@bigdata-1 ~]$ sudo vim /etc/ntp.conf

将“restrict default kod nomodify notrap nopeer noquery”这行修改成:

restrict default nomodify

如果没有其他NTP服务源,配置本机时间为ntp时间(stratum(层级)的值不能太大,如果要向上级NTP更新需要设置较低的值):将以下2行内容的注释去掉(去掉行开头的“#”号):

同时注释掉server 0/1/2共3行记录:

#server 0.centos.pool.ntp.org

#server 1.centos.pool.ntp.org

#server 2.centos.pool.ntp.org

修改完毕后截图如下:

 

保存并退出:按ESC,再按“:”,输入“wq”,保存文档退出。

ntp服务器主节点,最简洁的配置文件修改--添加以下内容即可:


restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

includefile /etc/ntp/crypto/pw

server 127.127.1.0  #local clock

fudge 127.127.1.0 stratum 10

keys /etc/ntp/keys

driftfile /var/lib/ntp/drift

restrict default nomodify

1.1.3. 启动ntpd服务

[cdh@bigdata-1 ~]$ sudo service ntpd start

[cdh@bigdata-1 ~]$ sudo chkconfig ntpd on

ntpd启动后,客户机要等几分钟再与其进行时间同步,

否则会提示“

no server suitable for synchronization found”错误。

1.2. 配置NTP客户机

1.2.1. 修改ntp.conf配置文件

[cdh@bigdata-2 ~]$ sudo vi /etc/ntp.conf

修改及确认以下红色标记数据(新增行:server IP地址可以为主机名也可以为IP地址):

修改内容如下:新增server ip行,注释:server 1.centos.pool.ntp.org的1和2共2行内容。

同时注释:

server 127.127.1.0     # local clock

fudge  127.127.1.0 stratum 10

# 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 -6 ::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 192.168.70.151

#server 1.centos.pool.ntp.org

#server 2.centos.pool.ntp.org

#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

# Undisciplined Local Clock. This is a fake driver intended for backup

# and when no outside source of synchronized time is available.

#server 127.127.1.0     # local clock

#fudge  127.127.1.0 stratum 10

保存并退出:按ESC,再按“:”,输入“wq”,保存文档退出。

从节点最简洁的配置文件修改--添加以下内容即可:


vi /etc/ntp.conf

driftfile /var/lib/ntp/drift

restrict 127.0.0.1

restrict -6 ::1

server 10.131.11.45 

1.2.2. 启动ntpd服务

先进行一次手动同步时间,需先关闭客户机NTP服务,同步完成以后,再开启NTP服务:

[cdh@bigdata-2 ~]$ sudo service ntpd stop

[cdh@bigdata-2 ~]$ sudo ntpdate 192.168.70.243

手动同步执行结果如下:

 

[cdh@bigdata-2 ~]$ sudo service ntpd start

[cdh@bigdata-2 ~]$ sudo chkconfig ntpd on

成功执行如下:

1.3. 结果验证

[cdh@ bigdata-1~]date

 

分别在集群主机上输入date命令查看对比时间是否一致,如果前后时间不超过10s(10s为切换主机,手动输入的间隔时间),说明时间一致。由于系统版本和语言环境不一样,可能出现的时间格式不一定完全一致,但是不影响结果验证。

1.4. 问题及处理

查看同步进展为   watch ntpq -p 

 

手动同步时间  Ntpdate -d IP(NTP服务器IP)

 

 

如果NTP服务器自身不同步成LOCAL模式则会出现以下错误

 

[root@master etc]# ntpdate -d slave1   

12 Jul 16:10:20 ntpdate[31734]: ntpdate 4.2.6p5@1.2349-o Fri Dec 19 16:19:04 UTC 2014 (1)

Looking for host slave1 and service ntp

host found : slave1

transmit(10.131.11.45)

receive(10.131.11.45)

transmit(10.131.11.45)

receive(10.131.11.45)

transmit(10.131.11.45)

receive(10.131.11.45)

transmit(10.131.11.45)

receive(10.131.11.45)

10.131.11.45: Server dropped: strata too high

server 10.131.11.45, port 123

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

refid [10.131.11.45], delay 0.02589, dispersion 0.00005

transmitted 4, in filter 4

12 Jul 16:10:26 ntpdate[31734]: no server suitable for synchronization found

 

The NTP SOCKET IS IN USE, EXITING 问题


 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值