Linux学习作业---第十三周(7.6-7.12)

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

yum -y install chrony                     #安装服务
systemctl enable chronyd             #开机启动
systemctl start chronyd                 #启动服务

2、服务端配置
vim /etc/chrony.conf 清空默认配置,添加如下配置内容

server s1a.time.edu.cn iburst             #添加外部时间源
server s1a.time.edu.cn iburst
server ntp.aliyun.com iburst
local stratum 10                                  #网络时间同步失败,将本地时间同步给client

allow 192.168.1.0/24                          #允许客户端连接的网段  

3、客户端配置
vim /etc/chrony.conf 清空默认配置,添加如下配置内容

server 192.168.1.1 iburst                   #添加chrony服务器IP

4、查看同步情况
chronyc sources –v
二、实现cobbler+pxe自动化装机
1、安装初始环境并启动服务

yum install httpd dhcp tftp-server xinetd -y
service dhcpd start
service httpd start
vim /etc/xinetd.d/tftp
disable                            = no
service xinetd start

2、关闭selinux及防火墙

systemctl disabled firewalld && systemctl stop firewalld
setenforce 0

3、安装cobbler

yum install cobbler -y

4、检查cobbler配置

cobbler check

5、编辑cobbler配置文件

next_server: 172.16.23.242
manage_dhcp: 1                   
server: 172.16.23.242         。
default_password_crypted: "$1$og3rjhWd$iBVqBzuesn5S25lwzdB6C/"   #初始密码123456
systemctl restart cobblerd 

6、编辑dhcp模板

vi /etc/cobbler/dhcp.template
subnet 172.16.23.0 netmask 255.255.255.0 {
     option routers             172.16.23.242;
     option domain-name-servers 172.16.23.242;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        172.16.23.230 172.16.23.245;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
}

7、下载loader文件并同步配置

cobbler get-loaders
cobbler sync

8、镜像准备

mkdir -p /mnt/cdrom
 mount /dev/cdrom /mnt/cdrom/
cobbler import --path=/mnt/cdrom  --name=centos7 --arch=x86_64

9、为镜像创建自动应答文件

cp /root/anaconda-ks.cfg /var/lib/cobbler/kickstarts/centos7-ks.cfg
vi /var/lib/cobbler/kickstarts/centos7-ks.cfg
install
url --url=$tree
cobbler profile edit --name=centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-ks.cfg
cobbler sync

10、客户端配置
客户端与cobbler在同一个网段
开机进入bios,选择从网卡启动

你可能感兴趣的:(Linux学习作业---第十三周(7.6-7.12))