第十二周作业

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

[root@localhost cobbler]# yum install chrony -y
[root@localhost cobbler]# cat /etc/chrony.conf
	# Please consider joining the pool (http://www.pool.ntp.org/join.html).
	server ntp1.aliyun.com iburst
	#server 1.centos.pool.ntp.org iburst
	#server 2.centos.pool.ntp.org iburst
	#server 3.centos.pool.ntp.org iburst
	###
	# Allow NTP client access from local network.
	allow 0.0.0.0/0
	#allow 192.168.0.0/16
	
	# Serve time even if not synchronized to a time source.
	local stratum 10
[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# 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               
===============================================================================
^* 120.25.115.20                 2   6    17    21    -38us[ -274us] +/-   17ms

二、实现pxe自动化装机

pxe自动化安装centos7
环境:两台主机,一台做dhcp、httpd、tftp服务器(单网卡、NAT模式),一台测试机(单网卡、NAT模式)

1. 安装相关服务
[root@localhost ~]# yum install httpd tftp-server dhcp syslinux -y
[root@localhost ~]# systemctl start httpd tftp
[root@localhost ~]# systemctl enable httpd tftp
2. 准备yum源
[root@localhost ~]# mkdir /var/www/html/centos/{6,7}/os/x86_64 -pv
[root@localhost ~]# mount /dev/cdrom /var/www/html/centos/7/os/x86_64
[root@localhost ~]# mount /dev/sr1 /var/www/html/centos/6/os/x86_64
3. 安装和配置kickstart
[root@localhost ~]# yum install -y system-config-kickstart
[root@localhost ~]# system-config-kickstart
[root@localhost ~]# mkdir  /var/www/html/ksdir/
[root@localhost ~]# ls /var/www/html/ksdir/
[root@localhost ~]# ks6_mini.cfg  ks7_mini.cfg
4. 配置dhcp服务
[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
	option domain-name "liuhua.com";
	option domain-name-servers 114.114.114.114;
	default-lease-time 86400;
	max-lease-time 864000;
	subnet 192.168.117.0 netmask 255.255.255.0 {
    	range 192.168.117.50 192.168.117.100;
   	 	option routers 192.168.117.1;
   		next-server 192.168.117.7;
   	 	filename "pxelinux.0";

}
[root@localhost ~]# systemctl start dhcpd
5. 准备相关的文件
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
[root@localhost ~]# cp /usr/share/syslinux/menu.c32		/var/lib/tftpboot/
[root@localhost ~]# mkdir /var/lib/tftpboot/centos{6,7}
[root@localhost ~]# cp /var/www/html/centos/7/os/x86_64/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos7
[root@localhost ~]# cp /var/www/html/centos/6/os/x86_64/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos6
[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg/
[root@localhost ~]# cp /var/www/html/centos/7/os/x86_64/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@centos7 tftpboot]# tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── centos6
│   ├── initrd.img
│   └── vmlinuz
├── centos7
│   ├── initrd.img
│   └── vmlinuz
├── menu.c32
├── pxelinux.0
└── pxelinux.cfg
    └── default
3 directories, 7 files
6. 准备启动菜单
[root@centos7 tftpboot]# cat /var/lib/tftpboot/pxelinux.cfg/default 
	default menu.c32
	timeout 600
	menu title CentOS Auto Install 
	
	label mini7
	  menu label Install CentOS ^Mini 7
	  kernel centos7/vmlinuz
	  append initrd=centos7/initrd.img ks=http://192.168.37.7/ksdir/ks7_mini.cfg
	
	label desktop
	  menu label Install CentOS ^Desktop 7
	  kernel centos7/vmlinuz
	  append initrd=centos7/initrd.img  ks=http://192.168.37.7/ksdir/ks7_desktop.cfg
	
	label mini6
	  menu label Install CentOS Mi^ni 6
	  kernel centos6/vmlinuz
	  append initrd=centos6/initrd.img ks=http://192.168.37.7/ksdir/ks6_mini.cfg
	
	label local
	  menu default
	  menu label Boot from ^local drive
	  localboot 0xffff
7. 测式机网卡启动

三、实现cobbler自动化装机

1.安装并启动cobbler、dhcp、tftp服务
[root@localhost ~]# yum install cobbler dhcp
[root@localhost ~]# systemctl start cobblerd httpd tftp
2.配置cobbler相关文件
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : ksvalidator was not found, install pykickstart
8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

[root@localhost ~]# vim /etc/cobbler/settings
	default_password_crypted: "$1$RFO.hOYF$g79MJdrxFJMgpggQlhjev/" #openssl passwd -1
	###
	next_server: 192.168.117.17     #tftp服务器
	###
	manage_dhcp: 1
	###
	server: 192.168.117.17          #cobbler服务
[root@localhost ~]# systemctl restart cobblerd
3.修改dhcp
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.117.0 netmask 255.255.255.0 {
     option routers             192.168.117.2;
     option domain-name-servers 192.168.117.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.117.100 192.168.117.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
4.同步cobbler并下载相关loaders
[root@localhost ~]# cobbler sync
[root@localhost ~]# systemctl start dhcpd
[root@localhost ~]# cobbler get-loaders
[root@localhost ~]# cobbler sync
5.创建yum源

将cdrom挂载到/mnt目录下,

[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
导入到cobbler中,
[root@localhost ~]# cobbler import --path=/mnt --name=CentOS7.6-x86_64 --arch=x86_64
[root@localhost ~]# cobbler profile list
   CentOS7.6-x86_64
[root@localhost ~]# cobbler distro list
   CentOS7.6-x86_64
6.准备ks文件
[root@localhost kickstarts]# cp ks7_mini.cfg /var/lib/cobbler/kickstarts/
[root@localhost kickstarts]# vim ks7_mini.cfg
url --url=$tree
创建cobbler的profile,包括指定yum源(distro)、(kickstart)
[root@localhost kickstarts]# cobbler profile add --name CentOS7.6-x86_64_mini --distro=CentOS7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks7_mini.cfg

将之前创建yum源而自动生成的profile移除,

[root@localhost kickstarts]# cobbler profile list
   CentOS7.6-x86_64
   CentOS7.6-x86_64_mini
[root@localhost kickstarts]# cobbler profile remove --name=CentOS7.6-x86_64
7.测试安装

cobbler测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值