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 { xx@xx.com } notification_email_from keepalived@xx.com 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 { xx@xx.com } notification_email_from keepalived@xx.com 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
gpedit.msc打开组策略
点击立即更新
yum -y install ntp
执行下面的命令
echo -e "\n\n## sync time\n*/10 * * ** root ntpdate 172.16.0.10 && hwclock-w" >> /etc/crontab
CentOS7 NTP server + keepalived
原文:http://tianshili.blog.51cto.com/5050423/1879046