CentOS配置NTP Server

2013-04-01

The NTP server (ntpd) can be setup to run continuously. This will keep the system clock synchronized. You will also be able to server NTP clients on

centos7已经用chrony替换
yum -y install chrony
systemctl start chronyd
主配置文件:/etc/chrony.conf
客户端程序:/usr/bin/chronyc
服务端程序:/usr/sbin/chronyd

your LAN, if you wish. I had problems with the Red Hat configuration GUI not setting the NTP server up correctly.

1、yum -y install ntp
2、The configuration file is /etc/ntp.conf, and there is also an /etc/ntp directory which contains keys and the drift file. I will show you a working

configuration file, with comments:

--------------------------------------------------------------------------------

restrict default nomodify notrap noquery

restrict 210.72.145.44
restrict 127.0.0.1

server 210.72.145.44 prefer
server cn.pool.ntp.org
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org

restrict 172.10.1.0 mask 255.255.255.0 nomodify notrap
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust

fudge 127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift
broadcastdelay 0.008

keys /etc/ntp/keys

--------------------------------------------------------------------------------

3、After you install this new version of the config file, you can start the service with /etc/init.d/ntpd startTo monitor the service, you can run the

following command: ntpdc -p or ntpdc -p -n
If you are really impatient, you can use this command to watch the system until it synchronizes: watch nptdc -p -n
The ntpdc command can be run interactively as well. There are a number of informative ntpdc commands, such as iostats, sysstats, and peers.
When enough time has gone by, one of the servers will have an * placed in front of it to tell you that your system is synchronized to it. The lower the stratum number, the more accurate the server.

4、If you want to have the NTP server start up automatically, you can use the checkconfig command as follows:
# chkconfig --level 345 ntpd on
# chkconfig --level 0126 ntpd off
# chkconfig --list | grep ntpd
ntpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

5、To see that your NTP server is listening on UDP port 123, use the following command:

netstat -nulp

Please note that the NTP server makes NTP queries from a UDP source port of 123. Some firewalls will not allow this, even if ntpdate worked (ntpdate

uses a source port > 1023.)
You can also use the ntpq utility, and the ntptrace utility for additional diagnostic support. For complete documentation on setting up and using NTP

servers, see http://www.ntp.org/.

6、other server you can config crontab
# crontab -e
0 0 * * * /usr/sbin/ntpdate 172.16.1.123;/sbin/hwclock -w;

分类:Linux操作系统 | 标签: |

相关日志

评论被关闭!