一个能够实现批量安装系统的Linxu应用程序,他能够实现同个服务器安装不一样操做系统版本。html
开启两个网卡。一个仅主机模式,一个桥接模式,仅主机模式对内提供cobbler服务。linux
配置完网卡后ping网络会ping不一样。vim
打开centos
vim /etc/resolv.conf
编写浏览器
nameserver 114.114.114..114 nameserver 8.8.8.8
不需重启网络,便可设置好网络。bash
yum install cobbler dhcp tftp-server xinetd syslinux httpd pykickstart -y
dhcp:新装的机子要给他一个ip,因此要下载一个dhcp服务器
tftp:简单传输协议网络
xinetd:超级守护进程,负责维护了一些小的服务架构
syslinux:引导程序,引导咱们的虚根,引导咱们的内核加密
yum安装cobbler须要使用下面两个源,把下面的代码添加到yum仓库
[epel]
name=epel
enabled=1
gpgcheck=0
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/ [centos]
name=centos base
enabled=1
gpgcheck=0
baseurl=http://mirrors.163.com/centos/7/os/x86_64/
Vim /etc/dhcp/dhcpd.conf
IP配咱们仅主机模式的IP
接下来配置守护进程
vim /etc/xinetd.d/tftp
把里面的 disable = yes 改为 no 便可。
systemctl restart xinetd
systemctl enable xinetd
systemctl eanble dhcp
执行这条命令
cobbler check
报错执行
systemctl restart httpd.service
vim /etc/cobbler/settings
将server处都修改为仅主机IP(272行和384行)
接下来
systemctl restart rsyncd systemctl enable rsyncd openssl passwd -1 -salt "123" "123456" $1$123$7mft0jKnzzvAdU4t0unTG1
并把新生成的加密数据填写进
/etc/cobbler/settings 101 default_password_crypted: "$1$123$7mft0jKnzzvAdU4t0unTG1"
以上问题解决以后,须要同步和重启
systemctl restart cobblerd
cobbler sync
cobbler import --path=/挂载点 --name=“centos7.5”名字千万不能有空格
查看distro
cobbler distro list centos7.5-x86_64
查看profile
cobbler profile list centos7.5-x86_64
distro : 发行版, 就是咱们安装什么版本的linux操做系统的名称 一会咱们会导入一个 distro.
profile : 相似于一个 配置文件,相似于你的 bash_profile, 里面包含你能够添加 kernel 参数,对应的kickstart 文件 以及 此profile 对应的 distro 等等.
咱们虽然建立的有,但他不包含kickstart,因此,咱们要复制root目录下的anaconda-ks.cfg 到 /var/lib/cobbler/kickstarts,更名为ks.cfg。
cp -a anaconda-ks.cfg /var/lib/cobbler/kickstarts/ks.cfg
然后打开dhcpd配置文件,添加一行东西
filename “pxelinux.0”;
意思为告诉我客户端要找我这个东西。
而后重启dhcpd
systemctl restart dhcp
如今打开ks.cfg文件进行修改,
find / -name centos7.5
#找出来,复制他的绝对路径
以前是cdrom,将cdrom删除,改为url --url=http://
url --url=http://仅主机模式的ip/cobbler/ks_mirror/centos7.5/
保存退出便可。
cobbler profile add --distro=centos7.5-x86_64 --name=centos7.5_ken --kickstart=/var/lib/cobbler/kickstarts/ks.cfg
而后查看一下
cobbler profile list
会有两个
删除带架构的便可。
cobbler profile remove --name= 指定名字
然后同步
cobbler sync
然后重启这些服务
service httpd restart
service cobblerd restart
service dhcpd restart
service xinetd restart
然后开始建立新的虚拟机,内存要加到3个G,否则会带不起来,模式要改为仅主机模式,然后选择安装便可。
cd /var/www/html
在此目录里建立一个目录,然后将cd挂载到刚建立的目录。
然后用浏览器访问IP加目录就能够了。