pps破解版下载,陈国鹏,sm新组合
chrony软件使用说明
chrony简介 chrony是一个开源的自由软件,它能保持系统时钟与时间服务器(ntp)同步,让时间保持精确。 它由两个程序组成:chrongd和chronyc。 chronyd是一个后台运行的守护进程,用于调整内核运行的系统时钟和时间服务器同步。 它确定计算机增减时间的比率,并对此进行补偿。 chrony是centos7.x上自带的时间同步软件
1 #yum install chrony --rhel7默认已安装chrony,而没有安装ntpd。 2 3 #systemctl status chronyd --查看chronyd服务状态 4 5 #systemct enable chronyd --开机启动 6 7 #vim /etc/chrony.conf --修改配置文件 8 9 #server 0.rhel.pool.ntp.org iburst --注释这4行,表示的是外网时间服务器的网址。 10 11 #server 1.rhel.pool.ntp.org iburst 12 13 #server 1.rhel.pool.ntp.org iburst 14 15 #server 1.rhel.pool.ntp.org iburst 16 17 server 192.168.56.112 iburst --添加这一行,表示与本机同步时间 18 19 local stratum 10 -->>该行注释取消掉不然ntp synchronized: 为no 取消掉后变为 ntp synchronized:yes 20 21 #allow ntp client access from local network. 22 23 allow 192.168.56.0/24 -->>允许哪些服务器或客户端到这台时间服务器来同步时间。必须配置 24 25 #systemctl restart chronyd -->>修改完配置文件后,重启chrony服务
[root@chronyd ~]# netstat -antulp|grep chronyd -->>查看时间服务器是否允许 udp 0 0 0.0.0.0:123 0.0.0.0:* 12505/chronyd udp 0 0 127.0.0.1:323 0.0.0.0:* 12505/chronyd udp6 0 0 ::1:323 :::* 12505/chronyd [root@chronyd ~]# ss -antulp|grep chronyd udp unconn 0 0 *:123 *:* users:(("chronyd",pid=12505,fd=7)) udp unconn 0 0 127.0.0.1:323 *:* users:(("chronyd",pid=12505,fd=5)) udp unconn 0 0 ::1:323 :::* users:(("chronyd",pid=12505,fd=6))
[root@chronyd ~]#timedatectl local time: 二 2019-11-12 11:06:46 cst universal time: 二 2019-11-12 03:06:46 utc rtc time: 二 2019-11-12 03:06:46 time zone: asia/shanghai (cst, +0800) ntp enabled: yes ntp synchronized: yes rtc in local tz: no dst active: n/a 注意ntp synchronized值,只有时间服务器自己同步完成时间后,才能为其他服务器提供时间同步。
timedatectl set-time "yyyy-mm-dd hh:mm:ss" timedatectl set-time "yyyy-mm-dd" timedatectl set-time "hh:mm:ss"
1 [root@chronyd ~]# timedatectl list-timezones |grep asia/shanghai 2 asia/shanghai
1 [root@chronyd ~]# timedatectl set-timezone asia/shanghai
1 [root@chronyd ~]# timedatectl set-local-rtc 1 2 [root@chronyd ~]# hwclock --systohc --localtime 3 #两条命令效果等同
1 [root@chronyd ~]# timedatectl set-ntp yes 2 [root@chronyd ~]# timedatectl set-ntp true
1 #两条命令效果等同 2 问题:ntp设置为yes,手动设置时间报错。
1 [root@chronyd ~]# chronyc sources -v 2 210 number of sources = 1 3 4 .-- source mode '^' = server, '=' = peer, '#' = local clock. 5 / .- source state '*' = current synced, '+' = combined , '-' = not combined, 6 | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. 7 || .- xxxx [ yyyy ] +/- zzzz 8 || reachability register (octal) -. | xxxx = adjusted offset, 9 || log2(polling interval) --. | | yyyy = measured offset, 10 || \ | | zzzz = estimated error. 11 || | | \ 12 ms name/ip address stratum poll reach lastrx last sample 13 =============================================================================== 14 ^* chronyd 10 6 177 9 -15ns[ -15us] +/- 25us 15 16 [root@chronyd ~]#
#yum install chrony -y -->>安装时间服务器软件
1 [root@client ~]# vim /etc/chrony.conf 2 3 # use public servers from the pool.ntp.org project. 4 # please consider joining the pool (http://www.pool.ntp.org/join.html). 5 #server 0.centos.pool.ntp.org iburst 6 #server 1.centos.pool.ntp.org iburst 7 #server 2.centos.pool.ntp.org iburst 8 #server 3.centos.pool.ntp.org iburst 9 server 192.168.56.112 iburst -->>添加该行,表示到这台服务器去同步时间。
1 [root@client ~]# systemctl restart chronyd.service -->>重启chrony服务 2 [root@client ~]# systemctl enable chronyd.service -->>设置开机自启动模式
1 [root@client ~]# timedatectl 2 local time: 四 2013-02-14 12:37:25 cst 3 universal time: 四 2013-02-14 04:37:25 utc 4 rtc time: 日 2019-05-12 04:24:01 5 time zone: asia/shanghai (cst, +0800) 6 ntp enabled: no 7 ntp synchronized: yes -->>为yes表示已同步 8 rtc in local tz: no 9 dst active: n/a
[root@client ~]# ntpdate 192.168.56.112 14 feb 12:40:09 ntpdate[8038]: adjust time server 192.168.56.112 offset -0.000067 sec
1 [root@client ~]# crontab -l 2 */2 * * * * /usr/sbin/ntpdate 192.168.56.112 -->>创建脚本每个2分钟来同步时间一次
1 如果同步失败,有可能是时间服务器的时间为同步,即时间服务器ntp synchronized 为no 2 3 手动修改时间时,必须把ntp enable 设置为no 4 5 如果把 ntp enable修改为yes时,表示开启自动同步时间,此时,是不能手动修改时间的。如果为no时,表示关闭自动同步时间。
1 [root@chronyd ~]# timedatectl set-ntp true 2 3 [root@chronyd ~]# timedatectl set-time "2019-11-11 12:56:11" 4 failed to set time: automatic time synchronization is enabled
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
linux下文本编辑器vim的使用方法(复制、粘贴、替换、行号、撤销、多文件操作)
网友评论