RHCE第三章 NTP服务器
知识点:
ntp服务端口号:123
国内时区编号:CST
如何能保证两台虚拟机互通 前提:两台主机具有相同的网络模式
如何查看主机的时间信息 使用date命令
更改时区操作
方法1:
[root@localhost ~]#timedatectl set-timezone Asia/Shanghai
方法2:
[root@localhost ~]#tzselect //而后按下4 10 y
方法3:
[root@localhost ~]#vim ~/.bash_profile
TZ='Asia/Shanghai';export TZ //追加内容退出后重新进入账号即可激活
NTP服务器设置
[root@localhost ~]#mount /dev/sr0 /mnt
[root@localhost ~]#vim /etc/yum.repos.d /base.repo
[BaseOS]
name RHEL8.2-BaseOS
baseurl=file:///mnt/BaseOS/ //url:统一资源定位符
enable=1
gpgcheck=0 //作用:关闭密钥验证
[AppStream]
name AppStream
baseurl=file:////mnt/AppStream/
enable=1
gpgcheck=0
[root@localhost ~]#yum install chrony
注意:此处服务端和客户端都需要配置
案例一:配置主机向外网时间服务器同步时间
(1)更改当前主机所在地时区
[root@localhost~]#timedatectl set-timezone Asia/Shanghai
(2)安装chrony时间同步程序
[root@localhost~]#yum install -y chrony
(3)访问外网 首先确定客户端能够访问外网
(4)[root@localhost~]#vim /etc/chrony.conf
pool slb.time.edu.cn ibusrt 自定义同步时间服务器 此处添加的是某大学时间服务器
[root@localhost~]#systemctl restart chronyd 有延迟
(5)date查看时间是否同步成功
[root@localhost~]#chronyc sources
案例二:自建时间服务器同步时间 配置ntp时间服务器 pool = server
sever:192.168.10.134 服务端配置
(1)更改配置文件
[root@localhost~]#vim /etc/chrony.conf
#pool xxxxxxxxxx
local stratum 10 即使server端无法从互联网同步时间,也同步本机时间至client
allow 192.168.10.0/24 允许客户端同步
(2)重启服务
[root@localhost~]#systemctl restart chronyd
(3)关闭防火墙
[root@localhost~]#systemctl stop firewalld
client:192.168.10.129 客户端配置
(1)date更改时间
(2)[root@localhost~]#vim /etc/chrony.conf
pool 192.168.10.134 添加时间服务器
(3)[root@localhost~]#systemctl restart chronyd
(4)[root@localhost~]# chronyc sources //此条命令主要用于查看时钟源授时时间偏差值

浙公网安备 33010602011771号