系统时间管理

it2022-05-05  133

系统时间管理

时间同步

##时间同步服务### 必须关闭客户端和服务端的防火墙; 服务名称 chronyd

服务端 vim /etc/chrony.conf 22 allow 172.25.254.200/24 ##允许那些客户段来同步本机时间 29 local stratum 10(直接打开注释) ##本机不同步任何主机的时间,本机作为时间源

systemctl restart chronyd 客户端 vim /etc/chrony.conf 3-6 server删除 3 server 172.25.254.155 iburst ##本机立即同步200主机的时间 systemctl restart chronyd

测试: 客户端 输入:chronyc sources -v 210 Number of sources = 1 .-- Source mode ‘^’ = server, ‘=’ = peer, ‘#’ = local clock. / .- Source state ‘*’ = current synced, ‘+’ = combined , ‘-’ = not combined, | / ‘?’ = unreachable, ‘x’ = time may be in error, ‘~’ = time too variable. || .- xxxx [ yyyy ] +/- zzzz || / xxxx = adjusted offset, || Log2(Polling interval) -. | yyyy = measured offset, || \ | zzzz = estimated error. || | | MS Name/IP address Stratum Poll Reach LastRx Last sample

^* 172.25.254.210 10 6 37 20 -3278ns[-2461us] +/- 148us ^服务器 *当前同步 需要客户端和服务端查看时间是否同步: 输入date;同步成功

时间管理

timedatectl 命令timedatectl 管理系统时间timedatectl status 显示当前时间(可加可不加,命令默认加此参数)timedatectl set-time “” 设定当前时间timedatectl set-timezone “” 设定当前时区timedatectl set-loacl-rtc 0|1 设定是否使用utc时区 0是使用utc 1不使用utclist-timezon ##查看支持的所有时区

最新回复(0)