之前已经使用ansible 批量安装部署启动过ntp
安装:ansible -i sms_addtikv.txt all -m shell -a "sudo yum install ntp ntpdate -y" -b 启动:ansible -i sms_addtikv.txt all -m shell -a "sudo systemctl start ntpd.service " -b |
但是ansible-playbook deploy.yml 安装tikv时还是报错:
ERROR MESSAGE SUMMARY ********************************************************************************************************************************************************************************************************************************************************
[172.20.34.89]: Ansible FAILED! => playbook: deploy.yml; TASK: check_system_dynamic : Preflight check - NTP service; message: {"changed": false, "msg": "Make sure NTP service is running and ntpstat is synchronised to NTP server. See https://github.com/pingcap/docs/blob/master/op-guide/ansible-deployment.md#how-to-check-whether-the-ntp-service-is-normal ."}
[172.20.34.72]: Ansible FAILED! => playbook: deploy.yml; TASK: check_system_dynamic : Preflight check - NTP service; message: {"changed": false, "msg": "Make sure NTP service is running and ntpstat is synchronised to NTP server. See https://github.com/pingcap/docs/blob/master/op-guide/ansible-deployment.md#how-to-check-whether-the-ntp-service-is-normal ."}
先查看ntp状态
[ansible@st300-hytikv-64] ~$ ntpstat
unsynchronised
polling server every 64 s
没有同步好,接下来手动再操作下
[ansible@st300-hytikv-64] ~$ ntpstat
unsynchronised
time server re-starting
polling server every 8 s
[ansible@st300-hytikv-64] ~$
[ansible@st300-hytikv-64] ~$ sudo systemctl stop ntpd.service
[ansible@st300-hytikv-64] ~$ sudo ntpdate pool.ntp.org
26 Oct 16:28:52 ntpdate[31699]: adjust time server 5.103.139.163 offset 0.001772 sec
[ansible@st300-hytikv-64] ~$ sudo systemctl start ntpd.service
[ansible@st300-hytikv-64] ~$
[ansible@st300-hytikv-64] ~$
[ansible@st300-hytikv-64] ~$ ntpstat
synchronised to NTP server (193.228.143.13) at stratum 3
time correct to within 170 ms
polling server every 64 s
[ansible@st300-hytikv-64] ~$
番外:
一般的执行如下命令,基本可以搞定
$ sudo systemctl stop ntpd.service $ sudo ntpdate pool.ntp.org $ sudo systemctl start ntpd.service |
---|
有时候centos7系统不行,采用下面命令
$ sudo yum install ntp ntpdate $ sudo systemctl start ntpd.service $ sudo systemctl enable ntpd.service |
---|
之后再执行 ansible-playbook deploy.yml命令,就会畅通无阻,顺利执行完成。