批量安装时间同步服务器

 

环境介绍

server192.168.6.241
chlient1192.168.3.75
chlient2192.168.3.22

所有主机

yum -y install chrony

server主机

配置文件 /etc/chrony.conf

#修改local stratum 12 修改stratum系统的时钟源级别从较低的级别提升到较高的级别

#需改allow 192.168.0.0/16 允许192.168.0.0/16网段同步时间



sed -i 's/#local stratum 10/local stratum 12/' /etc/chrony.conf

sed -i 's/#allow 192.168.0.0\/16/allow 192.168.0.0\/16/' /etc/chrony.conf

systemctl restart chronyd

systemctl enable chronyd

chlient主机

 

配置文件 /etc/chrony.conf

#需要修改

server 192.168.6.241 iburst #为server端地址

systemctl restart chronyd

systemctl enable chronyd

ansible批量安装

server端配置文件 /etc/chrony.conf

#修改local stratum 12 修改stratum系统的时钟源级别从较低的级别提升到较高的级别

#修改allow 192.168.0.0/16 允许192.168.0.0/16网段同步时间

# Use public servers from the pool.ntp.org project.

# Please consider joining the pool (http://www.pool.ntp.org/join.html).

server ntp.aliyun.com iburst

# Record the rate at which the system clock gains/losses time.

driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates

# if its offset is larger than 1 second.

makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).

rtcsync

# Enable hardware timestamping on all interfaces that support it.

#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust

# the system clock.

#minsources 2

# Allow NTP client access from local network.

allow 0.0.0.0/16

# Serve time even if not synchronized to a time source.

local stratum 12

# Specify file containing keys for NTP authentication.

#keyfile /etc/chrony.keys

# Specify directory for log files.

logdir /var/log/chrony

# Select which information is logged.

#log measurements statistics tracking

#chlient配置文件

/需要修改的位置,server 192.168.3.147 iburst

# Use public servers from the pool.ntp.org project.

# Please consider joining the pool (http://www.pool.ntp.org/join.html).

server 192.168.3.147 iburst

# Record the rate at which the system clock gains/losses time.

driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates

# if its offset is larger than 1 second.

makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).

rtcsync

# Enable hardware timestamping on all interfaces that support it.

#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust

# the system clock.

#minsources 2

# Allow NTP client access from local network.

allow 0.0.0.0/16

# Serve time even if not synchronized to a time source.

#local stratum 10

# Specify file containing keys for NTP authentication.

#keyfile /etc/chrony.keys

# Specify directory for log files.

logdir /var/log/chrony

# Select which information is logged.

#log measurements statistics tracking

ansible批量安装

#分发

ansible cus -b -m copy -a "src=/root/chrony/chrony-3.4-1.el7.x86_64.rpm dest=/root"

#安装

ansible cus -m shell -a "rpm -ihv /root/chrony-3.4-1.el7.x86_64.rpm"

#配置文件/root/chrony.conf/ 为客户端配置文件

ansible cus -b -m copy -a "src=/root/chrony.conf dest=/etc/chrony.conf"

#启动

ansible cus -m shell -a "systemctl restart chronyd && systemctl enable chronyd"

#删除包

ansible cus -m shell -a "rm -fr /root/chrony-3.4-1.el7.x86_64.rpm"

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值