一、安装ntp服务,要使用时间同步、那么服务端与客户端都须要使用以下命令安装NTP软件包html
[root@5201351 ~]# yum install ntp -y
二、若是只是做为客户端的话,配置则能够很是简单,编辑/etc/ntp.conf文件,注释掉默认的以下默认的4行linux
再加上咱们的时间同步服务端的IP地址或者域名便可,其中prefer选项表示优先使用该时间同步服务器centos
#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 iburst //其中iburst :当一个运程NTP服务器不可用时,向它发送一系列的并发包进行检测。 server 192.168.0.2 server 192.168.0.1 prefer logfile /var/log/ntpd.log //添加上日志信息,这个是否是必须的选项
三、而后重启ntpd.service服务,便可向上级NTP服务器进行时间同步服务器
========NTP做服务端的配置>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>网络
四、固然在工做中、也许咱们更多的还得配置本身的服务器为NTP时间同步服务器,让其余客户端进行同步并发
五、一样第一步也是须要安装NTP服务,做为NTP服务端,咱们须要添加那些IP能够进行时间同步,这里编辑/etc/ntp.confspa
restrict 192.168.0.3 //在默认的restrict 127.0.0.1后面加上这一条便可 restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap //也能够按此格式进行添加
六、最后也是重启ntpd.service服务,便可让指定的网络主机及网络段进行时间两步。rest
#########################################################日志
关于配置文件中的一些其余选项的说明以下:code
restrict default kod nomodify notrap nopeer noquery //拒绝 IPv4 的用户,其中默认的没有kod restrict -6 default kod nomodify notrap nopeer noquery //拒绝 IPv6 的用户 restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap //放行指定的段
#########################################################
最后笔者再补充一下关于linux中时间的知识>>>>>>>>
一、linux中时间分为系统时间与硬件时间,系统时间能够经过date命令进行查看
而硬件时间则须要使用hwclock或者hwclock -r命令进行查看
二、设置系统时间:date -s "2016-01-15 15:58:00"
设置硬件时间:hwclock --set --date "2016-01-15 15:58:00"
-----------------------------------------------------------------------------
三、系统时间-->同步到-->硬件时间:hwclock -w
四、硬件时间-->同步到-->系统时间:hwclock -s
尊重别人的劳动成果 转载请务必注明出处:http://www.cnblogs.com/5201351/p/5133472.html