Cobbler無人值守安裝

COBBLER無人值守安裝
Cobbler是獨立的,不需要先安裝Kickstart然後再安裝Cobbler,這是寫給不瞭解Kickstart的人看的。

建議大家在平常不用安裝系統的時候一定要關閉cobbler主機

1.1 Cobbler介紹
Cobbler是一個Linux服務器安裝的服務,可以通過網絡啓動(PXE)的方式來快速安裝、重裝物理服務器和虛擬機,同時還可以管理DHCP,DNS等。

Cobbler可以使用命令行方式管理,也提供了基於Web的界面管理工具(cobbler-web),還提供了API接口,可以方便二次開發使用。

Cobbler是較早前的kickstart的升級版,優點是比較容易配置,還自帶web界面比較易於管理。

Cobbler內置了一個輕量級配置管理系統,但它也支持和其它配置管理系統集成,如Puppet,暫時不支持SaltStack。

 

1.2 Cobbler集成的服務
PXE服務支持
DHCP服務管理
DNS服務管理(可選bind,dnsmasq)
電源管理
Kickstart服務支持
YUM倉庫管理
TFTP(PXE啓動時需要)
Apache(提供kickstart的安裝源,並提供定製化的kickstart配置)

 

1.3 系統環境準備

1、 使用VM創建一臺虛擬機 當做cobbler服務器使用  內網IP爲172.16.1.101

操作系統:

CentOS release 6.8 (Final)

默認分區並最小化安裝 軟件選包

@base
@compat-libraries
@debugging
@development
[root@cobbler ~]# cat /etc/redhat-release 

CentOS release 6.8 (Final)

[root@cobbler ~]# uname -r 

2.6.32-642.el6.x86_64

[root@cobbler ~]# getenforce

Disabled

[root@cobbler ~]# /etc/init.d/iptables status

iptables: Firewall is not running.
### 更改yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup &&\

wget -O /etc/yum.repos.d/CentOS-Base.repo 
http://mirrors.aliyun.com/repo/Centos-6.repo
 

wget -O /etc/yum.repos.d/epel.repo

 

###注意

虛擬機網卡採用NAT模式,不要使用橋接模式,因爲稍後我們會搭建DHCP服務器,在同一局域網多個DHCP服務會有衝突。

VMware的NAT模式的dhcp服務也關閉,避免干擾。

 

1.4 安裝cobbler

[root@CentOS6 yum.repos.d]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd

wKioL1jaENDQPwdOAAGUKfdKk6A505.jpg-wh_50

 

1.5 檢查安裝
[root@CentOS6 yum.repos.d]# cobbler check
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

Restart cobblerd and then run 'cobbler sync' to apply changes.

 

1.6解決報錯問題

[root@CentOS6 yum.repos.d]#  cp /etc/cobbler/settings{,.ori}
sed -i 's/server: 127.0.0.1/server: 172.16.1.101/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.101/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'oldboy' '123456'`\"#" /etc/cobbler/settings
sed -i 's#yes#no#' /etc/xinetd.d/rsync
sed -i 's#yes#no#' /etc/xinetd.d/tftp

上傳解壓cobbler_load.tar.gz
[root@CentOS6 opt]#  tar xfP cobbler_load.tar.gz
啓動xinetd
[root@CentOS6 opt]# /etc/init.d/xinetd start
修改dhcp.template
### 替換
vim /etc/cobbler/dhcp.template 
:%s/192.168.1/172.16.1/g 
 
### 刪除
刪除22和 23行
 
[root@CentOS6 opt]#  /etc/init.d/cobblerd restart
[root@CentOS6 opt]# cobbler sync
 
/etc/init.d/xinetd restart
 
/etc/init.d/cobblerd restart
 
/etc/init.d/httpd restart
 
[root@CentOS6 opt]# cobbler check
The following are potential configuration items that you may want to fix:
1 : file /etc/xinetd.d/rsync does not exist
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : 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.
有問題的話 看看這個文件有沒有內容 不行的話重啓下服務
 vim /etc/dhcp/dhcpd.conf
/etc/init.d/cobblerd restart
頁面訪問:賬號密碼默認均爲cobbler

 

配置篇:

上傳鏡像

[root@cobbler ~]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@cobbler ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        19G  1.5G   16G   9% /
tmpfs           491M     0  491M   0% /dev/shm
/dev/sda1       190M   34M  147M  19% /boot
/dev/sr0        3.7G  3.7G     0 100% /mn

 

wKiom1jaFhTi9EvVAACQOxzf3_s033.png-wh_50

如果不寫路徑 會把根/導入進去
可以通過Events事件中查看 正在導入

 

等待看不到rsync進程則導入完成
[root@CentOS6 CentOS-6.8-x86_64]# ps -ef|grep rsync
root       2782   1389  0 00:25 pts/0    00:00:00 grep rsync

 

創建kickstart文件

wKiom1jaF8DjF9hxAADIrn6Axp8384.png-wh_50

# Cobbler for Kickstart Configurator for CentOS 6.8
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw  --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end
%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end

 

今後只要安裝CerntOS鏡像,就會去關聯這個kickstart.cfg文件

### 每次改完配置文件 都要sync同步一下

wKioL1jaGJnhEN87AAD_BGZooqM851.png-wh_50

 

物理機安裝 只要連接上網線 與 10.0.0.101同網段即可,dhcp服務器會自動識別到新服務器

虛擬機 需要新建虛擬機 添加網卡 eth1 並且配置同樣的lan區段 然後開機

需要cobbler_load.tar.gz包的小夥幫可以留言並留下郵箱地址

### 開啓虛擬機
### 並不能直接自動安裝操作系統 這樣不太安全 cobbler有一個安全錯誤 要先選擇
### 選擇local 就是從本地硬盤啓動 防止誤重裝安全系統 儘量保留
### 選擇下面則會開始自動安裝 

wKiom1jaGU2z6tELAAARfyXy5j4725.png-wh_50

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章