#################设定时间和时区
1.在server主机中用timedatectl命令设定系统时区为上海,时间为11:11:11
[root@localhost Desktop]# timedatectl set-timezone "Asia/Shanghai" ###设定时区
[root@localhost Desktop]# timedatectl ####查看时间信息
Local time: 三 2016-10-26 13:31:52 CST
Universal time: 三 2016-10-26 05:31:52 UTC
RTC time: 三 2016-10-26 05:31:52
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@localhost Desktop]# timedatectl set-time 11:11:11
[root@localhost Desktop]# date
2016年 10月 26日 星期三 11:11:16 CST
###################同步主机时间
2.配置server主机的chronyd服务,使server主机中的时间可以被desktop主机同步
[root@server Desktop]# yum install chrony -y ####安装chrony服务
Loaded plugins: langpacks
Package chrony-1.29.1-1.el7.x86_64 already installed and latest version ###提示服务已安装
Nothing to do
[root@server Desktop]# vim /etc/chrony.conf ####配置服务端chrony服务文件
[root@server Desktop]# systemctl restart chronyd ####重启chronyd服务
[root@server Desktop]# systemctl stop firewalld ###关闭防火墙
3.同步server主机中的时间到desktop主机中
[root@localhost /]# vim /etc/chrony.conf ####配置客户端chrony文件
[root@localhost /]# systemctl restart chronyd ####重启服务
[root@localhost /]# systemctl stop firewalld ####关闭防火墙
测试:
[root@localhost /]# 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.99 10 6 17 58 -68ns[ +11us] +/- 107us
####################################################同步成功