CentOS环境中ntp服务器搭建

主要是简单记录一下ntp服务器的搭建过程,网上攻略很多,这里稍微记录

  1. 安装ntp软件
    直接使用yum就可以了 yum install ntp ntpdate -y

  2. 查找时间同步服务器
    查找的网址为http://www.pool.ntp.org/zone/asia
    对于中国区基本上都是如下内容(来源http://www.pool.ntp.org/zone/cn

    server 0.cn.pool.ntp.org
    server 1.cn.pool.ntp.org
    server 2.cn.pool.ntp.org
    server 3.cn.pool.ntp.org

  3. 配置文件修改
    编辑 /etc/ntp.conf
    server 127.127.1.0 iburst local clock #当外部时间不可用时,使用本地时间。
    restrict x.y.z.c mask 255.255.255.0 nomodify #允许更新的IP地址段

4.防火墙配置
firewall-cmd –add-service=ntp –permanent
firewall-cmd –reload
这样就不需要将防火墙关闭了。

5.启动时间同步服务
systemctl start ntpd
systemctl enable ntpd.service #设置开机启动服务

6.验证是否生效
使用如下命令
ntpq -p
date -R

其它,现在还有一个流行的时间同步应用 chronyd 改天研究一下再补充。

猜你喜欢

转载自blog.csdn.net/haiqinma/article/details/80525523
今日推荐