测试环境为类Debian系统:
服务器端:麒麟V10系统使用NTP做服务器
客户端:麒麟V4系统使用systemd-timesyncd做客户端
麒麟V10系统搭建NTP服务器
1. 服务器端配置
麒麟系统默认安装了同步工具systemd-timesyncd,仅做同步使用。用作同步服务器需安装ntp。
1.1 安装 NTP 服务
命令行执行如下指令:
sudo apt update
sudo apt install ntp
安装ntp时,systemd-timesyncd会自动卸载;同样。卸载ntp时,systemd-timesyncd会自动安装。
1.2 配置 NTP 服务器
vim /etc/ntp.conf
编辑配置文件
1.2.1 注释如下内容:
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
#pool ntp.ubuntu.com
1.2.2 添加如下内容:
server 127.127.1.0 iburst
fudge 127.127.1.0 stratum 10
server 1.ntp1.aliyun.com
server 2.ntp2.aliyun.com
restrict 192.168.3.0 mask 255.255.255.0 nomodify notrap
#192.168.3.0 为内网子网地址。如需多个网段,可添加多行。
1.3 重启 NTP 服务
systemctl restart ntp
2. 客户端配置
vim /etc/systemd/timesyncd.conf
编辑配置文件;
修改:NTP=NTP服务器地址
注意:此IP地址需要能够正常ping通。配置完成后可以修改服务器端日期测试客户端是否能够正常同步,同步时间间隔貌似不固定,暂时没有找到如何修改同步间隔时间,如有大佬知晓,望指教!
客户端也可以安装ntp,添加配置server IP ,IP为服务器地址。