NTP
参考:http://blog.sina.com.cn/s/blog_75c7ccf40101hg5l.html
客户端:
yum install ntp -y# 配置vim /etc/ntp.conf#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver 192.100.3.221 iburst# 设置开启服务后自动同步上级ntp server时间vim /etc/ntp/step-tickers192.100.3.221# 启动systemctl restart ntpdsystemctl enable ntpd# 开启同步ntpdate 192.100.3.221# 查看[root@node-1 conf]# ntpq -premote refid st t when poll reach delay offset jitter==============================================================================*yum_repository 192.100.3.221 11 u 42 64 377 0.167 0.667 0.123前面有*说明同步成功# 查看是否开启 NTP synchronized: yestimedatectlntpstat
服务端:
#1.备份配置文件cp /etc/ntp.conf /etc/ntp.conf.bak#2.添加参数vim /etc/ntp.confserver controller iburstrestrict -4 default kod notrap nomodifyrestrict -6 default kod notrap nomodify#3.注释以下参数#restrict default nomodify notrap nopeer noquery#restrict 127.0.0.1#restrict ::1#4.启动ntp服务systemctl enable ntpd.servicesystemctl start ntpd.service配置文件中一般有restrict default语句,#掉后选择,以下2种的一种restrict default nomodify notrap noquery # 默认允许所有可连接客户端ntpdate到本机restrict default ignore # 默认所有客户端禁止ntpdate到本机#与上级服务端连续性同步时间,prefer表示优先,如无可不设置server 上级ntp服务器IP或者域名 [prefer]#当之前设置了restrict default ignore的情况下,可以设置哪些客户可以ntpdate到本机restrict 192.168.1.88 mask 255.255.255.255 nomodify notrap
chrony
#安装yum install chrony -y#控制节点:vim /etc/chrony.confserver controller iburst# Serve time even if not synchronized to a time source.#打开注释,本机不同步任何主机的时间,本机作为时间源local stratum 10#允许访问的网段allow 10.0.0.0/24#其他节点:vim /etc/chrony.confserver controller iburst#启动systemctl enable chronyd.servicesystemctl restart chronyd.servicentpdate controller#验证chronyc sourceschronyc sources -v 查看状态说明timedatectl
