日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

cobbler自动化安装Linux系统

發(fā)布時(shí)間:2024/4/15 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 cobbler自动化安装Linux系统 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

cobbler簡介

Cobbler是一個(gè)Linux服務(wù)器快速網(wǎng)絡(luò)安裝的服務(wù),而且在經(jīng)過調(diào)整也可以支持網(wǎng)絡(luò)安裝windows。該工具使用python開發(fā),小巧輕便(才15k行python代碼),可以通過網(wǎng)絡(luò)啟動(dòng)(PXE)的方式來快速安裝、重裝物理服務(wù)器和虛擬機(jī),同時(shí)還可以管理DHCP,DNS,TFTP、RSYNC以及yum倉庫、構(gòu)造系統(tǒng)ISO鏡像。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),還提供了API接口,可以方便二次開發(fā)使用。
Cobbler是kickstart的升級版,優(yōu)點(diǎn)是比較容易配置,還自帶web界面比較易于管理。
Cobbler客戶端Koan支持虛擬機(jī)安裝和操作系統(tǒng)重新安裝,使重裝系統(tǒng)更便捷。

cobbler安裝部署

操作系統(tǒng):CentOS release 7.1

防火墻、Selinux關(guān)閉

安裝eple源

# yum -y install epel-release

安裝cobbler所需要的軟件包

# yum -y install cobbler cobbler-web pykickstart httpd dhcp tftp-server

啟動(dòng)服務(wù)

# /etc/init.d/httpd start # /etc/init.d/cobblerd start

初次啟動(dòng)httpd會(huì)有報(bào)錯(cuò)

Starting httpd: httpd: apr_sockaddr_info_get() failed for Template httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName #遇見報(bào)錯(cuò)需要修改apache的配置文件,添加一行 # vim /etc/httpd/conf/httpd.conf ServerName localhost:80

啟動(dòng)服務(wù)后,使用cobbler check檢查配置文件查看是否有問題,一般第一次啟動(dòng)的時(shí)候會(huì)有報(bào)錯(cuò),不過不用管,重啟cobbler后就會(huì)正常

# cobbler check Traceback (most recent call last):File "/usr/bin/cobbler", line 36, in <module>sys.exit(app.main())File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 657, in mainrc = cli.run(sys.argv)File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 270, in runself.token = self.remote.login("", self.shared_secret)File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__return self.__send(self.__name, args)File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __requestverbose=self.__verboseFile "/usr/lib64/python2.6/xmlrpclib.py", line 1253, in requestreturn self._parse_response(h.getfile(), sock)File "/usr/lib64/python2.6/xmlrpclib.py", line 1392, in _parse_responsereturn u.close()File "/usr/lib64/python2.6/xmlrpclib.py", line 838, in closeraise Fault(**self._stack[0]) xmlrpclib.Fault: <Fault 1: "<class 'cobbler.cexceptions.CX'>:'login failed'">

再次運(yùn)行cobbler check檢查配置文件,會(huì)出現(xiàn)如下錯(cuò)誤,檢查的時(shí)候一定要要在httpd與cobbler都啟動(dòng)的情況下檢查

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 themRestart cobblerd and then run 'cobbler sync' to apply changes.

上述問題解答方法如下:

1.需要修改/etc/cobbler/setting配置文件,將server行的IP改為本機(jī)IP
# sed -i 's#server: 127.0.0.0#server: 本機(jī)IP#g' /etc/cobbler/settings
2.需要修改/etc/cobbler/setting配置文件,將server_next行的IP改為本機(jī)IP
# sed -i 's#next_server: 127.0.0.1#next_server: 本機(jī)IP#g' /etc/cobbler/settings
3.修改/etc/xinetd.d/tftp配置文件,將disable = yes改為no
# sed -i 's#disable.* ?= yes#disable ? ? ? ? ? ? ? ? = no #g' /etc/xinetd.d/tftp
4.運(yùn)行cobbler get-loaders命令就行
5.修改/etc/xinetd.d/rsync配置文件,將disable = yes改為no
# sed -i 's#disable.*= yes# disable = no#g' /etc/xinetd.d/rsync
6.
7.安裝debmirror包,如果不安裝debian系統(tǒng)可以忽略
# yum install -y debmirror
8.使用openssl設(shè)置一個(gè)新的密碼來代替默認(rèn)密碼
# openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"
9.安裝cman?fence-agents
# yum install -y cman fence-agents

?再次檢測配置文件,會(huì)有關(guān)于debian的報(bào)錯(cuò)。注釋配置文件就行

注釋如下兩行 # vim /etc/debmirro.conf #@dists="sid"; #@arches="i386";

然后執(zhí)行cobbler sync,同步更改后的配置文件

# cobbler sync

cobbler可以管理dhcp,tftp,rsync服務(wù)

# vim /etc/cobbler/setting manage_dhcp = 1 manage_tftp = 1 manage_rsync = 1

cobbler管理dhcp后,只需修改cobbler提供的dhcp模板就行,不需要單獨(dú)的修改dhcp服務(wù)的配置文件

subnet 10.0.0.0 netmask 255.255.255.0 { #本機(jī)電腦所在的子網(wǎng)option routers 10.0.0.2; #設(shè)置客戶端默認(rèn)網(wǎng)關(guān)option domain-name-servers 10.0.0.2; #設(shè)置客戶端默認(rèn)DNSoption subnet-mask 255.255.255.0;range dynamic-bootp 10.0.0.100 10.0.0.254; #客戶端獲取到的地址范圍default-lease-time 21600;max-lease-time 43200;next-server $next_server;

注意:每次修改完cobbler配置信息的時(shí)候一定要使用check sync同步配置文件。

給cobbler服務(wù)器導(dǎo)入鏡像

掛載鏡像

將有鏡像的分區(qū)掛載到服務(wù)上 # mount /dev/cdrom /mnt

導(dǎo)入鏡像

# cobbler import --path=/mnt --name=CentOS-6.7-x86_64 --arch=x86_64 # --path 鏡像路徑 # --name 為安裝源定義一個(gè)名字 # --arch 指定安裝源是32位、64位、ia64, 目前支持的選項(xiàng)有: x86│x86_64│ia64 # 安裝源的唯一標(biāo)示就是根據(jù)name參數(shù)來定義,本例導(dǎo)入成功后,安裝源的唯一標(biāo)示就是:CentOS-6.6-x86_64,如果重復(fù),系統(tǒng)會(huì)提示導(dǎo)入失敗。

查看鏡像

# ll /var/www/cobbler/ks_mirror/
# cobbler distro list

配置ks配置文件

# more CentOS-6.7-x86_64.ks #Install OS install #Install type text#Use network installation url --url=http://10.0.0.222/cobbler/links/CentOS-6.7-x86_64/ #System authorization information auth --useshadow --enablemd5 #Root password rootpw 123456 rootpw --iscrypted $1$123456$wOSEtcyiP2N/IfIl15W6Z0#System bootloader bootloader --location=mbr#Clear the Master Boot Record zerombr#Run the Setup Agent firs boot firstboot --disable#System Keyboard keyboard us#System Language lang en_US#System Timezone timezone --isUtc Asia/Shanghai#Installation logging level logging --level=info#Firewall configuration firewall --disable#Selinux configuration selinux --disable#Disk partition information part /boot --bytes-per-inode=4096 --fstype="ext4" --size=200 part / --asprimary --bytes-per-inode=4096 --fstype="ext4" --size=10240reboot#This packages is for CentOS6.7 %packages @base @core @compat-libraries @debugging @development @hardware-monitoring @performance @perl-runtime @large-systems lrzsz tree telnet nmap %end

配置完成后需要cobbler sync

然后啟動(dòng)一臺(tái)新的機(jī)器就可以使用cobbler安裝系統(tǒng)了。

cobbler重裝

由于我是選擇安裝7的操作系統(tǒng),現(xiàn)在由于我對centos7的操作系統(tǒng)不熟悉,想要重裝為6的操作系統(tǒng),該如何做呢?

安裝koan

# yum install -y koan

查看cobbler可用的鏡像

# koan --server=10.0.0.222 --list=profiles - looking for Cobbler at http://10.0.0.222:80/cobbler_api CentOS-6.7-x86_64

在已經(jīng)的客戶端進(jìn)行重裝系統(tǒng)操作 ,這個(gè)操作一定要在客戶端操作

# koan --replace-self --server=10.0.0.222 --profile=CentOS-6.7-x86_64

Cobbler使用python調(diào)用API

#!/usr/bin/python import xmlrpclib server = xmlrpclib.Server("http://xx.xx.xx.xx/cobbler_api") print server.get_distros() print server.get_profiles() print server.get_systems() print server.get_images() print server.get_repos()#!/usr/bin/env python # -*- coding: utf-8 -*- import xmlrpclib class CobblerAPI(object):def __init__(self,url,user,password):self.cobbler_user= userself.cobbler_pass = passwordself.cobbler_url = urldef add_system(self,hostname,ip_add,mac_add,profile):''' Add Cobbler System Infomation''' ret = {"result": True,"comment": [],}#get tokenremote = xmlrpclib.Server(self.cobbler_url) token = remote.login(self.cobbler_user,self.cobbler_pass) #add systemsystem_id = remote.new_system(token) remote.modify_system(system_id,"name",hostname,token) remote.modify_system(system_id,"hostname",hostname,token) remote.modify_system(system_id,'modify_interface', { "macaddress-eth0" : mac_add, "ipaddress-eth0" : ip_add, "dnsname-eth0" : hostname, }, token) remote.modify_system(system_id,"profile",profile,token) remote.save_system(system_id, token) try:remote.sync(token)except Exception as e:ret['result'] = Falseret['comment'].append(str(e))return ret def main():cobbler = CobblerAPI("http://xx.xx.xx.xx/cobbler_api","cobbler","cobbler")ret = cobbler.add_system(hostname='cobbler-api-test',ip_add='xx.xx.xx.xx',mac_add='xx:xx:xx:xx:xx:xx',profile='CentOS-7-x86_64')print ret if __name__ == '__main__':main()

?添加repo

# cobbler repo add --name=xxoo --mirror=http://xxoo

同步repo

# cobbler reposync

添加repo到對應(yīng)的profile

# cobbler profile --name=xxoo --repos=xxoo

修改kickstart文件,添加(寫到%post %end中間)

%postsystemctl disable postfix.service$yum_config_stanza%end

添加定時(shí)任務(wù),定期同步repo

# echo "1 3 * * * /usr/bin/cobbler reposync --tries=3 --no-fail" >>/va/spool/cron/root

?

轉(zhuǎn)載于:https://www.cnblogs.com/ebay/p/7443299.html

總結(jié)

以上是生活随笔為你收集整理的cobbler自动化安装Linux系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。