Servidor NTP de configuración de Linux

Servidor NTP de configuración de Linux

El servidor NTP (Network Time Protocol) se utiliza para sincronizar la hora de los servidores de la red de área local, lo que puede garantizar que la hora de todos los servidores de la red de área local sea coherente con el servidor de hora. Se aplica a los eventos que requieren un alto tiempo de tiempo real y deben estar unificados.

Uno, instale el servicio NTP

1. Verifique si NTP está instalado

[root@wgx network-scripts]# rpm -qa | grep ntp
fontpackages-filesystem-1.41-1.1.el6.noarch

2. Instale NTP

[root@oracle etc]# yum install ntp ntpdate -y
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
 
    .......

Installed:
  ntp.x86_64 0:4.2.6p5-15.el6.centos                             ntpdate.x86_64 0:4.2.6p5-15.el6.centos                            

Complete!

Dos, configure el servicio NTP

1. Configuración requerida para todos los nodos

Configure la dirección IP del nodo actual, la puerta de enlace del segmento de red donde se encuentra el clúster y la máscara de subred. Los resultados son los siguientes:

[root@oracle etc]# vim ntp.conf

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 192.168.1.202 nomodify notrap nopeer noquery    #当前节点IP地址
restrict 127.0.0.1
restrict -6 ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

restrict 192.168.1.1 mask 255.255.255.0 nomodify notrap  #集群所在网段的网关,子网掩码

2. Configuración del nodo maestro

Agregue lo siguiente en la sección del servidor:

[root@wgx etc]# vim ntp.conf

 # 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 iburst
 # server 1.centos.pool.ntp.org iburst
 # server 2.centos.pool.ntp.org iburst
 # server 3.centos.pool.ntp.org iburst
 
 server 127.127.1.0  # local clock 
                     # 当服务器无法连接到公用的时间服务器时,以局域网的时间服务器为客户端提供时间同步服务
 Fudge 127.127.1.0 stratum 10

3. Configuración de otros nodos

Agregue la siguiente declaración en la sección del servidor para apuntar el servidor al nodo principal:

[root@oracle etc]# vim ntp.conf

# 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 iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst

server 192.168.1.201
Fudge 192.168.1.201 stratum 10

4. Configure el archivo ntpd

[root@rac2 grid]# vim /etc/sysconfig/ntpd

# Drop root to id 'ntp:ntp' by default.
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"

Tres, inicie el servicio NTP

Una vez completada la configuración, inicie el servicio NTP y verifique el estado de NTP. El comando es el siguiente:

[root@wgx etc]# service ntpd start
正在启动 ntpd:                                            [确定]

[root@wgx etc]# ntpstat
synchronised to local net at stratum 6 
   time correct to within 7948 ms
   polling server every 64 s

Cuarto, configure el arranque para iniciar el servicio NTP

chkconfig ntpd on

Supongo que te gusta

Origin blog.csdn.net/weixin_44377973/article/details/105568053
Recomendado
Clasificación