Cobbler安装和配置
1.yum國內(nèi)源的安裝與更新
1.1 備份原repo文件
cd /etc/yum.repo.d/
mkdir repo_bak
mv *.repo repo_bak
1.2 在centos中配置網(wǎng)易和阿里的開源鏡像
wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
1.3 清除系統(tǒng)緩存并生成新的yum緩存
yum clean all
yum makecache
1.4 安裝epel源
yum -y install epel-release
1.5 下載安裝阿里開源鏡像提供的epel
wget http://mirrors.aliyun.com/repo/epel-7.repo
1.6 再次清除系統(tǒng)緩存并生成新的yum緩存
yum clean all
yum makecache
1.7 查看系統(tǒng)可用的yum源和所有yum源
yum repolist enable
yum repolist all
2.搭建前操作
2.1 升級系統(tǒng)到最新
yum update -y
2.2 關(guān)閉selinux
vi /etc/selinux/config
將SELINUX=enforcing改為disabled
getenforce #檢測selinux是否關(guān)閉
2.3 關(guān)閉防火墻
firewall-cmd --state #查看防火墻狀態(tài)
systemctl stop firewalld.service #臨時關(guān)閉防火墻
systemctl disable firewalld.service #禁止firewall開機(jī)啟動
2.4 支撐環(huán)境安裝
yum -y install cobbler httpd rsync tftp-server xinetd dhcp pykickstart fence-agents cobbler-web
3.配置Tftp,Http
vim /etc/xinetd.d/tftp
service tftp
{
disable = no #原為yes
socket_type = dgram
protocol = udp
wait = yes
user = root
server =/usr/sbin/in.tftpd
server_args = -B 1380 -v -s /var/lib/tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
vim /etc/httpd/conf/httpd.conf
ServerName 192.168.4.88:80
4.配置Cobbler
4.1 生成系統(tǒng)裝機(jī)默認(rèn)密碼
如在kiskstart文件內(nèi)設(shè)置密碼則系統(tǒng)安裝后root密碼為kickstart文件內(nèi)設(shè)置的密碼)
openssl passwd -1 -salt 'testabc' '123456'
$1$random-p$mzxQ/Sx848sXgvfwJCoZM0 #生成root密碼
4.2 修改settings文件
vim /etc/cobbler/settings
manage_dhcp: 1 ## 原為 0
manage_tftpd: 1
manage_rsync: 1 ## 原為 0
next_server: 192.168.4.88 ## 本機(jī) IP
server: 192.168.4.88 ## 本機(jī) IP
default_password_crypted: "$1$random-p$mzxQ/Sx848sXgvfwJCoZM0" ## 生成的 root 密碼
4.3 cobbler-web用戶及密碼修改
cobbler-web登陸默認(rèn)使用cobbler/cobbler登陸,用戶及密碼存放的位置在/etc/cobbler/users.conf和/etc/cobbler/users.digest 兩個文件內(nèi)
如想修改可以使用如下命令:
htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password:
Re-type new password:
4.4 配置DHCP
只修改這個區(qū)域的IP地址即可
vim /etc/cobbler/dhcp.template
subnet 172.16.31.0 netmask 255.255.255.0 {
option routers 172.16.31.88;
#option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 172.16.31.100 172.16.31.120;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
5.啟動相關(guān)服務(wù)
5.1 啟動服務(wù)
systemctl start httpd
systemctl start xinetd
systemctl start cobblerd
systemctl start rsyncd
5.2 將服務(wù)加入啟動項(xiàng)
systemctl enable httpd
systemctl enable xinetd
systemctl enable cobblerd
systemctl enable rsyncd
6.檢查配置
cobbler check
依照檢查配置的要求完成每一步
執(zhí)行cobbler get-loaders自動下載引導(dǎo)文件
cobbler get-loaders
注意 debmirror檢查這一步可以忽略
7.同步操作
cobbler sync
8.重啟cobbler服務(wù)
systemctl restart cobblerd
systemctl status cobblerd
9.注意事項(xiàng)
cobbler-web使用的python Django1.8.9實(shí)現(xiàn),如果通過頁面https://192.168.4.88/cobbler_web 登陸報(bào)“Internal Server Error”錯誤可以通過以下方式修復(fù)
#下載pip.py
wget https://bootstrap.pypa.io/get-pip.py
#調(diào)用本地python運(yùn)行pip.py腳本
python get-pip.py
#安裝pip
pip install Django==1.8.9
#查看pip版本號
python -c "import django; print(django.get_version())"
#重啟httpd
systemctl restart httpd
10.cobbler使用
10.1 下載安裝鏡像文件
wget http://mirrors.163.com/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso
10.2導(dǎo)入安裝源 #以下步驟均可在web頁面完成
mkdir /mnt/CentOS-7-x86_64
mount -r CentOS-7-x86_64-DVD-1810.iso /mnt/CentOS-7-x86_64/
cobbler import --path=/mnt/CentOS-7-x86_64 --name=Centos-7-x86_64
輸出信息略(Cobbler 將鏡像拷貝一份放在 /var/www/cobbler/ks_mirror/Centos-7-x86_64 目錄下)
(同時會創(chuàng)建一個名為 Centos-7-x86_64 的發(fā)布版本及 profile 文件)
[root@localhost ~]# cobbler list
distros:
CenOS-7-xx86_64-Minimal-x86_64
Centos-7-x86_64
profiles:
CenOS-7-xx86_64-Minimal-x86_64
Centos-7-x86_64
systems:
CHN-JS-1-IRON-07
repos:
images:
mgmtclasses:
packages:
files:
10.3 創(chuàng)建ks文件
vim /var/lib/cobbler/kickstarts/Centos7-base-install.cfg
#platform=x86, AMD64, or Intel EM64T
# System language
lang en_US
# System keyboard
keyboard us
# System timezone
timezone Asia/Shanghai
# Root password
rootpw --plaintext ezsvs@123
#Use text mode install
text
# Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#version=DEVEL
#Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# Network information
$SNIPPET('network_config')
# Network information
#network --bootproto=dhcp --device=eth0 --onboot=on
# Partition clearing information
#clearpart --all --initlabel
clearpart --drives=sda --all
# Disk partitioning information
#part /boot --asprimary --fstype="ext4" --ondisk=sda --size=200
#part swap --asprimary --fstype="swap" --ondisk=sda --size=4096
#part / --asprimary --fstype="xfs" --grow --ondisk=sda --size=1
part / --fstype="xfs" --ondisk=sda --size=20480
part swap --fstype="swap" --ondisk=sda --size=4096
part /boot --fstype="xfs" --ondisk=sda --size=500
part /data --fstype="xfs" --ondisk=sda --grow --asprimary --size=1
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%post
$SNIPPET('post_install_network_config')
%end
%packages
@base
@core
%end
目前已有編寫好的文件供安裝系統(tǒng)調(diào)用,注意ks文件中不能有中文,注釋也不能有中文。
注意磁盤分區(qū)字段
clearpart --all --initlabel #系統(tǒng)初裝刪除所有分區(qū)
clearpart --drives=sda --all #系統(tǒng)重裝只刪除系統(tǒng)分區(qū)sda保留數(shù)據(jù)盤
10.4 關(guān)聯(lián)ks文件
[root@localhost kickstarts]# cobbler distro list
CenOS-7-xx86_64-Minimal-x86_64
Centos-7-x86_64
這里有2個鏡像,其中Centos-7-x86_64是我剛上傳制作的
[root@localhost kickstarts]# cobbler profile report --name Centos-7-x86_64
Name : Centos-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
這個鏡像默認(rèn)使用的ks文件為/var/lib/cobbler/kickstarts/sample_end.ks
cobbler profile add --name=Cenos-7-x86_64 --distro=Centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7-base-install.cfg
再次查看關(guān)聯(lián)成功
Kickstart : /var/lib/cobbler/kickstarts/Centos7-base-install.cfg
10.5 修改內(nèi)核參數(shù)
[root@localhost ~]# cobbler profile edit --name=Centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@localhost ~]# cobbler profile report --name=Centos-7-x86_64
Name : Centos-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/Centos7-base-install.cfg
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
10.6 同步配置完成操作
cobbler sync
至此,cobbler的安裝和配置已經(jīng)完成,連接待安裝的服務(wù)器,將服務(wù)器啟動引導(dǎo)PXE啟動,即可開始安裝系統(tǒng)。
11.附錄
11.1 cobbler 常用命令列表
[root@localhost kickstarts]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
[root@localhost kickstarts]# cobbler profile --help
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list
cobbler profile remove
cobbler profile rename
cobbler profile report
cobbler distro add --name=string --kernel=path --initrd=path [--kopts=string] [--kopts-post=string] [--ksmeta=string] [--arch=x86|x86_64|ia64] [--breed=redhat|debian|suse] [--template-files=string]
cobbler profile add --name=string --distro=string [--kickstart=path] [--kopts=string] [--ksmeta=string] [--virt-file-size=gigabytes] [--virt-ram=megabytes] [--virt-type=string] [--virt-cpus=integer] [--virt-path=string] [--virt-bridge=string] [--server] [--parent=profile]
cobbler system add --name=string --profile=string [--mac=macaddress] [--ip-address=ipaddress] [--hostname=hostname] [--kopts=string] [--ksmeta=string] [--kickstart=path] [--netboot-enabled=Y/N] [--server=string] [--gateway=string] [--dns-name=string] [--static-routes=string] [--power-address=string] [--power-type=string] [--power-user=string] [--power-pass=string] [--power-id=string]
11.2 基本命令說明
| 命令名稱 | 命令用途 |
|---|---|
| cobbler check | 核對當(dāng)前設(shè)置是否有問題 |
| cobbler list | 列出所有的cobbler元素 |
| cobbler distro/profile/system/repo/image/mgmtclass/package/file list | 列出每種元素的列表 |
| cobbler report | 詳細(xì)的列出每個元素 |
| cobbler distro/profile/system/repo/image/mgmtclass/package/file report --name=[object-name] | 列出每個元素的報(bào)告 |
| cobbler sync | 同步配置 |
| cobbler reposync | 同步y(tǒng)um倉庫 |
11.3 配置文件說明
cobbler配置文件存放在/etc/cobbler/下
| 配置文件名稱 | 用途 |
|---|---|
| /etc/cobbler/settings | cobbler主配置文件 |
| /etc/cobbler/dhcp.template | dhcp的模板配置文件 |
| /etc/cobbler/tftpd.template | tftp的模板配置文件 |
| /etc/cobbler/named.template | dns的模板配置文件 |
| /etc/cobbler/users.digest | 用于web訪問的用戶名密碼配置文件 |
| /etc/cobbler/modules.conf | 模塊配置文件 |
| /etc/cobbler/users.conf | cobbler webUI/web service授權(quán)配置文件 |
repo數(shù)據(jù)目錄/var/www/cobbler
導(dǎo)入的發(fā)行版,repos鏡像和kickstarts文件都放置在/var/www/cobbler目錄下。確保/var目錄有足夠的空間來存儲這些文件
| 目錄名稱 | 用途 |
|---|---|
| images/ | 存儲所有導(dǎo)入發(fā)行版的kernel和initrd鏡像用于遠(yuǎn)程網(wǎng)路啟動 |
| ks_mirrors | 存儲導(dǎo)入的發(fā)行版 |
| repo_mirror | yum repos存儲目錄 |
| /var/log/cobbler | 存放日志文件/var/log/cobbler/cobbler.log |
cobbler數(shù)據(jù)目錄/var/lib/cobbler,此目錄存儲和cobbler profiles,systems,distros相關(guān)的配置。
| 目錄名稱 | 用途 |
|---|---|
| configs/ | 存儲distros,repos,systems和profiles相關(guān)信息 |
| backup/ | 備份目錄 |
| snippets | 放置一些可以在kickstarts導(dǎo)入的腳本小片段 |
| triggers/ | 放置一些可執(zhí)行腳本 |
| kickstarts/ | 放置kickstarts模板文件 |
總結(jié)
以上是生活随笔為你收集整理的Cobbler安装和配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: input、print、字符串格式化输出
- 下一篇: STL:set的使用