查看时区
[root@web ~]# date -R
查看所有时区
[root@web ~]# ls /usr/share/zoneinfo/
#修改日期
timedatectl set-time 2016-04-25
#修改时间
timedatectl set-time '2016-04-26 21:53:50'
#设置系统时区为上海
timedatectl set-timezone Asia/Shanghai
一、实验环境准备
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum install chrony -y Redhat7 为ntp
主配置文件:
[root@localhost ~]# vim /etc/chrony.conf
二、配置时间服务器
同步两主机时区:
[root@localhost ~]# timedatectl set-local-rtc 0
[root@localhost ~]# timedatectl set-local-rtc 0
服务器端:
[root@localhost ~]# vim /etc/chrony.conf
启动服务:[root@localhost ~]# systemctl restart chronyd.service
[root@localhost ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; ve>
Active: inactive (dead) since Mon 2020-07-13 16:38:45 +08; 3min 40s ago
Docs: man:firewalld(1)
Process: 1066 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD>
Main PID: 1066 (code=exited, status=0/SUCCESS)
7月 14 10:54:42 localhost.localdomain systemd[1]: Starting firewalld - dy>
7月 14 10:54:44 localhost.localdomain systemd[1]: Started firewalld - dyn>
7月 13 16:38:44 localhost.localdomain systemd[1]: Stopping firewalld - dy>
7月 13 16:38:45 localhost.localdomain systemd[1]: Stopped firewalld - dyn>
lines 1-11/11 (END)
客户端:
先修改系统时间:错误时间
[root@localhost ~]# date 071612122020
2020年 07月 16日 星期四 12:12:00 CST
更改配置文件:[root@localhost ~]# vim /etc/chrony.conf
同步时间:
[root@localhost ~]# chronyc sources
显示状态:[root@localhost ~]# chronyc sources -v
[root@localhost ~]# date
2020年 07月 13日 星期一 17:20:57 CST