场景及报错信息:
在做Ansible 测试的时候遇到以下报错:
[root@control ansible]# ansible all -a 'chronyc sources'
node2 | FAILED | rc=1 >>
506 Cannot talk to daemonnon-zero return code
node1 | FAILED | rc=1 >>
506 Cannot talk to daemonnon-zero return code
解决方案:
在control node1, node2上分别按照以下步骤操作
安装chrony
[root@localhost ~]# dnf -y install chrony
时间同步
1.设置时区
[root@localhost ~]# timedatectl set-timezone "Asia/Shanghai"
2.配置chrony.conf
添加时间服务器参数:pool ntp.aliyun.com iburst
[root@localhost ~]# vim /etc/chrony.conf
[root@control ansible]# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
pool 2.centos.pool.ntp.org iburst
pool ntp.aliyun.com iburst //添加服务器参数
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
3.重新加载配置
[root@localhost ~]# systemctl restart chronyd.service
4.再次测试:[root@control ansible]# ansible all -a 'chronyc sources'
[root@control ansible]# ansible all -a 'chronyc sources'
node2 | CHANGED | rc=0 >>
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* time.neu.edu.cn 1 6 17 11 +108us[+2427us] +/- 19ms
^- ntp.wdc2.us.leaseweb.net 2 6 17 11 +28ms[ +30ms] +/- 258ms
^- time.cloudflare.com 3 6 17 11 +16ms[ +19ms] +/- 113ms
^- 119.28.183.184 2 6 17 11 -3651us[-3651us] +/- 66ms
^- 203.107.6.88 2 6 17 11 -5117us[-5117us] +/- 29ms
node1 | CHANGED | rc=0 >>
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ 119.28.183.184 2 6 17 18 -3250us[-3460us] +/- 43ms
^- time.cloudflare.com 3 6 17 17 +9550us[+9340us] +/- 107ms
^+ time.neu.edu.cn 1 6 17 17 +1765us[+1554us] +/- 18ms
^- ntp.wdc2.us.leaseweb.net 2 6 17 17 +27ms[ +27ms] +/- 255ms
^* 203.107.6.88 2 6 17 16 -1438us[-1649us] +/- 27ms