1.7 KiB
1.7 KiB
本文作者:丁辉
NTP时间同步
节点名称 | IP |
---|---|
ntp-master(NTP服务器) | 192.168.1.100 |
node-1 | 192.168.1.10 |
node-2 | 192.168.1.20 |
node-3 | 192.168.1.30 |
基础环境配置
安装 ntp 服务
-
Centos
yum -y install ntp
-
Ubuntu
apt -y install ntp
NTP服务器配置
-
修改配置文件
cp /etc/ntp.conf /etc/ntp.conf.bak vi /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 server 127.127.1.0
填写 127.127.1.0 是一个特殊的IP地址, 代表本地主机(即自己) 或 填写其他授时中心服务器地址
-
启动 ntpd 服务
systemctl enable ntpd systemctl start ntpd
其他节点同步 NTP 服务器时间
-
修改配置文件
cp /etc/ntp.conf /etc/ntp.conf.bak vi /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 server 192.168.1.100
192.168.1.100 为 NTP 服务器 IP 地址
-
启动 ntpd 服务
systemctl enable ntpd systemctl start ntpd
-
启动 ntpd 服务
systemctl enable ntpd systemctl start ntpd
-
查看状态
ntpq -p