centos7 cobbler

--



# ll /share/CentOS-7-x86_64-DVD-1611.iso 
-rw-r--r-- 1 root root 4379901952 May 22 11:41 /share/CentOS-7-x86_64-DVD-1611.iso



使用此iso用虚拟机图形安装centos7.3


====================================================================================

安装完后,做一些基本优化

1,主机名
centos7有一个新的修改主机名的命令hostnatctl

# hostnamectl set-hostname --static vm1.cluster.com

# vim /etc/hosts    --最后加上你的IP与主机名的绑定
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.2.10 vm1.cluster.com


2,关闭iptables

# systemctl status firewalld.service    --查看firewalld服务的状态,active是启动状态,inactive是关闭状态

# systemctl stop firewalld.service  --关闭此服务


# systemctl list-unit-files |grep firewalld --查看firewalld是否开机自动启动
firewalld.service                           enabled 

# systemctl disable firewalld.service   --类似以前的chkconfig xxx off

# systemctl list-unit-files |grep firewalld
firewalld.service                           disabled


3,关闭selinux(方法和以前一样)

# sed -i 7s/enforcing/disabled/  /etc/selinux/config    --改完后,在后面重启系统生效

4,关闭NetworkManager
# systemctl stop NetworkManager.service
# systemctl disable NetworkManager.service



5,配置本地yum
# rm /etc/yum.repos.d/* -rf --先把原来里面的默认的yum配置删除掉,我们统一使用下面自己配置的本地yum

虚拟机光驱装载centos7.3的镜像

创建目录并将光驱的镜像挂载(我这里是用/yum目录,只是个人习惯而已,你可以使用其它目录挂载)
# mkdir /yum
# mount /dev/cdrom /yum   

将挂载命令加到rc.local设置成开机自动挂载
# vim /etc/rc.local 
mount /dev/cdrom /yum 

# chmod +x /etc/rc.d/rc.local   --rhel7要给执行权限,开机才能执行

创建yum的配置文件,写上本地yum源路径
# vim /etc/yum.repos.d/local.repo   --此文件不存在,手动建立
[centos7.3]
name=centos7.3
baseurl=file:///yum/
enabled=1
gpgcheck=0 


6,再加上epel

# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm 
# rpm -ivh epel-release-7-9.noarch.rpm

安装完后,在/etc/yum.repo.d/目录下会产生epel.repo和epel-testing.repo文件,这就表示已经配置好了,只有能访问公网,就可以直接使用了


7,再加上163的centos源
# cd /etc/yum.repos.d/
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo



# yum clean all


8,时间同步
# yum install ntp  ntpdate  --安装ntp时间同步相关软件包

# vim /etc/ntp.conf     --确认配置文件里有下列的时间同步源(如果前面安装系统界面选择过,这里就有。如果没有可以手动加)
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

# systemctl enable ntpd     --设置开机自动启动ntpd
# systemctl start ntpd      --立即启动ntpd服务
# date              --确认时间与现在时间一致

# ntpdate 0.rhel.pool.ntp.org   --如果还没有同步成功,你可以用此命令手动同步一下



9,重启系统,确认上面的基本修改没问题后,就可以对这个虚拟机做一个快照了(以后做实验需要干净的系统,就可以直接恢复此快照再做实验)


====================================================================================


下面使用centos7.3来做cobbler


第一步:
先安装cobbler相关软件包  --这一次直接使用我们准备好的公网yum源安装就可以了
# yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart fence-agents xinetd   debmirror  system-config-kickstart




第二步:
再把上面准备好的这台机器换成虚拟机的私有网络,我这里仍然是使用昨天使用的vmnet1网络和192.168.1.2/24这个IP

        cobbler server    -------    client
        192.168.1.2/24


修改虚拟机的网卡连接/dev/vmnet1网络

然后修改ip地址
# vim /etc/sysconfig/network-scripts/ifcfg-ens33  --打开网卡配置文件,只修改ip和掩码,其它不变
......
IPADDR="192.168.1.2"
PREFIX="24"
......

# systemctl restart network.service

重启网络后,使用ifconfig查看验证一下是否获取到了192.168.1.2/24这个ip



第三步:启动服务,并使用cobbler check查询哪些需要修改

# systemctl start cobblerd.service
# systemctl start httpd.service 

#  cobbler check    

第四步:按照cobbler check对应的信息修改
# sed -i 272s/127.0.0.1/192.168.1.2/ /etc/cobbler/settings
# sed -i 384s/127.0.0.1/192.168.1.2/ /etc/cobbler/settings  
# sed -i 242s/0/1/ /etc/cobbler/settings


# openssl passwd -1 -salt 'xcvsfdsdfwq' '123456'
$1$xcvsfdsd$cGxdcHuQGCnu5vJw5M7zX1

# vim /etc/cobbler/settings --在101行把上面产生的密码字符串粘贴到""里替代原来的字符串
default_password_crypted: "$1$xcvsfdsd$cGxdcHuQGCnu5vJw5M7zX1"


# systemctl restart cobblerd.service


# sed -i /disable/s/yes/no/ /etc/xinetd.d/tftp

# systemctl start rsyncd.service
# systemctl enable rsyncd.service


第五步:导入centos7.3的iso镜像

# cobbler import --path=/yum/ --name=centos7.3

# cobbler distro list   --导入成功后,确认导入的镜像名
   centos7.3-x86_64
# cobbler profile list  --导入成功后,确认默认的profile名
   centos7.3-x86_64

第六步:修改dhcp配置模块
# vim /etc/cobbler/dhcp.template  --在此文件的第21行到第25行修改成你对应的网段和ip  

subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.2;
     option domain-name-servers 192.168.1.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.254;


第七步:使用cobbler sync同步,并启动xinetd服务
# cobbler sync
# systemctl start xinetd.service


第八步:新建另一个虚拟机(保证相同私有网络,并且最好2G内存,内存小的话会在安装时报空间不够的错误),进行安装测试 


第九步:使用system-config-kickstart图形自定义ks文件

# vim /etc/yum.repo.d/local.repo    --这里有个小问题,需要把软件仓库里改成development,图形才能选择包,否则图形在选择软件包那一步看不到
[development]
name=development
baseurl=file:///yum/
enabled=1
gpgcheck=0


# yum clean all

# system-config-kickstart  --图形自定义ks文件,过程省略

附录一个我这里定义的ks.cfg文件

[root@vm1 ~]# cat /root/ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$s.qimPg3$T/Wp3yfp7/CZfQLfYcT69.
# Use network installation
url --url="http://192.168.1.2/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="xfs" --size=300
part swap --asprimary --fstype="swap" --size=2000
part / --asprimary --fstype="xfs" --grow --size=1

%post
touch /root/123
%end

%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre

%end




# mv /root/ks.cfg  /var/lib/cobbler/kickstarts/myks1.ks
# cobbler profile add --name=my_profile1 --distro=centos7.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/myks1.ks

# cobbler profile list
   centos7.3-x86_64
   my_profile1


最后进行安装测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值