CentOS7 NTP Server + keepalived

Source: Internet
Author: User




NTP installation



Yum-y Install NTP



Systemctl Enable NTPD






Synchronize one time first



Ntpdate time.windows.com






NTP configuration (Host1 Host2)



/etc/ntp.conf


server time.windows.com prefer
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org


#Record the time it took for the last NTP server to connect to the upper NTP server
driftfile /var/lib/ntp/drift


#Set the default policy to allow any host to synchronize time
restrict 0.0.0.0 mask 0.0.0.0 nomodify


#Set the path of the ntp log
statsdir /var/log/ntp/


#Set ntp log file
logfile /var/log/ntp/ntp.log


mkdir/var/log/ntp/; Touch/var/log/ntp/ntp.log; Chown Ntp:ntp/var/log/ntp/ntp.log



Systemctl Start NTPD






Keepalived Installation



Yum-y Install keepalived



HOST1 Configuration



/etc/keepalived/keepalived.conf


global_defs {
         notification_email {
                 [email protected]
         }

         notification_email_from [email protected]
         smtp_server 127.0.0.1
         smtp_connect_timeout 30
         router_id LVS_DEVEL
}




vrrp_instance VI_1 {
         state MASTER ############ MASTER/BACKUP
         interface eno16777984
         virtual_router_id 51
         mcast_src_ip 172.16.0.2
         priority 150 ########### MASTER weight is higher than BACKUP
         advert_int 1

         authentication {
                 auth_type PASS
                 auth_pass GSksLAyTX9ylwG86U2Ez
         }

         virtual_ipaddress {
                 172.16.0.10
         }

}





HOST2 Configuration


global_defs {
         notification_email {
                 [email protected]
         }

         notification_email_from [email protected]
         smtp_server 127.0.0.1
         smtp_connect_timeout 30
         router_id LVS_DEVEL
}




vrrp_instance VI_1 {
         state BACKUP ############ MASTER/BACKUP
         interface eno16777984
         virtual_router_id 51
         mcast_src_ip 172.16.0.3
         priority 150 ########### MASTER weight is higher than BACKUP
         advert_int 1

         authentication {
                 auth_type PASS
                 auth_pass GSksLAyTX9ylwG86U2Ez
         }

         virtual_ipaddress {
                 172.16.0.10
         }

} 





Systemctl Enable keepalived



Systemctl Start keepalived





1 windowsClient toNtpevery10minute synchronization Time





Gpedit.msc Open Group Policy




1.1StartWindows NTPClient






1.2ConfigurationWindows NTPClient






1.3 Internetspecify time server in time settings




Click Update Now








2 LinuxClient toNtpevery10minute synchronization Time2.1installationNtp


Yum-y Install NTP





2.2set up time synchronization


Execute the following command



Echo-e "\n\n## Sync TIME\N*/10 * * * * * root ntpdate 172.16.0.10 && hwclock-w" >>/etc/crontab






CentOS7 NTP Server + keepalived


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.