文档撰写: hanxin
时间:2018-6-12
版本:20180612-1
1 简介
cobbler 能够一次性一体化的支持不同的发行版和系统,还能自行管理额外服务,dhcp,tftp,rsync,dns。
支持bulid iso 对于不支持pxe的节点,可输入命令制作成镜像。
2 安装
环境 centos 6.9
IP 192.168.199.10
2.1 安装源和对应服务
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo //cobbler安装必须使用到epel源
yum install cobbler cobbler-web pykickstart httpd dhcp tftp-server -y
cat /etc/redhat-release // 系统版本
CentOS release 6.5 (Final)
getenforce //检测selinux是否关闭(必须关闭)
/etc/init.d/iptables status #检测防火墙是否关闭(必须关闭)
/etc/init.d/httpd restart #启动apache服务
Starting httpd: httpd: 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
#遇见报错需要修改apache的配置文件,添加一行
[root@cobbler cobbler]# vim /etc/httpd/conf/httpd.conf
ServerName localhost:80
#再重启服务发现没有报错了
/etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
/etc/init.d/cobblerd restart #启动cobbler服务
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon:
2.2 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 : file /etc/xinetd.d/rsync does not exist 7 : debmirror package is not installed, it will be required to manage debian deployments and repositories 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
更改cobbler配置文件
sed -i 's/server: 127.0.0.1/server: 192.168.199.10/' /etc/cobbler/settings sed -i 's/next_server: 127.0.0.1/next_server: 192.168.199.10/' /etc/cobbler/settings openssl passwd -1 -salt 'random-phrase-here' '1234567890' //复制生成的密码 default_password_crypted: "填入上述命令生成的" //在/etc/cobbler/settings里改 manage_dhcp:1 manage_tftpd:1 pxe_just_once:1 cobbler check //检查问题,看是否报错 出现问题时 [root@centos7 ~]# getenforce Enforcing [root@centos7 ~]# setenforce 0 [root@centos7 ~]# getenforce Permissive [root@centos7 ~]# systemctl restart httpd.service #重启http服务 [root@centos7 ~]# cobbler check The following are potential configuration items that you may want to fix rpm -qa |grep rsync #检查系统是否安装了rsync软件包 rsync-2.6.9 如果没有,就去yum 或者apt-get install或者去官网服务器上下一个 vi /etc/xinetd.d/rsync 将disable=yes改为no service rsync { disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID } service rsync restart //重启rsync服务 cobbler get-loaders //下载缺失的文件如果能访问互联网就行,不行的话复制syslinux里的syslinux.0 和 vesamenu.c32 都是复制到 /var/lib/cobbler/loaders 注释 vim /etc/debmirror.conf 28 #@dists="sid"; 30 #@arches="i386"; 注释掉这两行,重新check后没有报错了 配置dhcp vim /etc/cobbler/ks75.cfg //这里对应安装什么配置就在default对应哪个cfg subnet 192.168.199.0 netmask 255.255.255.0 { option routers 192.168.199.10; option domain-name-servers 192.168.199.10; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.199.11 192.168.199.100; } 可用此方法定制系统# cobbler system add \ --name=linux75 \ --mac=00:0C:29:3B:03:9B \ --profile=Centos-7.5-x86_64 \ --ip-address=192.168.199.1 \ --subnet=255.255.255.0 \ --gateway=192.168.199.9 \ --interface=eth0 \ --static=1 \ --hostname=huawei1 \ --name-servers="192.168.199.10" \ --kickstart=/var/lib/cobbler/kickstart/ks75.cfg system add # 添加定制系统 name # 定制系统名称 mac # mac地址 profile #指定profile ip-address # 指定IP地址 subnet # 指定子网掩码 gateway # 指定网关 interface # 指定网卡,eth0上面配置已经修改,centos7默认网卡名称不是eth0 static # 1表示启用静态IP hostname # 定义hostname name-server # dns服务器 kickstart # 指定ks文件 配置成功后我们可以查看到刚才定制的系统 service cobblerd restart cobbler check //check之后只有两个问题,可忽略 service httpd restart //重启服务 cobbler sync //数据同步到对应目录下
2.3 挂载镜像
mkdir /var/www/html/centos75/ mount /dev/cdrom /var/www/html/centos75/ cobbler import --path=/var/www/html/centos/ --name=CentOS-7.5-x86_64 --path:指定要导入的镜像文件的挂载目录 --name:指定导入后distro的标识名。 cobbler distro list 查看挂载目录
2.4导入或重做kick start文件
cp or vi ks.cfg /var/www/cobbler/kickstarts/ 添加一个新的profile并同步 cobbler profile add --name="CentOS75" --distro="CentOS7" --kickstart="/var/lib/cobbler/kickstarts/ks75.cfg" //对应上边配置的ks文件 cobbler sync /var/lib/tftpboot/pxelinux.cfg/default //修改配置文件ontimeout 跟默认安装的系统,使定时后其自动化安装
2.5重启服务
service httpd restart service dhcpd restart service rsync restart service cobblerd restart