无人值守安装随笔

kickstart

1、搭建dhcp
    [root@temp ~]# yum install dhcp -y
    [root@temp ~]# vim /etc/dhcp/dhcpd.conf
        subnet 172.16.0.0 netmask 255.255.0.0 {
            range 172.16.30.10 172.16.30.20;
            next-server 172.16.30.200;
            filename "pxelinux.0";
        }
    [root@temp ~]# systemctl restart dhcpd.service
    
2、tftp配置
    [root@temp ~]# yum install tftp-server tftp xinetd -y
    [root@temp ~]# vim /etc/xinetd.d/tftp
        disable                 = no
    [root@temp ~]# systemctl restart xinetd.service
    [root@temp ~]# systemctl enable xinetd
    [root@temp ~]# netstat -antulp | grep :69
        udp        0      0 0.0.0.0:69              0.0.0.0:*                           2122/xinetd  
    共享引导文件
    [root@temp ~]# yum provides */pxelinux.0
    [root@temp ~]# yum install /usr/share/syslinux/pxelinux.0 -y
    [root@temp ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
    共享内核和驱动等文件
    [root@temp ~]# cd /mnt/cdrom/isolinux/       //光盘的isolinux下
    [root@temp isolinux]# ls
    [root@temp isolinux]# cp vmlinuz initrd.img vesamenu.c32 boot.msg /var/lib/tftpboot/
    共享默认配置文件
    [root@temp ~]# cd /mnt/cdrom/isolinux/
    [root@temp isolinux]# ls
    [root@temp isolinux]# mkdir /var/lib/tftpboot/pxelinux.cfg
    [root@temp isolinux]# cp isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
    
3、ftp准备安装源    
    [root@temp ~]# yum install vsftpd -y
    [root@temp ~]# systemctl restart vsftpd
    [root@temp ~]# systemctl enable vsftpd
    Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
    [root@temp ~]# mkdir /var/ftp/iso
    [root@temp ~]# echo "/dev/sr0 /var/ftp/iso iso9660 defaults 0 0" >> /etc/fstab
    [root@temp ~]# mount -a
4、准备ks文件
    需要图形界面
    [root@temp ~]# yum install system-config-kickstart -y
    
    [root@temp ~]# system-config-kickstart      //生成ks文件,保存到ftp共享中
    [root@temp ~]# vim /etc/yum.repos.d/mnt_cdrom.repo
            [development]
            name=added from: file:///mnt/cdrom
            baseurl=file:///mnt/cdrom
            enabled=1
    
5、修改default文件
    去自己定义一个新的label(标签)
    [root@temp ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
         66行    label linux-my
                menu label ^Kickstart Install CentOS 7
                kernel vmlinuz
  append initrd=initrd.img inst.stage2=ftp://172.16.30.200/iso inst.ks=ftp://172.16.30.200/pub/ks.cfg quiet

 

cobbler

1、安装cobbler
        1)有网
                epel:extended package enterprise linux    扩展的安装源
            [root@cobbler ~]# ls /etc/yum.repos.d/
                bak  mnt_cdrom.repo
            [root@cobbler ~]# cd /etc/yum.repos.d/
            [root@cobbler yum.repos.d]# gunzip *
            [root@cobbler yum.repos.d]# gzip mnt_cdrom.repo         //把自己配置的本地的压缩下
            [root@cobbler ~]# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
            [root@cobbler yum.repos.d]# ls
                bak               CentOS-Debuginfo.repo  CentOS-Sources.repo  epel-testing.repo
                CentOS-Base.repo  CentOS-fasttrack.repo  CentOS-Vault.repo    mnt_cdrom.repo.gz
                CentOS-CR.repo    CentOS-Media.repo      epel.repo
            [root@cobbler yum.repos.d]# yum clean all
            [root@cobbler ~]# yum install dhcp httpd tftp-server tftp xinetd pykickstart cobbler cobbler-web -y
            
        2)无网
        
        
2、启动服务并配置
    [root@cobbler ~]# systemctl start cobblerd.service  httpd
    [root@cobbler ~]# systemctl enable cobblerd.service  httpd
    检查配置
    [root@cobbler ~]# cobbler check
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 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : 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
8 : 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.
        1/2/3/4/7    —— 必解决
        /etc/cobbler/settings    配置文件
        /etc/xinetd.d/tftp
        /var/lib/cobbler/loaders
        /etc/cobbler/settings                default_password_crypted
        Restart cobblerd and then run 'cobbler sync' to apply changes.
    --------
    报错:就是因为apache未启动
        httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback:

    问题1:
        [root@cobbler ~]# vim /etc/cobbler/settings
            server: 172.16.0.150
    问题2:
        next_server: 172.16.0.150
    问题3:
        [root@cobbler ~]# sed '/disable/s/yes/no/' /etc/xinetd.d/tftp -i
        [root@cobbler ~]# systemctl start xinetd
        [root@cobbler ~]# systemctl enable xinetd
    问题4:
        [root@cobbler ~]# ls /var/lib/cobbler/loaders/
        [root@cobbler ~]# cobbler get-loaders
        [root@cobbler ~]# ls /var/lib/cobbler/loaders/
    问题7:
        [root@cobbler ~]# openssl passwd -1 -salt 'ok' 'ok'                    //随机种子  虚拟机的密码
               $1$ok$x3aiQ0vpjra1ThtfkGC8t0
        [root@cobbler ~]# vim /etc/cobbler/settings
                default_password_crypted: "$1$ok$x3aiQ0vpjra1ThtfkGC8t0"
3、重启服务、再次检查配置、同步更新配置
    [root@cobbler ~]# systemctl restart cobblerd.service
    [root@cobbler ~]# cobbler check
        The following are potential configuration items that you may want to fix:

        1 : enable and start rsyncd.service with systemctl
        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@cobbler ~]# cobbler sync
4、配置dhcp服务
    1)手动配置
    2)用cobbler进行管理     ****
        [root@cobbler ~]# vim /etc/cobbler/settings
            manage_dhcp: 1
        [root@cobbler ~]# vim /etc/cobbler/dhcp.template   //模板文件
                21 subnet 172.16.0.0 netmask 255.255.0.0 {
                 22      option routers             172.16.0.244;
                 23      option domain-name-servers 8.8.8.8;
                 24      option subnet-mask         255.255.0.0;
                 25      range dynamic-bootp        172.16.0.10 172.16.0.20;
                 26      default-lease-time         21600;
                 27      max-lease-time             43200;
                 28      next-server                $next_server;
        [root@cobbler ~]# systemctl restart cobblerd.service
        [root@cobbler ~]# cobbler sync
5、导入光盘镜像
        [root@cobbler ~]# cobbler import --help
            Usage: cobbler import [options]

            Options:
              -h, --help            show this help message and exit
              --arch=ARCH           OS architecture being imported
              --breed=BREED         the breed being imported
              --os-version=OS_VERSION
                                    the version being imported
              --path=PATH           local path or rsync location
              --name=NAME           name, ex 'RHEL-5'
              --available-as=AVAILABLE_AS
                                    tree is here, don't mirror
              --kickstart=KICKSTART_FILE
                                    assign this kickstart file
              --rsync-flags=RSYNC_FLAGS
                                    pass additional flags to rsync
        [root@cobbler ~]# cobbler import --path=/mnt/cdrom --name=CentOS7-4-x86_64 --arch=x86_64
                        --path后面写的是光盘的挂载点
        镜像导入到系统的/var/www/cobbler/ks_mirror目录下。

 

posted on 2018-05-30 14:52  dataunix123  阅读(143)  评论(0编辑  收藏  举报