///
/// 安装
///
[iyunv@wode012 mysql]# yum install ntp 已加载插件:fastestmirror, langpacks Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Repository contrib is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 软件包 ntp-4.2.6p5-19.el7.centos.3.x86_64 已安装并且是最新版本 无须任何处理 [iyunv@wode012 mysql]#
///
/// vi /etc/ntp.conf
///
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server time.lib.tsinghua.edu.cn server cn.pool.ntp.org
/// /// systemctl enable/status/start /// [iyunv@wode012 etc]# systemctl enable ntpd.service [iyunv@wode012 etc]# systemctl status ntpd.service ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled) Active: inactive (dead)
[iyunv@wode012 etc]# systemctl start ntpd.service [iyunv@wode012 etc]# systemctl status ntpd.service ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled) Active: active (running) since 六 2015-11-14 23:48:34 CST; 2s ago Process: 26192 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 26193 (ntpd) CGroup: /system.slice/ntpd.service └─26193 /usr/sbin/ntpd -u ntp:ntp -g
/// /// firewall /// [iyunv@wode012 services]# firewall-cmd --add-service=ntp --permanent success [iyunv@wode012 services]# firewall-cmd --list-all public (default, active) interfaces: enp3s0f0 enp3s0f1 sources: services: dhcpv6-client mysql ssh ports: 8703/tcp masquerade: no forward-ports: icmp-blocks: rich rules: [iyunv@wode012 services]# firewall-cmd --reload success [iyunv@wode012 services]# firewall-cmd --list-all public (default, active) interfaces: enp3s0f0 enp3s0f1 sources: services: dhcpv6-client mysql ntp ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules: [iyunv@wode012 services]#
// for old version, iptables iptables -A INPUT -p udp -dport 123 -j ACCEPT
/// /// check on server /// [iyunv@wode012 etc]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== web.lib.tsinghu .INIT. 16 u - 64 0 0.000 0.000 0.000 +news.neu.edu.cn 202.118.1.46 2 u 24 64 1 12.675 -5.860 0.000 +dns1.synet.edu. 202.118.1.46 2 u 14 64 1 12.546 -5.778 1.238 *202.118.1.130 202.118.1.46 2 u 13 64 1 12.399 -5.711 0.797 dns.sjtu.edu.cn .INIT. 16 u - 64 0 0.000 0.000 0.000
///
/// test on client /// #!/bin/bash
# sync time /usr/sbin/ntpdate 192.168.1.134
# write to hw /usr/sbin/hwclock -w
|