fedora23 搭建时间服务器ntp

来源:互联网 发布:js trigger click 编辑:程序博客网 时间:2024/04/27 20:30

ntp时间服务器非常常用,这里使用的fedora23,实际上和centos7基本无差别,把dnf改为yum就可以,当然centos和redhat系列都可以按照这样来配置时间服务器。
我们按常见的装包,配置,启动服务的顺序来就行了。

setp1:装包

dnf install ntp    -y #centos改成yum install ntp -y

setp2:配置

[root@yeting ~]# ls /etc/ntp.conf /etc/ntp.conf[root@yeting ~]# cat /etc/ntp.conf         #原先的配置文件有好多注释,我用sed清理了下driftfile /var/lib/ntp/driftrestrict default nomodify               #允许任何客户机进行同步restrict 127.0.0.1 restrict ::1server   cn.pool.ntp.org  burst     #决定上行时间服务器,源文件有4个server,我这里只用一个includefile /etc/ntp/crypto/pwkeys /etc/ntp/keysdisable monitor

setp3:起服务

[root@yeting ~]# systemctl  start ntpd[root@yeting ~]# systemctl  enable ntpd[root@yeting ~]# ntpstat   #启动服务后,不会立即同步上行ntp服务器,同步成功后,输出如下synchronised to NTP server (202.118.1.130) at stratum 3    time correct to within 7961 ms   polling server every 64 s

step4:客户端设置

方式1:计划任务方式同步

[root@yeting ~]# crontab -e60 * * * * ntpdate  A.B.C.D             #这里写你的时间服务器ip,60分种同步一次[root@yeting ~]# systemctl  restart crond.service [root@yeting ~]# systemctl  enable crond.service 

方式2:图形同步(不常用,要用到图形界面)

[root@yeting ~]# yum install system-config-date            #安装图形界面配置工具[root@yeting ~]# system-config-date        #调出图形进行设置

这里写图片描述

添加上ntp服务器的ip点击确定就可以了

0 0
原创粉丝点击