学习自动化装机
第一:解放我们的双手
第二:批量化安装
一台Linux主机
两块网卡
一块网卡配置外网
一块网卡配置内网
[root@scum ~]# cat /etc/redhat-release #检查系统版本
CentOS release 6.7 (Final)
[root@scum ~]# service iptables stop #关闭防火墙
[root@scum ~]# setenforce 0 #关闭selinux
[root@scum ~]# yum install cobbler dhcp tftp-server xinetd syslinux httpd pykickstart -y
yum安装cobbler需要网络源,为大家准备了一份网络源,使用这个网络源可以下载cobbler
[epel]
name=epel
enabled=1
gpgcheck=0
baseurl=https://mirrors.aliyun.com/epel/6Server/x86_64/
[root@scum ~]# vim /etc/dhcp/dhcpd.conf #写下如下代码
subnet 192.168.169.0 netmask 255.255.255.0 {
range 192.168.169.15 192.168.169.254;
default-lease-time 600;
max-lease-time 7200;
filename "pxelinux.0";
}
#设置ip段
#设置DHCP池
[root@scum ~]# systemcctl restart dhcpd
[root@scum ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file
transfer \
# protocol. The tftp protocol is often used to boot diskles
s \
# workstations, download configuration files to network-awar
e printers, \
# and to start the installation process for some operating s
ystems.
service tftp
{
disable = no #把yes修改为no,即启动tftp服务
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
}
[root@scum ~]# systemcctl restart xinetd
[root@scum ~]# cobbler check
The following are potential configuration items that you may want to fix:
: 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.
: 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.
: 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.
: change 'disable' to 'no' in /etc/xinetd.d/rsync
: debmirror package is not installed, it will be required to manage debian deployments and repositories
: 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
: 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.
根据上面的错误,逐一修改。
问题三、五、七可以忽略。
问题一:
cobbler文件默认是127.0.0.1本地回环地址,需要更改为提供cobbler服务的ip地址 192.168.169.10
[root@scum ~]# sed -i 's/server: 127.0.0.1/server: 192.168.232.7/g' /etc/cobbler/settings
问题二:
netx_server也是默认本地127.0.0.1回环地址,需要修改为提供cobbler服务的ip地址 192.168.169.10
[root@ken ~]# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.232.7/g' /etc/cobbler/settings
问题四:
启动rsync即可
[root@scum ~]# vim /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no #yes更改为no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root@scum ~]# service xinetd restart #重启xinetd服务
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@scum ~]# chkconfig --list | grep rsync #检查rsync是否已经启动
rsync: on
问题六:
更改密码,并把新生成的加密数据填写进/etc/cobbler/settings
[root@scum ~]# openssl passwd -1 -salt '123' '123456'
$1$123$7mft0jKnzzvAdU4t0unTG1
[root@scum ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$123$7mft0jKnzzvAdU4t0unTG1" #把新生成的加密密码填写在101行处
以上问题解决之后,需要同步和重启
[root@scum ~]# service cobblerd restart #重启cobbler服务
[root@scum ~]# cobbler sync #进行同步
再次检查是否已经更改完成
[root@scum ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : 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.
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.
挂载光盘
[root@scum ~]# mount /dev/cdrom /mnt
数据导入
[root@scum ~]# cobbler import --path=/mnt --name=centos6.7 #进行数据导入
task started: 2018-09-09_021922_import
task started (id=Media import, time=Sun Sep 9 02:19:22 2018)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/centos6.7:
creating new distro: centos6.7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos6.7 -> /var/www/cobbler/links/centos6.7-x86_64
creating new profile: centos6.7-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/centos6.7 for centos6.7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos6.7
need to process repo/comps: /var/www/cobbler/ks_mirror/centos6.7
looking for /var/www/cobbler/ks_mirror/centos6.7/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos6.7/repodata
*** TASK COMPLETE ***
查看distro
[root@scum ~]# cobbler distro list
centos6.7-x86_64
查看profile
[root@scum ~]# cobbler profile list
centos6.7-x86_64
[root@scum ~]# cobbler profile add --distro=centos6.7-x86_64 --name=centos6.7_scum --kickstart=/var/lib/cobbler/kickstarts/ks.cfg
[root@scum ~]# cobbler sync
在root目录下找到ks文件,并移动到/var/lib/cobbler/kickstarts/到目录下改名为ks.cfg
[root@scum ~]# ls
anaconda-ks.cfg install.log install.log.syslog
[root@scum ~]# mv anaconda-ks.cfg /var/lib/cobbler/kickstarts/ks.cfg
[root@scum ~]# vim /var/lib/cobbler/kickstarts/ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url=http://192.168.169.10/cobbler/ks_mirror/centos7.6/ #这里需要更改为repodata所在的http地址
# Use graphical install
查看profile,将不包含ks.conf的包删除
[root@scum ~]# cobbler profile remove --name=centos6.7-x86_64
同步cobbler
[root@scum ~]# cobbler sync
[root@scum ~]# systemctl restart httpd
[root@scum ~]# systemctl restart cobblerd
[root@scum ~]# systemctl restart dhcpd
[root@scum ~]# systemctl restart xinetd