164 字
1 分钟
Linux服务器配置校时
数据查不出来?找了半天,md是因为时间不对
在使用服务器时,时间同步很重要,因为很多服务依赖时间,比如数据库、缓存、日志、监控等等。
但是随着运行时间的增长,时间同步的精度会越来越差,因此,建议将服务器的时钟同步到公网时间服务器。
将时区设置为上海
sudo timedatectl set-timezone Asia/Shanghai安装时间同步工具 chrony
# 代理配置#export http_proxy=http://192.168.1.87:3128#export https_proxy=http://192.168.1.87:3128yum install chrony -y# apt install chrony -y配置国内 NTP 服务器/配置内网ntp服务器
sudo vim /etc/chrony.conf
server 192.168.1.244 iburst
server ntp.aliyun.com iburstserver time1.cloud.tencent.com iburstserver ntp1.aliyun.com iburstserver ntp.sjtu.edu.cn iburstserver cn.ntp.org.cn iburst启动并启用 chronyd 服务\验证 chrony 是否运行
systemctl enable chronyd --nowsystemctl start chronydsystemctl status chronyd检查时间同步状态
## 查看跟踪状态chronyc tracking## 查看时间源chronyc sources -v设置 timedatectl 使用 NTP
timedatectl set-ntp true再次查看时间状态
timedatectl如果这篇文章对你有帮助,欢迎分享给更多人!
发现错误或想要改进这篇文章?
在 GitHub 上编辑此页