CentOS7 NTP server + keepalived
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7 NTP server + keepalived相关的知识,希望对你有一定的参考价值。
NTP安装
yum -y install ntp
systemctl enable ntpd
首先同步一次时间
ntpdate time.windows.com
ntp配置(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 #记录上次的NTP server与上层NTP server连接接所花费的时间 driftfile /var/lib/ntp/drift #设置默认策略为允许任何主机进行时间同步 restrict 0.0.0.0 mask 0.0.0.0 nomodify #设置ntp日志的path statsdir /var/log/ntp/ #设置ntp日志文件 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安装
yum -y install Keepalived
host1配置
/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权值要比BACKUP高 advert_int 1 authentication { auth_type PASS auth_pass GSksLAyTX9ylwG86U2Ez } virtual_ipaddress { 172.16.0.10 } }
Host2配置
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权值要比BACKUP高 advert_int 1 authentication { auth_type PASS auth_pass GSksLAyTX9ylwG86U2Ez } virtual_ipaddress { 172.16.0.10 } }
systemctl enable keepalived
systemctl start keepalived
1 windows客户端向NTP每10分钟同步一次时间
gpedit.msc打开组策略
1.1 启动windows NTP客户端
1.2 配置windows NTP客户端
1.3 Internet时间设置里指定时间服务器
点击立即更新
2 linux客户端向NTP每10分钟同步一次时间
2.1 安装NTP
yum -y install ntp
2.2 设置时间同步
执行下面的命令
echo -e "\n\n## sync time\n*/10 * * ** root ntpdate 172.16.0.10 && hwclock-w" >> /etc/crontab
以上是关于CentOS7 NTP server + keepalived的主要内容,如果未能解决你的问题,请参考以下文章