ntp服务在局域网内的搭建
来源:互联网 发布:淘宝怎么退订服务 编辑:程序博客网 时间:2024/04/30 10:11
1、简介
本文主要对ntp服务在局域网内的安装和配置做了简要的介绍。
2、服务器端安装
tar zxvf ntp-4.2.6p5.tar.gz
cd ntp-4.2.6p5
./configure --prefix=/usr/ntp --enable-all-clocks --enable-parse-clocks
make
make install
该部分是在时间同步服务中充当服务器的机器上要进行的安装,其他机器将会行这台机器上获取时间,实现同步。
3、服务器端配置
(1) 允许客户机的配置
修改ntp.conf配置文件
vi /etc/ntp.conf
①、第一种配置:允许任何IP的客户机都可以进行时间同步
将“restrict default kod nomodify notrap nopeer noquery”这行修改成:
将“restrict default kod nomodify notrap nopeer noquery”这行修改成:
restrict default nomodify
②、第二种配置:只允许10.15.62.*网段的客户机进行时间同步
在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:
在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:
restrict 10.15.62.0 mask 255.255.255.0 nomodify
(2) 同步时间设置
①通过网络同步时间
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
②使用本地时间
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
4、启动ntp服务器
(1)通过bin目录下的脚本启动
/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
(2)通过service工具启动
service ntpd status
service ntpd start
service ntpd stop
5、客户端配置
(1)安装ntpdate
tar zxvf ntpdate.tar.gz
然后把解压出的ntpdate可执行脚本拷贝到/usr/bin目录或者是其他系统自动查询的可执行程序的目录即可。
(2)配置
vim /etc/crontab
如下配置成每小时同步一次
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
1 * * * * root ntpdate 10.15.62.70 && hwclock -w
6、常见问题
(1)no server suitable for synchronization found
在ntp服务器启动之后需要一段时间才能够通过客户端进行时间的同步,所以如果这个问题是在服务器端刚启动的时候出现的是属于正常的情况,请等待一段时间在进行尝试。如果还是有问题可以查看网络或者是服务器端与客户端的配置情况。
(2)端口占用
在使用ntpdate进行同步时如果发现NTP端口被占用的提示,请使用ps命令查看系统是不是运行着ntp相关的服务,很多服务器安装上之后会自动的启动一些服务,之用将其关闭就可以了。
(3)防火墙和selinux问题
这个问题往往影响到服务器端和客户端正常连接,在发现连接问题时,请首先考虑这两个方面。
==========================================
参考:http://blog.s135.com/
http://www.blogjava.net/spray/archive/2008/07/10/213964.html
- ntp服务在局域网内的搭建
- 局域网内使用linux搭建NTP服务器
- ntp 服务的搭建
- 如何在局域网内搭建外网能访问的网站?
- 在局域网内搭建外网能访问的网站
- Wamp搭建的服务器网页在局域网内无法访问
- 无法在局域网内访问tomcat服务
- win7搭建NTP服务
- linux搭建ntp服务
- 如何搭建NTP服务
- CentOS NTP服务搭建
- 局域网内使用ntp服务器同步时间
- 搭建 ngrok 服务实现外网访问局域网内的网站
- 局域网内访问虚拟机的服务
- 局域网内的简单linux DNS搭建
- 局域网时间同步NTP服务架设
- CentOS 6搭建局域网NTP服务器
- centos ntp 内网服务内网
- 远程桌面突然不能粘贴的解决方案
- IOS和Android开发的一些个人感受
- Android TextView 加入图片
- 使用JEditorPane 显示WEB页面
- zoj 3466 The Hive II
- ntp服务在局域网内的搭建
- C#中windos API SendMessage的使用
- 堆变量和栈变量
- Log4j中的日志配置
- mybatis错误 Mapped Statements collection does not contain value for
- 不用的IO处理方式
- 编程心得
- java中<load-on-startup>
- flex 优化技巧