-
查看是否已安装:
-
CentOS:
rpm -qa | grep ntp-* -
Ubuntu:
dpkg -l | grep ntp-* -
安装:
-
CentOS 6/7:
sudo yum install -y ntp -
Ubuntu:
sudo apt-get install -y ntp
- 官网介绍:https://help.aliyun.com/knowledge_detail/40583.html
- 配置文件介绍(记得先备份):
sudo vim /etc/ntp.conf - 注释掉以下默认的配置内容:
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
- 新增配置:
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com- CentOS 6
- 重启 NTP 服务:
sudo service ntpd start - 添加 NTP 自启动:
sudo chkconfig ntpd on
- 重启 NTP 服务:
- CentOS 7
- 重启 NTP 服务:
sudo systemctl start ntpd.service - 添加 NTP 自启动:
sudo systemctl enable ntpd.service
- 重启 NTP 服务:
- 世界上可以校对时间节点:http://www.pool.ntp.org/zh
- 中国时间校对服务器节点:http://www.pool.ntp.org/zone/cn
- 配置文件介绍(记得先备份):
sudo vim /etc/ntp.conf
- 该配置解释:
- 标注 1 是默认内容,我们这里进行了注释。
- 标注 2 是新增内容,表示使用中国时间校对服务器节点地址。
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org- 启动服务:
sudo service ntpd start - 服务加到启动项
- CentOS 系统:
sudo chkconfig ntpd on - Ubuntu 系统
sudo apt-get install -y sysv-rc-confsudo sysv-rc-conf ntpd on
- CentOS 系统:
