架设本地时间服务器

来源:互联网 发布:好莱坞电影推荐 知乎 编辑:程序博客网 时间:2024/04/29 21:24

一:本地时间服务

1、安装ntp

查看是否安装---rpm -qa |grep ntpdate

没安装先安装 -- yum install ntp

2、ntp配置

ntp.conf 配置

修改/etc/ntp.conf文件内容

server 127.127.1.0


fudge 127.127.1.0 stratum 8


restrict 192.168.1.0 mask 255.255.255.0 nomodify                         //允许 192.168.1的号段的ip使用与时间服务器

restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust      //屏蔽其它ip使用时间服务

其它不变


使NTP服务可以在系统引导的时候自动启动------- chkconfig ntpd on


将同步好的时间同步到CMOS  ----- 

vim /etc/sysconfig/ntpd 

SYNC_HWCLOCK=yes

3、启动|停止|重启

启动------ /etc/init.d/ntpd start

停止-------/etc/init.d/ntpd stop

重启-------/etc/init.d/ntpd restart


4、问题排查

查看ntp服务是否启动----pgrep ntpd

查看端口 ---- netstat -ntlup



二:需要同步服务器

crontab -e 

添加以下内容

* */1 * * * /usr/sbin/ntpdate 时间服务IP                          //此例子是1小时同步一次。


0 0