上一篇文章
>pxe系统批量自动安装
操作系统:rhel7.3
Python版本:2.7
安装包百度网盘链接: https://pan.baidu.com/s/1AOZ8vF4JyUSeFRn-sd100w 提取码: 4tnb
[root@server1 ~]# yum install -y createrepo httpd mkisofs python-netaddr \
python-urlgrabber xinetd rsync syslinux tftp-server yum-utils mod_ssl mod_wsgi \
git make python-devel python-setuptools fence-agents pykickstart dhcp rpm-build \
edpatch perl-Compress-Zlib perl-libwww-perl perl-Digest-SHA
下载地址:https://pypi.org/project/PyYAML/#files
[root@server1 ~]# wget https://files.pythonhosted.org/packages/9f/2c/9417b5c774792634834e730932745bc09a7d36754ca00acf1ccd1ac2594d/PyYAML-5.1.tar.gz
[root@server1 ~]# tar xf PyYAML-5.1.tar.gz
[root@server1 ~]# cd PyYAML-5.1/
[root@server1 PyYAML-5.1]# python setup.py install
### 这里是Python2.7,如果是Python3的话可以装Django2版本
[root@server1 ~]# wget https://media.djangoproject.com/releases/1.10/Django-1.10.8.tar.gz
[root@server1 ~]# tar xf Django-1.10.8.tar.gz
[root@server1 ~]# cd Django-1.10.8/
[root@server1 Django-1.10.8]# python setup.py install
下载地址:https://pypi.org/project/Markdown/#files
[root@server1 ~]# wget https://files.pythonhosted.org/packages/3c/52/7bae9e99a7a4be6af4a713fe9b692777e6468d28991c54c273dfb6ec9fb2/Markdown-3.0.1.tar.gz
[root@server1 ~]# tar xf Markdown-3.0.1.tar.gz
[root@server1 ~]# cd Markdown-3.0.1/
[root@server1 Markdown-3.0.1]# python setup.py install
下载地址:https://pypi.org/project/Cheetah/2.4.4/#files
[root@server1 ~]# wget https://files.pythonhosted.org/packages/cd/b0/c2d700252fc251e91c08639ff41a8a5203b627f4e0a2ae18a6b662ab32ea/Cheetah-2.4.4.tar.gz
[root@server1 ~]# tar xf Cheetah-2.4.4.tar.gz
[root@server1 ~]# cd Cheetah-2.4.4/
[root@server1 Cheetah-2.4.4]# python setup.py install
联网安装链接:https://cobbler.github.io/manuals/quickstart/
下载地址:https://github.com/cobbler/cobbler/releases/tag/v2.8.4
[root@server1 ~]# wget https://github.com/cobbler/cobbler/archive/v2.8.4.tar.gz
[root@server1 ~]# tar xf v2.8.4.tar.gz
[root@server1 ~]# cd cobbler-2.8.4/
[root@server1 cobbler-2.8.4]# make && make install
[root@server1 cobbler-2.8.4]# mkdir -p /var/www/cobbler/web /srv/www/cobbler/svc
###检测,没有报错cobbler也会启动,手动启动命令systemctl restart cobblerd
[root@server1 cobbler-2.8.4]# make webtest
cobbler check ###核对当前设置是否有问题
cobbler list ###列出所有的cobbler元素
cobbler report ###列出元素的详细信息
cobbler sync ###同步配置到数据目录,更改配置最好都要执行下
cobbler reposync ###同步yum仓库
cobbler distro ###查看导入的发行版系统信息
cobbler system ###查看添加的系统信息
cobbler profile ###查看配置信息
### 生成加密密码,前面的“dreamya”为干扰码,可自行设置,这里“123456”就是root密码
[root@server1 ~]# openssl passwd -1 -salt 'dreamya' '123456'
$1$dreamya$cNDemAQyzv5/63XPbALwY.
[root@server1 ~]# vim /etc/cobbler/settings
101 default_password_crypted: "$1$dreamya$cNDemAQyzv5/63XPbALwY."
242 manage_dhcp: 1 ###如果使用cobbler配置dhcp可以打开(即修改为1),否则直接配置dhcp即可
261 manage_rsync: 1
272 next_server: 10.10.10.1 (IP修改成本机地址)
292 pxe_just_once: 1 ###防止重装
384 server: 10.10.10.1 (IP修改成本机地址)
不通过cobbler设置dhcp参考博客:https://blog.csdn.net/Dream_ya/article/details/79245704
[root@server1 ~]# vim /etc/cobbler/dhcp.template
...
subnet 10.10.10.0 netmask 255.255.255.0 {
### 下面这2个IP都是设置为本机ip
option routers 10.10.10.1;
option domain-name-servers 10.10.10.1;
option subnet-mask 255.255.255.0;
### 设置生成IP范围
range dynamic-bootp 10.10.10.110 10.10.10.150;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
...
}
[root@server1 ~]# vim /etc/cobbler/tftpd.template
service tftp
{
disable = no ###yes修改为no
socket_type = dgram
protocol = udp
wait = yes
user = $user
server = $binary
server_args = -B 1380 -v -s $args
per_source = 11
cps = 100 2
flags = IPv4
}
[root@server1 ~]# mkdir /rhel7.3
[root@server1 ~]# mount /dev/sr0 /rhel7.3/
mount: /dev/sr0 is write-protected, mounting read-only
自定制使用ks:cobbler profile add --name=安装选择时的名字 --kickstart=/var/lib/cobbler/kickstarts/xx.ks --distro=rhel7.3-x86_64 --kopts=‘net.ifnames=0 biosdevname=0’
[root@server1 ~]# cobbler import --path=/rhel7.3/ --name=rhel7.3 --arch=x86_64
[root@server1 ~]# cobbler distro list ###查看导入的镜像
rhel7.3-x86_64
[root@server1 ~]# cobbler profile report rhel7.3-x86_64 ###查看镜像信息
### 需要确定http和cobbler是启动的,下面这部是需要连接外网的,也可以把上面的百度网盘链接的loaders的包解压放入即可
[root@server1 ~]# systemctl restart httpd
[root@server1 ~]# cobbler get-loaders
task started: 2019-03-20_225257_get_loaders
task started (id=Download Bootloader Content, time=Wed Mar 20 22:52:57 2019)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
[root@server1 ~]# ls /var/lib/cobbler/loaders/
COPYING.elilo COPYING.yaboot grub-x86_64.efi menu.c32 README
COPYING.syslinux elilo-ia64.efi grub-x86.efi pxelinux.0 yaboot
### 如果想修改网卡名可以先执行此命令:cobbler profile edit --name=rhel7.3-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@server1 ~]# cobbler sync
[root@server1 ~]# systemctl restart httpd && systemctl enable httpd
[root@server1 ~]# systemctl restart xinetd && systemctl enable xinetd
[root@server1 ~]# systemctl restart cobblerd && chkconfig cobblerd on
[root@server1 ~]# systemctl restart dhcpd && systemctl enable dhcpd
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=$tree
# Root password
rootpw --iscrypted $1$nD88pFjh$H9Kd9/Zp2J3jR.dxP9JBv0
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Network information
network --bootproto=dhcp --device=em1 --onboot=on
# System bootloader configuration
bootloader --location=mbr
#bootloader --append=" crashkernel=auto" --location=mbr --driveorder=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
#需要使用下面那个,mbr可以使用上面这个
#clearpart --all --drives=sda
clearpart --none --initlabel
part /boot/efi --fstype="efi" --ondisk=sda --size=1024 --fsoptions="defaults,uid=0,gid=0,umask=0077,shortname=winnt"
part swap --fstype="swap" --size=2048
part / --fstype="ext4" --size=102400
part /boot --fstype="ext4" --size=1024
%pre
parted -s /dev/sda mklabel gpt
%end
%packages
@base
%end