1、配置chrony服务,实现服务器时间自动同步
centos7默认安装有 ,可通过rpm -ql chrony 查询 监听端口: 323/udp,123/udp
[root@centos7 ~]#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
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp.aliyun.com iburst #选择的是阿里的网络同步网址
server ntp1.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 172.16.0.0/16
allow 192.168.0.0/16 #多网段配置
# Serve time even if not synchronized to a time source.
#开启,即使server指令中时间服务器不可用,也允许将本地时间作为标准时间授予其他客户端
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
[root@centos7 ~]#systemctl start chronyd 开启服务
[root@centos7 ~]#systemctl enable chronyd 设置开机自启
[root@centos7 ~]#systemctl restart chronyd.service 配置好后重启服务
centos6:
[root@centos6 ~]yum install -y chrony 下载安装 chronyd
[root@centos6 ~]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.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst 注释掉默认的
#server 3.rhel.pool.ntp.org iburst
server 172.16.100.43 iburst 客户端只添加这行即可
[root@centos6 ~]service chronyd start 开启服务
[root@centos6 ~]/etc/init.d/chronyd restart 重启服务
[root@centos6 ~] chronyc sources -v 查看同步状态
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.16.100.43 3 6 377 40 +195us[ +958us] +/- 17ms 带* 同步成功
centos7
[root@centos7 ~]vim /etc/chrony.conf 更改配置
#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst 注释掉默认的
#server 3.rhel.pool.ntp.org iburst
[root@centos7 ~]server 172.16.100.43 iburst 客户端只添加这行即可
[root@centos7 ~]systemctl status chronyd 查看服务状态
[root@centos7 ~]systemctl start chronyd 启动
[root@centos7 ~]systemctl restart chronyd 重启
[root@cen7 ~]#chronyc sources -v
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.16.100.43 3 6 377 5 -389us[ -678us] +/- 19ms
2、实现cobbler+pxe自动化装机
安装system-config-kickstart 在桌面环境下生成ks配置文件
yun install system-config-kickstart
安装dhcp服务
dhcp协议
动态主机配置协议是一个局域网的网络协议控制一段IP地址范围,客户机登录服务器时就可以自动获得服务器分配的IP地址和子网掩码。与dhcp功能相同是dnsmasq
[root@cen7 dhcp]#yum -y -install dhcp安装
[root@cen7 dhcp]#cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example ./dhcpd.conf -f
[root@cen7 ~]#vim /etc/dhcp/dhcpd.conf 更改配置文件
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "hello"; 域名
option domain-name-servers 172.16.100.10; DNS
default-lease-time 3600; 默认租约期限
max-lease-time 7200; 最大租约期限
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 192.168.50.0 netmask 255.255.255.0 { 起始IP
range 192.168.50.8 192.168.50.50; 分配的IP网段
option routers 192.168.50.1; 默认网关
}
其他的可注释掉 或不用改动
分配的IP 主机
[root@cen7 dhcp]#cd /var/lib/dhcpd/
[root@cen7 dhcpd]#cat dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.2.5
server-duid "\000\001\000\001&\236\314e\000\014)\001\260\372";
lease 192.168.50.8 {
starts 1 2020/07/13 08:36:16;
ends 1 2020/07/13 09:36:16;
cltt 1 2020/07/13 08:36:16;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:a7:69:08;
}
lease 192.168.50.9 {
starts 1 2020/07/13 08:44:13;
ends 1 2020/07/13 09:44:13;
cltt 1 2020/07/13 08:44:13;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:e9:bc:48;
}
lease 192.168.50.9 {
starts 1 2020/07/13 09:02:10;
ends 1 2020/07/13 10:02:10;
cltt 1 2020/07/13 09:02:10;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:e9:bc:48;
}
lease 192.168.50.9 {
starts 1 2020/07/13 09:04:56;
ends 1 2020/07/13 10:04:56;
cltt 1 2020/07/13 09:04:56;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:e9:bc:48;
}
客户端
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.50.9 netmask 255.255.255.0 broadcast 192.168.50.255
inet6 fe80::c05a:9322:2171:1ab1 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:e9:bc:48 txqueuelen 1000 (Ethernet)
RX packets 76 bytes 6030 (5.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 257 bytes 18869 (18.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tftp服务
安装tftp 用于下载引导文件
yum -y install tftp-server tftp
安装http服务 布置安装镜像
yum -y install httpd
[root@localhost ~]# yum install cobbler dhcp 安装cobbler服务
[root@localhost ~]# systemctl enable cobblerd 设置开机自取
[root@localhost ~]# systemctl start httpd 开启http服务
[root@localhost ~]# systemctl start tftp 开启tftp服务
vim /etc/cobbler/settings 更改配置文件
manage_dhcp: 1
next_server:192.168.50.143
server:192.168.50.143
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]#cobbler get-loaders
[root@localhost ~]# vim /etc/cobbler/dhcp.template 更改dhcp配置
subnet 192.168.50.0 netmask 255.255.255.0 { 初始IP
option routers 192.168.50.1; 网关
option domain-name-servers 172.16.100.10 域dns
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.50.100 192.168.50.254;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.50.143;
[root@localhost tftpboot]# cobbler sync 同步dhcp配置
[root@localhost dhcp]# systemctl start dhcpd 开启dhcp服务
[root@localhost ~]#mount /dev/sr0 /mnt
[root@localhost tftpboot]# cobbler import --path=/mnt --name=Centos7.6-x86_64 将光盘导入yum源
开始安装 选择网路安装 默认安装是最小安装,
添加自己的ks配置文件
更改生成ks 的http yum源网址
url --url=$tree
cp ks7.cfg /var/lib/cobbler/kickstarts/ 将配置文件复制到cobbler
cobbler profile add --name Centos7 --kickstart=/var/lib/cobbler/kickstarts/ks7.cfg
cobbler profile list
查看yum 源
开始安装

image.png