标签归档:Kickstart

CentOS7x64下安装Cobbler

测试中发现,无法导入32位系统镜像,使用32位的CentOS安装Cobbler也不行,目前未解决。

 

001# 安装环境
002# cat /etc/redhat-release
003CentOS Linux release 7.1.1503 (Core)
004 
005# uname -a
006Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
007 
008 
009# cat /etc/redhat-release
010CentOS Linux release 7.1.1503 (Core)
011[root@localhost ~]# uname -a
012Linux localhost.localdomain 3.10.0-229.20.1.el7.x86_64 #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
013 
014# rpm -qa cobbler
015cobbler-2.6.10-1.el7.noarch
016 
017####################################################################################
018#
019#安装过程
020#
021####################################################################################
022# 增加repo源
023rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
024# 或
025wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
026 
027# 安装Cobbler及相关软件
028yum -y install httpd xinetd tftp-server dnsmasq rsync syslinux
029yum -y install cobbler fence-agents pykickstart
030 
031# 关闭selinux
032# vi /etc/selinux/config
033SELINUX=disabled
034 
035# 获取selinux状态
036# getenforce
037 
038# 关闭iptables
039systemctl stop firewalld
040systemctl disable firewalld
041 
042# 生成系统安装后,root的密码 (默认密码为 cobbler)
043# 格式 openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
044# 其中 random-phrase-here 为干扰码
045 
046# openssl passwd -1 -salt 'allgo' 'allgo.cc'                                
047$1$allgo$sjkKoGvJXV2AuBNFeHyxP.
048 
049# 修改Cobbler配置/etc/cobbler/settings
050manage_dhcp:1
051manage_dns:1
052manage_tftpd:1
053restart_dhcp:1
054restart_dns:1
055next_server:<服务器的 IP 地址>
056server:<服务器的 IP 地址>
057default_password_crypted: "$1$allgo$sjkKoGvJXV2AuBNFeHyxP."
058 
059# 修改 modules,使用dnsmasq作为DHCP、DNS服务器
060# vi /etc/cobbler/modules.conf
061[dns]
062module = manage_dnsmasq
063 
064[dhcp]
065module = manage_dnsmasq
066 
067[tftpd]
068module = manage_in_tftpd
069 
070# 修改dnsmasq配置文件 /etc/dnsmasq.conf
071# vi /etc/dnsmasq.conf
072 
073# Cobbler generated configuration file for dnsmasq
074# $date
075#
076 
077# resolve.conf .. ?
078#no-poll
079#enable-dbus
080read-ethers
081addn-hosts = /var/lib/cobbler/cobbler_hosts
082 
083dhcp-range=192.168.211.10,192.168.211.29,255.255.255.0
084dhcp-ignore=tag:!known
085dhcp-option=3,$next_server
086dhcp-lease-max=1000
087dhcp-authoritative
088dhcp-boot=pxelinux.0
089dhcp-boot=net:normalarch,pxelinux.0
090dhcp-boot=net:ia64,$elilo
091 
092$insert_cobbler_system_definitions
093 
094# TFTP配置
095# cat /etc/xinetd.d/tftp
096# default: off
097# description: The tftp server serves files using the trivial file transfer \
098#       protocol.  The tftp protocol is often used to boot diskless \
099#       workstations, download configuration files to network-aware printers, \
100#       and to start the installation process for some operating systems.
101service tftp
102{
103        socket_type             = dgram
104        protocol                = udp
105        wait                    = yes
106        user                    = root
107        server                  = /usr/sbin/in.tftpd
108        server_args             = -s /var/lib/tftpboot
109        disable                 = no
110        per_source              = 11
111        cps                     = 100 2
112        flags                   = IPv4
113}
114 
115systemctl start xinetd.service
116systemctl status xinetd.service
117systemctl enable xinetd.service
118 
119systemctl start tftp.socket
120systemctl status tftp.socket
121systemctl enable tftp.socket
122 
123systemctl start tftp.service
124systemctl status tftp.service
125systemctl enable tftp.service
126 
127# 配置httpd
128cd /etc/httpd/conf.d/
129#移除并备份conf文件,目的不显示测试页面
130mv autoindex.conf autoindex.conf.bak
131mv userdir.conf userdir.conf.bak
132mv welcome.conf welcome.conf.bak
133 
134 
135# 启动httpd、Cobbler
136systemctl start httpd.service
137systemctl enable httpd.service
138systemctl status httpd.service
139 
140systemctl start cobblerd.service
141systemctl enable cobblerd.service
142systemctl status cobblerd.service
143 
144# Cobbler检查,会检测到一些错误,根据提示解决
145cobbler check
146 
147# Cobbler配置应用
148cobbler sync
149 
150# 查看相关应用是否启动
151ss -naltu
152 
153 
154# 准备安装文件
155# 导入iso文件
156mount -t iso9660 -o loop,ro /os/CentOS-7-x86_64-Minimal-1503-01.iso /mnt
157cobbler import --name=centos7mini --path=/mnt --arch=x86_64
158# cobbler import --arch=x86_64 --path=/mnt --name=centos7mini2
159 
160# 查看导入结果
161cobbler distro list
162cobbler distro report
163cobbler profile report
164 
165# 添加kickstart配置文件
166# 从现有sample_end 修改得到
167# cp /var/lib/cobbler/kickstarts/sample_end.ks /var/lib/cobbler/kickstarts/jxl_data.ks
168# vi /var/lib/cobbler/kickstarts/jxl_data.ks
169timezone Asia/Shanghai --isUtc
170lang en_US.UTF-8 --addsupport=zh_CN.UTF-8
171 
172# 添加账号
173# user --name=<username> [--groups=<list>] [--homedir=<homedir>] [--password=<password>] [--iscrypted] [--shell=<shell>] [--uid=<uid>]
174user --name="centos" --iscrypted="$1$juxinli$PEn5Sl/DCkrLOGeSmVrFP1" --uid=1000
175 
176 
177# Allow anaconda to partition the system as needed
178# autopart
179 
180# Partition clearing information
181clearpart --all --initlabel
182# Disk partitioning information
183part / --asprimary --fstype="xfs" --size=204800
184part /boot --asprimary --fstype="xfs" --size=1024
185part swap --asprimary --fstype="swap" --size=4096
186# kvm
187part /vm --asprimary --fstype="xfs" --grow --size=1
188# data
189part /data --asprimary --fstype="xfs" --grow --size=1
190 
191#LVM-data
192part /boot --fstype="xfs" --size=1024
193part swap --fstype="swap" --size=4096
194part pv.01 --size=1 --grow
195volgroup centos pv.01
196logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
197logvol  /data  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=data
198 
199 
200#LVM-kvm
201part /boot --fstype="xfs" --size=1024
202part swap --fstype="swap" --size=4096
203part pv.01 --size=1 --grow
204volgroup centos pv.01
205logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
206logvol  /vm  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=vm
207 
208 
209 
210 
211 
212 
213 
214# cobbler profile add --name=Fedora17-xfce --ksmeta='desktop_pkg_group=@xfce-desktop' --kickstart=/var/lib/cobbler/kickstarts/example.ks --parent=centos7mini2-x86_64
215# cobbler profile add --name=centos-data --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks --parent=centos7mini2-x86_64
216 
217# 修改kickstart文件
218cobbler profile edit --name=centos7mini-x86_64 --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks
219 
220# 验证kickstart文件内容
221cobbler profile getks --name=centos7mini-x86_64
222 
223# 配置需要安装的机器
224# 针对MAC为00:0C:29:48:30:63的机器安装
225cobbler system add --name=test --profile=centos7mini-x86_64 --interface=eno16777736 --mac=00:0C:29:48:30:63 --ip-address=192.168.211.11 --netmask=255.255.255.0 --static=1 --dns-name=test.mydomain.com --gateway=192.168.211.1 --hostname=test.mydomain.com
226 
227cobbler system report
228 
229 
230#######
231# 让配置生效
232cobbler sync
233 
234#######注意################
235# 检查 dnsmasq dhcp-range是否正确,因为cobbler sync 会修改
236grep "range" /etc/dnsmasq.conf
237dhcp-range=192.168.211.10,192.168.211.20
238 
239# 修改/etc/dnsmasq.conf 后需要重启dnsmasq
240systemctl restart dnsmasq.service
241 
242 
243 
244##############################
245# 安装Cobbler Web 界面
246 
247yum -y install cobbler-web
248# 修改授权
249# /etc/cobbler/modules.conf
250[authentication]
251module = authn_pam
252 
253[authorization]
254module = authz_ownership
255 
256# 添加Cobbler_web 账号
257# useradd web && passwd web
258 
259# 将 账号 添加到Cobbler_web admins组
260# cat /etc/cobbler/users.conf
261[admins]
262admin = ""
263cobbler = ""
264web = ""
265 
266# 重启服务
267service cobblerd restart
268service httpd restart
269 
270# 登录WEB(注意使用https)
271https://192.168.211.131/cobbler_web/
272 
273 
274# Cobbler 子命令介绍
275cobbler check         #检查cobbler配置
276cobbler sync          #步配置到dhcp pxe和数据目录
277cobbler list          #列出所有的cobbler元素
278cobbler import        #导入安装的系统光盘镜像
279cobbler report        #列出各元素的详细信息
280cobbler distro        #查看导入的发行版系统信息
281cobbler profile       #查看配置信息
282cobbler system        #查看添加的系统信息
283cobbler reposync      #同步yum仓库到本地
284 
285cobbler repo add --name=CentOS-7-x86_64 --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/
286cobbler reposync
287 
288 
289# 参考文档
290# Cobbler官网
291http://cobbler.github.io/manuals/quickstart/
292http://cobbler.github.io/manuals/2.6.0/
293# dnsmasq设置
294http://debugo.com/dnsmasq/
295# 使用 Cobbler 自动化和管理系统安装
296http://www.ibm.com/developerworks/cn/linux/l-cobbler/
297# Cobbler自动化工具同时批量部署CentOS7及CentOS6.5
298http://www.tuicool.com/articles/YZN3qi
299#kickstart配置文件详解
300http://blog.chinaunix.net/uid-17240700-id-2813881.html