网络时间服务
网络时间服务:ntp 和 chrony
ntp 和 chrony 既可做客户端也可做服务器,需要时时开启与服务器同步,也需要时时等待客户端的连接,不同与c/s结构,作为客户端也要时时开启,因为需要时时与服务器同步。
ntp服务配置
ntp作为客户端
yum install ntp -y
vim /etc/ntp.conf
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
date -s '+10 month'
service ntpd start
已经经同步
以上是基于centos6
ntp作为服务器
yum install ntp -y
vim /etc/ntp.conf (centos6注释掉以下行)
#restrict default kod nomodify notrap nopeer noquery
service ntpd start
ntp服务端口
ntp服务端口为 udp 的 123 端口
chrony 服务
chrony客户端配置
yum install chrony -y
vim /etc/chrony.conf
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
date -s '-2 year'
systemctl restart chronyd
chrony服务端配置
yum install chrony -y
vim /etc/chrony.conf
allow 0.0.0.0/0 //允许所有客户端
local stratum 10 //本机不能与服务器同步了,也允许客户端与本机同步
systemctl start chronyd
chrony服务的端口
# timedatectl 命令
timedatectl list-timezones 查看时区
系统默认的时区
设置时区
timedatectl set-timezone Africa/Gaborone
ln -s …/usr/share/zoneinfo/Asia/Shanghai /etc/localtime