Cobbler无人值守安装系统

 

环境说明

系统版本    CentOS 6.9 x86_64

Cobbler是一款Linux安装服务器,可以快速设置网络安装环境。它粘合在一起并自动执行许多相关的Linux任务,因此部署新系统时不必在许多不同的命令和应用程序之间跳转,并且在某些情况下更改现有的命令和应用程序。Cobbler可以帮助进行配置,管理DNS和DHCP,软件包更新,电源管理,配置管理编排等等,Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

cobbler官网http://cobbler.github.io/

1、安装

clbbler需要先配置epel源

yum -y install cobbler cobbler-web dhcp

需要手动安装Django

[root@cobbler ~]# yum localinstall Django14-1.4.21-1.el6.noarch.rpm

[root@cobbler ~]# rpm -ql cobbler # 查看安装的文件,下面列出部分。

/etc/cobbler # 配置文件目录

/etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobblerpython写的程序。

/etc/cobbler/dhcp.template # DHCP服务的配置模板

/etc/cobbler/tftpd.template # tftp服务的配置模板

/etc/cobbler/rsync.template # rsync服务的配置模板

/etc/cobbler/iso # iso模板配置文件目录

/etc/cobbler/pxe # pxe模板文件目录

/etc/cobbler/power # 电源的配置文件目录

/etc/cobbler/users.conf # Web服务授权配置文件

/etc/cobbler/users.digest # 用于web访问的用户名密码配置文件

/etc/cobbler/dnsmasq.template # DNS服务的配置模板

/etc/cobbler/modules.conf # Cobbler模块配置文件

/var/lib/cobbler # Cobbler数据目录

/var/lib/cobbler/config # 配置文件

/var/lib/cobbler/kickstarts # 默认存放kickstart文件

/var/lib/cobbler/loaders # 存放的各种引导程序

/var/www/cobbler # 系统安装镜像目录

/var/www/cobbler/ks_mirror # 导入的系统镜像列表

/var/www/cobbler/images # 导入的系统镜像启动文件

/var/www/cobbler/repo_mirror # yum源存储目录

/var/log/cobbler # 日志目录

/var/log/cobbler/install.log # 客户端系统安装日志

/var/log/cobbler/cobbler.log # cobbler日志

2、配置

2.1、配置cobbler

[root@cobbler ~]# /etc/init.d/httpd start    #启动httpd

正在启动 httpdhttpd: apr_sockaddr_info_get() failed for cobbler

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

[确定]

[root@cobbler ~]# cobbler check    #检查Cobbler的配置

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 : change 'disable' to 'no' in /etc/xinetd.d/rsync

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@cobbler ~]# vim /etc/cobbler/settings    #解决提示1和提示2

384 server: 192.168.1.62

272 next_server: 192.168.1.62

[root@cobbler ~]# /etc/init.d/cobblerd restart

Stopping cobbler daemon: [确定]

Starting cobbler daemon: [确定]

[root@cobbler ~]# vim /etc/xinetd.d/tftp        #解决提示3

disable = no

[root@cobbler ~]# cobbler get-loaders            #解决提示4

task started: 2018-06-05_201440_get_loaders

task started (id=Download Bootloader Content, time=Tue Jun 5 20:14:40 2018)

path /var/lib/cobbler/loaders/README already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/COPYING.elilo already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/COPYING.yaboot already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/COPYING.syslinux already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/elilo-ia64.efi already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/yaboot already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/pxelinux.0 already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/menu.c32 already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/grub-x86.efi already exists, not overwriting existing content, use --force if you wish to update

path /var/lib/cobbler/loaders/grub-x86_64.efi already exists, not overwriting existing content, use --force if you wish to update

*** TASK COMPLETE ***

[root@cobbler ~]# vim /etc/xinetd.d/rsync        #解决提示5

disable = no

[root@cobbler ~]# /etc/init.d/xinetd restart

停止 xinetd [确定]

正在启动 xinetd [确定]

[root@cobbler ~]# yum install debmirror -y        #解决提示6,管理debian服务器

[root@cobbler ~]# cobbler check    #再次检查

The following are potential configuration items that you may want to fix:

1 : comment out 'dists' on /etc/debmirror.conf for proper debian support

2 : comment out 'arches' on /etc/debmirror.conf for proper debian support

3 : ksvalidator was not found, install pykickstart

4 : 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

5 : 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@cobbler ~]# vim /etc/debmirror.conf

#@dists="sid";

@sections="main,main/debian-installer,contrib,non-free";

#@arches="i386";

[root@cobbler ~]# yum install -y pykickstart    #解决提示3

[root@cobbler ~]# openssl passwd -1 -salt 'random' '123456'

$1$random$lNO5K9IqIbuZDaMsncC6/1

[root@cobbler ~]# vim /etc/cobbler/settings    #解决提示4

# 设置新装系统的默认root密码123456。下面的命令来源于提示6random为(掩码)干扰码,可以自行设定。

101 default_password_crypted: "$1$random$lNO5K9IqIbuZDaMsncC6/1"

[root@cobbler ~]# yum install cman -y            #解决提示5

[root@cobbler ~]# /etc/init.d/cobblerd restart        #重启cobbler

Stopping cobbler daemon: [确定]

Starting cobbler daemon: [确定]

[root@cobbler ~]# cobbler check

No configuration problems found. All systems go.

2.2、配置dhcp

[root@cobbler ~]# vim /etc/cobbler/settings

242 manage_dhcp: 1    #配置cobbler接管dhcp

[root@cobbler ~]# vim /etc/cobbler/dhcp.template    #修改cobblerdhcp配置文件

subnet 192.168.1.0 netmask 255.255.255.0 {

option routers 192.168.1.62;    #网关地址

option domain-name-servers 223.5.5.5;        #dns地址

option subnet-mask 255.255.255.0;

2.3、同步cobbler配置

[root@cobbler ~]# cobbler sync

[root@cobbler ~]# netstat -lntup

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1158/sshd

tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN 21912/python

tcp 0 0 :::873 :::* LISTEN 19939/xinetd

tcp 0 0 :::80 :::* LISTEN 1492/httpd

tcp 0 0 :::22 :::* LISTEN 1158/sshd

tcp 0 0 :::443 :::* LISTEN 1492/httpd

udp 0 0 0.0.0.0:67 0.0.0.0:* 21969/dhcpd

udp 0 0 0.0.0.0:69 0.0.0.0:* 19939/xinetd

3、配置cobbler为路由器,

配置cobbler为路由器,使安装的机器能以cobbler为网关上网

[root@cobbler ~]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

[root@cobbler ~]# sysctl -p

[root@cobbler ~]# iptables -F

[root@cobbler ~]# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE

4、cobbler-web操作

浏览器访问http://10.0.0.62/cobbler_web 默认用户名cobbler密码cobbler

Centos7访问地址要使用https

4.1、导入光盘镜像

机器插入光盘,系统挂载(以当前最新的CentOS-7-x86_64-DVD-1804为例)

[root@cobbler ~]# mount /dev/cdrom /mnt

mount: block device /dev/sr0 is write-protected, mounting read-only

4.2、在web界面操作

导入镜像,执行run,后台会通过rsync进行同步,需要等待一段时间(若需要导入多个系统镜像,需要先卸载,再进行挂载导入)

编辑配置文件Profile

a、为dvd指定ks文件,可以使用系统的ks文件,也可以手动上传

另外一种方式是通过命令指定关联的ks文件

cobbler profile edit --name=CentOS7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ cobbler_centos7.ks

b、对于centOS 7需要在安装的时候添加内核参数及指定分辨率net.ifnames=0 biosdevname=0 vga=0x340

另外一种方式是通过命令指定关联的ks文件

cobbler profile edit --name=CentOS7-x86_64 --kopts='net.ifnames=0 biosdevname=0 vga=0x340'

同步配置

5、开始装系统

新建机器,与cobbler服务器同网络类型,开机进行装系统

温馨提示:CentOS 7.4以上的系统在安装的时候内存需要大于等于2G,不然会出现以下错误

6、附

6.1、命令行查看相关信息

[root@cobbler ~]# cobbler distro report --name=CentOS7-x86_64        #查看安装镜像文件信息

[root@cobbler ~]# cobbler profile report        #查看所有的profile设置

[root@cobbler ~]# cobbler profile report --name=CentOS7-x86_64        #查看指定的profile设置

6.2、修改安装时的地址

[root@cobbler ~]# vim /etc/cobbler/pxe/pxedefault.template

MENU TITLE Cobbler | http://www.ssgeek.com

[root@cobbler ~]# cobbler sync    #同步配置

修改前

修改后

6.3、定制化安装

即为指定的主机安装指定的系统,设置主机名,ip,网关,,网卡名、dns等,开机自动选择,不需要询问手动选择

另外一种方式是通过命令来指定镜像,设置相关信息

[root@cobbler ~]# cobbler system add --name=test --mac=00:0C:29:9C:9D:23 --profile=CentOS7-x86_64 --ip-address=192.168.1.110 --subnet=255.255.255.0 --gateway=192.168.1.62 --interface=eth0 --static=1 --hostname=test --name-servers="223.5.5.5"        #--name 自定义,但不能重复

[root@cobbler ~]# cobbler sync    #同步配置

[root@cobbler ~]# cobbler system list        #查看定义的列表

Test

开机后自动安装,跳过了选择页面

6.4、设置cobbler的web界面密码

/etc/cobbler/users.conf # Web服务授权配置文件

/etc/cobbler/users.digest # 用于web访问的用户名密码配置文件

#Cobbler组添加cobbler用户,提示输入2遍密码确认

[root@cobbler ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler

Changing password for user cobbler in realm Cobbler

New password: 123456

Re-type new password: 123456

[root@cobbler ~]# cobbler sync    #同步配置

6.5、利用Cobbler自建repo源

添加zabbix的repo源(wget方式貌似只能通过zabbix官方的源)

rsync方式rsync://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/

添加完成后点击Reposync开始同步

做好了repo源,在安装系统的时候可以选择repo源,这样安装好的系统也配置了从该repo源下载,有了cobbler服务器的repo库

6.6、使用cobbler需要启动的服务

可以手动启动也可添加为开机启动项

/etc/init.d/httpd start

/etc/init.d/xinetd start

/etc/init.d/dhcpd start

/etc/init.d/cobblerd restart

部分参考来源:http://www.zyops.com/autoinstall-cobbler/

转载请注明出处

猜你喜欢

转载自www.cnblogs.com/ssgeek/p/9223496.html
今日推荐