十二周

1、配置chrony服务,实现服务器时间自动同步

服务端配置

1 使用的机器是centos7自带chrony
2 修改配置文件
vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst     #设定时间同步服务器地址
server 1.centos.pool.ntp.org iburst     #iburst 选项可加快初始同步速度
server 1.1.1.1 iburst
server 2.2.2.2 iburst

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift   #driftfile 根据实际时间计算出计算机增减时间的比率,将它记录到一个文件中,
                                            #会在重启后为系统时钟作出补偿

# 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          #启用内核模式,系统时间每11分钟会拷贝到实时时钟(RTC)

# 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 192.168.0.0/16 #指定一台主机、子网,或者网络以允许访问本服务器
deny  10.0.0.0/24    #指定一台主机、子网,或者网络以拒绝访问本服务器
# Serve time even if not synchronized to a time source.
local stratum 10  #即使server指令中时间服务器不可用,也允许将本地时间
                  #作为标准时间授时给其它客户端

# 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

3 启动 加入开机自启
systemctl start chronyd
systemctl enable chronyd

客户端配置

vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 10.0.0.173 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 192.168.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
启动 加入开机自启
systemctl start chronyd
systemctl enable chronyd

chronyc命令

chronyc命令
 help命令可以查看更多chronyc的交互命令
 accheck 检查是否对特定主机可访问当前服务器
 activity 显示有多少NTP源在线/离线
 sources [-v] 显示当前时间源的同步信息
 sourcestats [-v]显示当前时间源的同步统计信息
 add server 手动添加一台新的NTP服务器
 clients 报告已访问本服务器的客户端列表
 delete 手动移除NTP服务器或对等服务器
 settime 手动设置守护进程时间
 sracking 显示系统时间信息

2、实现cobbler+pxe自动化装机

你可能感兴趣的:(十二周)