NTP 服务概述
腾讯云内网 NTP 服务器
1
2
3
4
5
|
time1.tencentyun.com
time2.tencentyun.com
time3.tencentyun.com
time4.tencentyun.com
time5.tencentyun.com
|
腾讯云外网 NTP 服务器
1
2
3
4
5
|
time1.cloud.tencent.com
time2.cloud.tencent.com
time3.cloud.tencent.com
time4.cloud.tencent.com
time5.cloud.tencent.com
|
参考文章:https://cloud.tencent.com/document/product/213/30392
Linux 实例:配置 NTP 服务
https://cloud.tencent.com/document/product/213/30393
设置时区
1
2
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo 'Asia/Shanghai' >/etc/timezone
|
安装chrony
配置chrony
vi /etc/chrony.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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 time1.tencentyun.com iburst
server time2.tencentyun.com iburst
server time3.tencentyun.com iburst
server time4.tencentyun.com iburst
server time5.tencentyun.com iburst
外网则使用以下配置
server time1.cloud.tencent.com iburst
server time2.cloud.tencent.com iburst
server time3.cloud.tencent.com iburst
server time4.cloud.tencent.com iburst
server time5.cloud.tencent.com iburst
|
创建用户chrony,并通过相关命令配置,并启动开机启动chronyd
1
2
3
4
5
6
7
8
|
useradd -M -s /sbin/nologin chrony
mkdir /run/chrony
chown -R chrony:chrony /run/chrony/
chmod 750 /run/chrony/
systemctl restart chronyd
systemctl enable chronyd
|
1
2
3
|
[root@server181 ~]# ps -ef | grep chronyd
chrony 3323 1 0 17:09 ? 00:00:00 /usr/sbin/chronyd
root 4304 3358 0 17:14 pts/0 00:00:00 grep --color=auto chronyd
|
完成
过程中,可能存在以下报错,提示Could not change ownership of /var/run/chrony : Operation not permitted没有权限,可通过上述步骤“创建用户chrony,并通过相关命令配置”解决。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
[root@server182 ~]# systemctl restart chronyd
Job for chronyd.service failed because the control process exited with error code. See "systemctl status chronyd.service" and "journalctl -xe" for details.
[root@server182 ~]# systemctl status chronyd.service
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-08-24 18:16:03 CST; 7s ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 20429 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=1/FAILURE)
Aug 24 18:16:03 server182 systemd[1]: Starting NTP client/server...
Aug 24 18:16:03 server182 chronyd[20431]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Aug 24 18:16:03 server182 chronyd[20431]: Could not change ownership of /var/run/chrony : Operation not permitted
Aug 24 18:16:03 server182 chronyd[20429]: Could not open /var/run/chrony/chronyd.pid : No such file or directory
Aug 24 18:16:03 server182 systemd[1]: chronyd.service: control process exited, code=exited status=1
Aug 24 18:16:03 server182 systemd[1]: Failed to start NTP client/server.
Aug 24 18:16:03 server182 systemd[1]: Unit chronyd.service entered failed state.
Aug 24 18:16:03 server182 systemd[1]: chronyd.service failed.
[root@server182 ~]#
|