Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux's NTP service server

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

We chose the third machine (mysql02) as the NTF server, and the other machines synchronized with this machine.

1. Check whether the ntp service has been installed

[root@mysql02 ~] # sudo rpm-qa | grep ntp

Ntpdate-4.2.6p5-5.el6.centos.x86_64

Fontpackages-filesystem-1.41-1.1.el6.noarch

Ntp-4.2.6p5-5.el6.centos.x86_64

[root@mysql02 ~] #

Description: shows that the ntp program has been installed, in which ntpdate-4.2.6p5-1.el6.centos.x86_64 is used to synchronize with a server

Ntp-4.2.6p5-1.el6.centos.x86_64 is used to provide time synchronization services.

2. Modify the configuration file ntp.conf

[root@mysql02 ~] # vim / etc/ntp.conf

2.1enable restrice and modify network segment

Restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

Uncomment this line and change the network segment to the cluster network segment, which we have here is 1 network segment.

2.2 comment out the server domain name configuration

# 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

Description: the above is the domain name of the time server, there is no need to connect to the Internet, so comment them out.

2.3 before server 0.centos.pool.ntp.org iburst, add the following

Server 127.127.1.0 # local clock

Fudge 127.127.1.0 stratum 10

Add:

① configuration method 1: only allow clients of 192.168.100.0 network segment to synchronize time

Add a line after restrict default kod nomodify notrap nopeer noquery (indicates that time synchronization for all IP is rejected by default)

Restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap

② configuration method 2: allow any ip client to synchronize time

Modify the restrict default kod nomodify notrap nopeer noquery to look like this line:

Restrict default nomodify

Permissions are mainly set by the parameter restrict, and the main syntax is:

Restrict IP address mask subnet mask parameter

Where IP can be IP address or default,default, which refers to all IP

The main parameters are as follows:

Ignore: turn off all NTP online services

Nomodify: the client cannot change the time parameter of the server, but the client can calibrate the time on the network through the server.

Notrust: unless the client is authenticated, the client source will be considered an untrusted subnet

Noquery: no client time query is provided

3. Modify the configuration file ntpd

[root@mysql02 ~] # sudo vim / etc/sysconfig/ntpd

Add a line of configuration: SYNC_CLOCK=yes

4. Start the ntp service

[root@mysql02 ~] # service ntpd start

Starting ntpd: [OK]

[root@mysql02 ~] # sudo chkconfig ntpd on

In this way, the ntp service starts automatically each time the machine starts.

5. Configure the synchronization of other machines

Machines that need to be synchronized

Switch to root user to configure timing synchronization through contab:

[root@bigdata-senior02 hadoop] # crontab-e

* / 10 * / usr/sbin/ntpdate 10.219.24.25

6. Test whether the synchronization is valid

6.1. Check the time of the current three machines

[root@mysql02 ~] # date "+% Y-%m-%d% H:%M:%S"

2017-08-14 05:57:13

[root@mysql01 ~] # date "+% Y-%m-%d% H:%M:%S"

2017-08-14 05:57:17

6.2. modify the time on mysql02

Change the time to a previous time

[root@mysql02] # sudo date-s' 2017-08-13 22pur01pur00'

Sun Aug 13 22:01:00 CST 2017

[root@mysql02 ~] # date "+% Y-%m-%d% H:%M:%S"

2017-08-13 22:01:08

Wait 10 minutes to see if automatic synchronization can be achieved.

6.3. Check whether the time is automatically synchronized

[root@mysql02 ~] # date "+% Y-%m-%d% H:%M:%S"

2017-08-13 23:01:45

[root@mysql01 ~] # date "+% Y-%m-%d% H:%M:%S"

2017-08-13 23:01:46

Description: mysql01 has been automatically synchronized with mysql02.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report