半自動化安裝腳本
在可以聯網的機器準備
準備離線裝機包
# 安裝yum-utils
# yum-utils是管理repository及擴展包的工具,包含一系列yum工具,我們需要使用yumdownloader來下載cobbler相關的依賴包
yum install -y yum-utils
使用yumdownlader下載cobbler及相關產品的依賴包
yumdownloader --resolve --destdir=/tmp/offline-cobbler/ cobbler cobbler-web dhcp httpd tftp xinetd pykickstart debmirror
安裝createrepo
yum -y install createrepo
創建yum倉庫檔案
cd /tmp/offline-cobbler/
createrepo .
打包cobbler離線安裝檔案
cd /tmp
tar -zcvf offline-cobbler.tar.gz offline-cobbler/
我已經打包好的cobbler包,提取碼:w3kb
在無網機器中操作
1. 將打包好的cobbler壓縮包傳入機器
2. 解壓offline-cobbler.tar.gz
tar xvf offline-cobbler.tar.gz -C /tmp/
3. 備份現有yum源
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
4. 撰寫本地yum源
# 掛載本地iso鏡像,需要本地yum源不然安裝的時候會少依賴
# 先使用u盤傳一個iso鏡像最好與本機系統版本一致
# 具體掛載位置看你上傳的鏡像位置,虛擬機操作是/dev/sr0
$ mount /dev/sr0 /mnt
$ vi /etc/yum.repos.d/cobbler.repo
[cobbler]
name=cobbler local repo
baseurl=file:///tmp/offline-cobbler/
gpgcheck=0
enalbed=1
# 本機鏡像源
$ vi /etc/yum.repos.d/Centos.repo
[centos]
name=centos
baseurl=file:///mnt/
gpgcheck=0
enalbed=1
5. 生成yum快取
yum clean all
yum makecache
6. 安裝cobbler
# 關閉selinux和防火墻
# -i 直接修改檔案
# s 查找替換
# g 完成所有匹配值的替換
$ sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
$ setenforce 0
$ systemctl disable firewalld.service
$ systemctl stop firewalld.service
# 安裝cobbler
$ yum install cobbler -y
7. 安裝dhcp和httpd
# 移除cobbler yum源之后安裝
rm -f /etc/yum.repos.d/cobbler.repo
yum install dhcp httpd -y
8. 啟動服務
$ systemctl enable httpd.service tftp.socket cobblerd.service
$ systemctl start httpd.service tftp.socket cobblerd.service
9. 檢查cobbler
$ 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : ksvalidator was not found, install pykickstart
9 : 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
10 : 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、/etc/cobbler/settings中的“server”欄位必須設定為localhost以外的地址,否則kickstarting特性將不起作用,其應該是一個可決議的主機名或IP,所有機器都可達的地址,
2、為了使PXE正常作業,必須將/etc/cobbler/settings中的“next_server”欄位設定為除127.0.0.1之外的其他欄位,并且應該與PXE網路上的引導服務器的IP匹配,
3、SELinux已啟用,請查看下面的Wiki頁面以確保在您的SELinux環境下cobbler可以正確作業;
4、 在/etc/xinetd.d/tftp檔案中將 'disable' 設定為 'no';
Xinetd:即extended internet daemon,是新一代的網路守護行程服務程式,又叫超級Internet服務器,常用來管理多種輕量級Internet服務,Xinetd提供類似于inetd+tcp_wrapper的功能,但是更加強大和安全,
5、一些網路引導加載程式在/var/lib/cobblerZ/loaders中丟失,您可以運行“cobbler get-loaders”來下載它們,如果您只想處理x86/x86_64 網路引導,確保您已經安裝了最近的syslinux包,安裝后可以忽略此訊息,如果希望支持所有體系結構,則此目錄中的檔案應該包括pxelinux.0(預啟動linux引導程式)、menu.c32(顯示選單界面引導程式)、elilo.efi(ELILO 是一種基于 EFI 開發的 boot loader)和yaboot(Macintosh的引導程式),“cobbler get-loaders”命令是解決這些需求最簡單的方法,
6、使用systemctl命令開啟rsyncd.service服務(rsync(remote [r??mo?t] sync [s??k])是linux系統下的資料鏡像備份工具)并設定開機自啟
7、debmirror包沒有安裝,它用來管理Debian系統的部署和存盤庫
8、ksvalidator (validator [?v?l?de?t?r]驗證器)沒有發現,要安裝pykickstart
9、新安裝的機器的默認密碼設定為cobbler,你可以使用"openssl passwd -1 -salt 'random phrase-here' 'your-password-here'"得到新得密碼
10、fencing([?fens??] 擊劍/(用柵欄、籬笆或圍欄)圍住) tools 沒有找到,它被用來電源管理功能(可選),安裝cman或者fence-agents 來使用
按步驟修復即可,基本想搞離線安裝的肯定都會接下來的操作,我這邊就不寫了.
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/499702.html
標籤:Linux
