背景知识
- 需要对PXE有深入了解
- 需要对红帽的kikstart流程有深入了解
实验部署机物理配置
项目 |
参数 |
操作系统 |
Centos-7-x86_64-DVD-1511.iso |
CPU |
4核 |
RAM |
16G |
硬盘 |
100G |
推送所使用的镜像 |
Centos-7-x86_64-DVD-1511.iso |
基于CLI版的cobbler部署及简单实用
setenforce 0
sed -i "s/^SELINUX\=.*$/SELINUX\=disabled/g" /etc/selinux/config
http://cobbler.github.io/manuals/2.8.0/4/2_-_SELinux.html
# yum install python-netaddr python-simplejson PyYAML python-cheetah httpd mod_wsgi
# yum install git make python-devel pyflakes python-pep8 python-sphinx rpm-build
yum install cobbler
# git clone https://github.com/cobbler/cobbler.git
# cd cobbler
# make install
修改cobbler的/etc/cobbler/settings配置
* 使用openssl生成密码并回归到配置文件
$ openssl passwd -1
default_password_crypted: "$1$bfI7WLZz$PxXetL97LkScqJFxnW7KS1"
- HTTP 和TFTP服务需要使用的server地址配置 ,不能是0.0.0.0,进程不会监听
# default, localhost
server: 127.0.0.1
- DHCP/PXE服务需要使用的next_server地址配置,必须与server相同
# default, localhost
next_server: 127.0.0.1
- DHCP 服务管理的相关配置,默认是0如何没有cobbler意外的dhcp服务器我们要配置成1
# default, don't manage
manage_dhcp: 0
- 自动安装时需要选择local还是我们的system
- 如果上文开启了dhcp管理功能则需要配置以下文档
$ vi /etc/cobbler/dhcp.template
- 修改内容如下,$next_server和其余文字一律不要改动
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.210,192.168.1.211;
option subnet-mask 255.255.255.0;
filename "/pxelinux.0";
default-lease-time 2.8.0;
max-lease-time 43200;
next-server $next_server;
}
cobbler所需要的本地存储
- cobbler会占用/var目录下的很多空间,如果要更改默认存储路径地址查看以下文档
http://cobbler.github.io/manuals/2.8.0/2/5_-_Relocating_Your_Installation.html
启动cobbler
$ systemctl start cobblerd.service
$ systemctl enable cobblerd.service
$ systemctl status cobblerd.service
- 使用cobbler自检功能查看环境及cobbler配置是否正确
$ cobbler check
The following are potential configuration items that you may want to fix:
1. ...
2. ...
Restart cobblerd and then run 'cobbler sync' to apply changes.
cobbler sync
- 导入ISO镜像,要使用镜像的DVD版, --arch参数不是必要的
$ mount -t iso9660 -o loop,ro /path/to/isos/Fedora-Server-dvd-x86_64-28-1.1.iso /mnt
$ cobbler import --name=fedora28 --arch=x86_64 --path=/mnt
$ cobbler distro list
$ cobbler profile list
$ cobbler distro report --name=fedora28-x86_64
Name : fedora28-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/fedora28-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/fedora28-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/fedora28-x86_64'}
Management Classes : []
OS Version : fedora28
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
- 创建cobbler system,用于后续客户机dhcp下载,system的创建时基于上述import镜像成功为基础的。
$ cobbler system add --name=test --profile=fedora28-x86_64
$ cobbler system list
test
$ cobbler system report --name=test
Name : test
TFTP Boot Files : {}
Comment :
Enable gPXE? : 0
Fetchable Files : {}
Gateway :
Hostname :
Image :
IPv6 Autoconfiguration : False
IPv6 Default Device :
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : <<inherit>>
Kickstart Metadata : {}
LDAP Enabled : False
LDAP Management Type : authconfig
Management Classes : []
Management Parameters : <<inherit>>
Monit Enabled : False
Name Servers : []
Name Servers Search Path : []
Netboot Enabled : True
Owners : ['admin']
Power Management Address :
Power Management ID :
Power Management Password :
Power Management Type : ipmitool
Power Management Username :
Profile : fedora28-x86_64
Proxy : <<inherit>>
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos Enabled : False
Server Override : <<inherit>>
Status : production
Template Files : {}
Virt Auto Boot : <<inherit>>
Virt CPUs : <<inherit>>
Virt Disk Driver Type : <<inherit>>
Virt File Size(GB) : <<inherit>>
Virt Path : <<inherit>>
Virt RAM (MB) : <<inherit>>
Virt Type : <<inherit>>
- 一些配置不同网段以及其它参数的例子,要针对自己环境的情况来配置
$ cobbler system edit --name=test --interface=eth0 --mac=00:11:22:AA:BB:CC --ip-address=192.168.1.100 --netmask=255.255.255.0 --static=1 --dns-name=test.mydomain.com
$ cobbler system edit --name=test --gateway=192.168.1.1 --hostname=test.mydomain.com
kickstart编写
- 查看system所使用的kickstart文件所在位置
$ cobbler profile report --name=cntos7-x86_64
/var/lib/cobbler/kickstarts/sample_end.ks
- 需要kickstart的详细了解
- 如修改磁盘分配,需要修改文件autopart部分
part biosboot --fstype=biosboot --size=1
part /boot --size=500
part swap --size=16384
part / --size=20480(需要方法将剩余磁盘全数分给根盘)
- 增加初始化的安装包功能,修改%package到%end部分增加需要的软件
%packages
tree
net-tools
%end
- 双网卡绑定功能,需要精确的知道网卡mac地址,绑定关系还有和ip地址的对应关系列表
$ cobbler system edit --name=foo --interface=eth0 --mac=AA:BB:CC:DD:EE:F0 --interface-type=bond_slave --interface-master=bond0
$ cobbler system edit --name=foo --interface=eth1 --mac=AA:BB:CC:DD:EE:F1 --interface-type=bond_slave --interface-master=bond0
$ cobbler system edit --name=foo --interface=bond0 --interface-type=bond --bonding-opts="miimon=100 mode=1" --ip-address=192.168.1.100 --netmask=255.255.255.0
http://cobbler.github.io/manuals/2.8.0/4/1/1_-_Bonding.html
- 以下为cobbler官方关于kickstart文件的相关说明
http://cobbler.github.io/manuals/2.8.0/3/5_-_Kickstart_Templating.html
网友评论