ntp为时间同步服务.通过连接ntp中配置的授时中心来校验linux系统时间从而获得更加标准的时间.也可以将自己的ntp搭建为授时服务器
关闭ntp本身对linux没有什么影响,但要注意如果是多台服务器运行业务.有服务需要严格匹配时间尤其是再群集工作环境下.关闭ntp可能导致服务器之间时间不一致,服务之间无法正常对接.
检查时区 date -R

注意这里,如果显示的时区不是+0800,你可以删除localtime文件夹后,再关联一个正确时区的链接过去,命令如下:
# rm -rf /etc/localtime
# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
同步时间
# ntpdate pool.ntp.org
修改NTP配置文件
# vi /etc/ntp.conf
去掉下面这行前面的# ,并把网段修改成自己的网段:
restrict 192.168.122.0 mask 255.255.255.0 nomodify notrap
注释掉以下几行:
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
#server 3.centos.pool.ntp.org iburst
把下面两行前面的#号去掉,如果没有这两行内容,需要手动添加
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
最后,如图所示:

重启ntp服务
centOS7使用:
# systemctl start ntpd.service
# systemctl enable ntpd.service
注意,如果是centOS7以下的版本,使用命令:
service ntpd start
chkconfig ntpd on
集群其他节点去同步这台时间服务器时间
首先需要关闭这两台计算机的ntp服务
centOS7使用:
# systemctl stop ntpd.service 关闭服务
# systemctl disable ntpd.service 关闭服务
# systemctl status ntpd 查看ntp服务状态
# pgrep ntpd 查看ntp服务进程id
centOS7以下,则:
service ntpd stop
chkconfig ntpd off
同步第一台服务器192.168.1.20的时间,切换到root权限执行,不然没有相应权限
# ntpdate


制定计划任务,周期性同步时间,20为主节点,下面命令在 21 22节点执行,让他俩同步20
# crontab -e

重启定时任务
# systemctl restart crond.service
centOS7以下使用:service crond restart,其他台机器的配置同理


相关文章:
-
2022-02-28
-
2021-07-08
-
2021-04-27
-
2022-01-09
-
2022-12-23
猜你喜欢
-
2021-06-29
-
2021-12-09
-
2021-09-23
-
2021-12-14
-
2022-01-12
-
2021-06-19
相关资源
-
下载
2023-02-26
-
下载
2022-12-29
-
下载
2023-01-13
-
下载
2021-07-02