无人值守安装(自动按定制的需求来批量安装 linux 系统)
- kickstart
- cobbler
linux 安装系统的方法:
1 光盘 ---- 把 iso 镜像刻录 (windows 下有类似 nero 这类软件) 到光盘里, 通过光驱, 再修改 BIOS 第一启动顺序为光驱进行安装
2 u 盘 ---- 把 iso 镜像刻录 (windows 下有类似 nero 这类软件) 到 U 盘里(具体过程请上网自已查), 通过 USB 接口, 再修改 BIOS 第一启动顺序为 U 盘进行安装
3 硬盘 ---- 在 linux 硬盘上有 iso 镜像, 可以通过 grub 进行硬盘安装第二个操作系统, 或者重装系统(只重格根分区, 不要重格 iso 所在的分区)
4 网络
/share/soft/rhel-server-6.5-x86_64-dvd.iso 3.6G 3.6G
rhel6 的 iso 镜像里的基本文件说明:
Packages: 这个目录是存放 rhel6 所有的 rpm 包(但不代表其它的 linux 也都一样, 比如 rhel5 是分为四个目录来存放 rpm 包的)
repodata: (repository data 软件仓库数据目录, 你可以把它比喻成一个仓库货物清单), 在 yum 仓库里找软件包不是直接去找包在哪, 而是找 repodata(这是配置 yum 要知道的一个关键知识点)
images 和 isolinux 目录: 简单来说和启动引导系统有关(包括 vmlinuz 和 initrd.img 启动内核的文件)
EFI: 简单来说 EFI 是 BIOS 的升级版
#################################################################
硬盘安装 linux 系统
/dev/sda6
47G 4.0G 40G 9% /share
------ 安装第二个系统(安装在 / dev/sda6)
准备下面这些东西, 最好都放到一个专门的分区挂载目录, 我这里是 / dev/sda6
- /share/rhel-server-6.5-x86_64-dvd.iso
- /share/isolinux/
- /share/images/
- /share/vmlinuz
- /share/initrd.img
重启你的操作系统, 在 grub 界面按 C 键,
- grub> root (hd0,5)
- grub> kernel /vmlinuz
- grub> initrd /initrd.img
- grub> boot
就会进入装系统的界面, 和以前装系统的过程几乎一样, 只有一个地方不一样就是有一步它会问你你的安装方式, 你选择 hard drive, 然后再会问你 iso 的路径, 你选择 / dev/sda6 就可以了;
注: bootloader --grub : 装第二个分区时可以不选 bootloader(一个硬盘只有一个 bootloader(grub)就可以了)
问题: 我现在的机器只有一个 linux,linux 上有一个完整的 rhel6.5 的 iso 镜像, 没有网络, 也没有光驱. 但我现在做了一个错误操作
# rpm -e --nodeps rpm-4.8.0-37.el6.x86_64
造成的我系统 rpm 和 yum 都用不了, 你如何解决?
解决过程:
因为没有光驱, 所以我没办法通过光盘进入 rescue 模式
没有网络, 所以我也没办法通过网络安装服务器进入 rescue 模式
下面我使用硬盘安装第二个 linux, 通过第二个 linux 再把 rpm 包安装回来:
步骤一:
通过上面的硬盘安装方法, 安装第二个 linux(在分区自定义, 在 free 空间再分一个根, 把它格式化. 但这里要注意, 不要把你第一个系统的分区给标记为格式化)
我这里第二个 linux 的根为 / dev/sda9, 并且选安装包为了方便, 选的是最小化安装
-- 注意: 在 install boot loader on /dev/sda 这一步, 我没有打勾 (表示第二个 linux 的 boot loader 不会覆盖第一个的, 仍然使用第一个 linux 的 boot loader)
步骤二:
安装完后, 进入第一个 linux
去修改第一个 linux 的 / boot/grub/grub.conf, 增加下面一段
title second rhel6.5
root (hd0,8)----- 指的是 / dev/sda9
- kernel /boot/vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/sda9 rhgb quiet
- initrd /boot/initramfs-2.6.32-431.el6.x86_64.img
步骤三:
在第一个 linux 上 mount /dev/sda9 /mnt 把第二个 linux 的根挂载
# cp /yum/Packages/rpm-4.8.0-37.el6.x86_64.rpm /mnt/ 把我们要安装的包拷贝到第一个系统
步骤四:
重启 linux, 选择 second rhel6.5 引导第二 linux 启动
进入第二个 linux 后
- # mount /dev/sda2 /media 把第一个系统的根挂载到第二个系统的 / media
- # rpm -ivh --root=/media /rpm-4.8.0-37.el6.x86_64.rpm -- 使用这个方法把 rpm 安装回第一个系统了
步骤五:
重启 linux, 回到第一个 linux, 验证 rpm 安装回来了
最后再补充: 如果你想换回第二个的 boot loader, 可以进入第二个 linux, 然后写好 / boot/grub/grub.conf,
最后执行 grub-install /dev/sda(也就是说, 多个 linux 的 boot loader 可以随时使用这个方法切换)
-----------------------------------------------------------------------------------
基于 pxe(preboot execute environment)技术
pxe 是 intel 公司的技术, 工作 server/client 的网络模式, 支持客户端从服务端下载软件, 再使用 t https://i.cnblogs.com/ftp
(trival file tranfer protocol) 协议下载一个启动软件包到客户端内存中执行.
PXE(preboot execute environment, 预启动执行环境)是由 Intel 公司 https://baike.baidu.com/item/Intel公司 开发的最新技术, 工作于 Client/Server 的网络模式, 支持工作站 https://baike.baidu.com/item/工作站 通过网络从远端服务器下载映像, 并由此支持通过网络启动操作系统, 在启动过程中, 终端要求服务器分配 IP 地址, 再用 https://baike.baidu.com/item/TFTP (trivial file transfer protocol)或 https://baike.baidu.com/item/MTFTP (multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行, 由这个启动软件包完成终端 (客户端) 基本软件设置, 从而引导预先安装在服务器中的终端操作系统.
t https://i.cnblogs.com/ftp
简单文件传输协议, 提供简单的, 不可靠的文件传输. 基于 UDP 的 69 端口.
要求的技术和服务:
1 nfs 服务器或者用 http,ftp 三种协议之一 https://i.cnblogs.com/http,ftp三种协议之一 (共享安装光盘目录文件)
2 tftp 服务器 https://i.cnblogs.com/ftp服务器
----- 共享启动相关文件
3 dhcp 服务器
----- 客户端获取 IP, 网关, DNS 指向, 主机名, NIS 域, NTP
4 kickstart 程序生成的 ks.cfg 配置文件(此文件就定义了安装系统如何分区, 如何格式化, root 密码等等) 取一个安装名字, 可以由客户端自动选择是否用此安装名安装
满足上面的 1,2,3 三点, 就是安装服务器 (类似第一天来学习时的安装系统的网络服务器), 客户端(支持 pxe 的网卡) 选择网络启动 ---- 通过 dhcp 获取 IP 可以和服务器通迅 ---- 通过 tftp 下载系统引导文 https://i.cnblogs.com/ftp下载系统引导文 件 ---- 按照 ks.cfg 配置文件里的方式来自动安装操作系统 ---- 在安装最后一步要安装软件包, 会按照 ks.cfg 里配置的软件包来安装
我们这里用一个虚拟机做服务器, 另一个虚拟机做客户端, 并使用 host-only(vmnet1)网络, 防止都在同一个网络造成 dhcp 获取混乱(我这里的用的网段为 192.168.1.0/24, 这是一个公网网段, 我在这里只是实验测试为了方便而已)
- cobbler server ------- client
- 192.168.1.2/24
安装前准备:
(这里特别要注意一点: 你的虚拟机的 cobbler-server 的 / var 目录空间最少要有 4G 以上空间)
1, 关闭 iptables,selinux
2, 配置静态 IP
3, 设置主机名
4, 时间同步
5, 配置本地 iso 镜像里的 yum 仓库
我这里直接把宿主机里的镜像 / share/soft/rhel-server-6.5-x86_64-dvd.iso 直接放到 cobbler server 虚拟机的光驱里
- # mkdir /yum
- # mount /dev/cdrom /yum
简单时间服务器的配置
1,ntp
2,rdate
这里写一下 rdate 的配置方法
在服务器 (建议使用宿主机) 上
- # yum install xinetd -y
- # vim /etc/xinetd.d/time-dgram
- disable = no ----(--yes 改为 no)
- # vim /etc/xinetd.d/time-stream
- disable = no -----(--yes 改为 no)
- # /etc/init.d/xinetd restart
- # chkconfig xinetd on
客户端同步时间的用法
- # rdate -s 时间服务器的 ip
- ------------------------------------------------------------------------------
[需要 epel 源]
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
第一大步: 在 cobbler server 上安装 cobbler
- cobbler-2.6.3-1.el6.noarch.rpm
- cobbler-web-2.6.3-1.el6.noarch.rpm
- koan-2.6.9-1.el6.noarch.rpm
- libyaml-0.1.4-2.3.x86_64.rpm
- Django14-1.4.20-1.el6.noarch.rpm
- PyYAML-3.10-3.1.el6.x86_64.rpm
安装 cobbler 和 cobbler-web
- # yum install createrepo -y
- # cd /cobbler_soft/
- # createrepo .
---- 把当前目录这 6 个 rpm 包做一个 repodata(类似软件的一个仓库软件清单)
# vim /etc/yum.repos.d/rhel-source.repo
---- 在你原来的 yum 的配置基础上, 再加上下面这一段
- [cobbler]
- name=cobbler
- baseurl=file:///cobbler_soft
- enabled=1
- gpgcheck=0
- # yum clean all
- # yum makecache
- # yum install cobbler cobbler-web
-- 安装 cobbler 和 cobbler-web, 自动解决依赖性
安装完 cobbler, 把下面这些组件服务也确认安装上
# yum install t https://i.cnblogs.com/ftp* rsync xinetd https://i.cnblogs.com/http* syslinux dhcp* pykickstart
扩展问题:
如果你要下载并安装一些 rpm 包时, 如果缺少依赖性包, 但官方又没有提供(这种事很常见), 你操作系统的 iso 镜像里也没有, 你如何去找这些依赖包?
答案:
方法一: 去一些第三方的 yum 仓库里去找, 如:
epel 源, 163 源(mirrors.163.com),centos 源
方法二:
如果上面的 yum 还是找不到, 则去 www.rpmfind.net 或 rpm.pbone.net 网站去搜 http://www.rpmfind.xn--netrpm-r06l.pbone.xn--net-gu3ev26e3f5a1sg/
第二大步: 基本配置
# cobbler check
-- 查看 cobbler 潜在的需要修改的选项(有可能因为你的 httpd 启不 https://i.cnblogs.com/httpd启不 来, 而选成无法显示下面的结果; 按报错去解决它)
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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment: https://github.com/cobbler/cobbler/wiki/Selinux
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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
- #6 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : 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.
-- 说明: 上面我这里是有 9 个需求(不同的机器和环境可能会不一样, 按照它的说明去解决就可以了
解决需求 1, 需求 2, 需求 8:
# openssl passwd -1 -salt 'werwqerwqr' '123456'
----123456 为密码(这是自动安
装客户端系统成功后的 root 登录密码),werwqerwqr 为随机字节干扰码(随便写)------ 为客户端设置 root 密码:"123456"
$1$werwqerw$.prcfrYFbwuvkD8XspayN.
# vim /etc/cobbler/settings
server: 192.168.1.2 ---------- 换成 cobbler 服务器端的 IP--(第 384 行)
next_server: 192.168.1.2 ---- 同上 --(第 272 行)
default_password_crypted: "$1$werwqerw
$.prcfrYFbwuvkD8XspayN." -- 把密码字符串换成你上面产生的字符串(此密码为客户机安装后的 root 登录密码)--(第 101 行)
# /etc/init.d/cobblerd restart ---- 修改后重启
解决需求 3
关闭 selinux
- # vim /etc/selinux/config
- SELINUX=disabled
-- 如果真的要完全关闭, 必须按上面的操作并重启生效; 如果你觉得麻烦, 可以使用 setenforce 0 暂时代替
解决需求 5
# vim /etc/xinetd.d/rsync
disable = no ----yes 改为 no
解决需求 6
- # /etc/init.d/iptables stop
- # chkconfig iptables off
或者开启 iptables, 但要开放 69, 80/443, 25151 这几个端口
解决需求 9
# yum install fence-agents
解决了上面的问题后, 再次 cobbler check
# cobbler check
-- 解决了上面的问题, 只余下两个问题了(问题 1 可以使用 cobbler get-
loaders 解决, 但需要有外网和外网的 yum 源; 问题 2 是关于 debian 系统的, 我们这里可以忽略)
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
Restart cobblerd and then run 'cobbler sync' to apply changes.
第三大步: 导入镜像
以下是相关配置路径(默认安装) :
Cobbler 配置主要位置:/var/lib/cobbler/
snippets 代码 位置:/var/lib/cobbler/snippets/
Kickstart 模板 位置 : /var/lib/cobbler/kickstarts/
默认使用的 ks 文件: /var/lib/cobbler/kickstarts/default.ks
装源镜像 位置 : /var/www/cobbler/ks_mirror/
- # mkdir /yum
- # mount /dev/cdrom /yum -- 先把 iso 挂载到一个目录(我这里是直接用光驱挂载)
- # ls /var/www/cobbler/ks_mirror/
- config
- # cobbler import --path=/yum/ --name=rhel6.5-x86-64 -- 将挂载的镜像目录 / yum 位置导入到 cobbler,name 后面接的是你取的一个名称
- ......
*** TASK COMPLETE ***---- 表示导入成功
- # ls /var/www/cobbler/ks_mirror/ ----- 导入完后, 这里会多了刚导入的镜像目录
- config rhel6.5-x86-64
- # cobbler distro list ------ 列表你 cobbler 导入的镜像
- rhel6.5-64-x86_64
- # cobbler profile list ----- 列表你的 cobbler 自动安装方案(从这里看到你导入一个镜像会默认做一个与它同名的安装方案)
- rhel6.5-64-x86_64
cobbler 可以实现多种不同的 iso 镜像导入, 并且每个 iso 镜像还可以对应多种不同安装方法(也就是说一个 distro 可以对应多个 profile)
第四大步:
修改 dhcp, 让 cobbler 来管理 dhcp, 并进行 cobbler 配置同步
修改 / etc/cobbler/dhcp.template, 此文件是 cobbler 管理 dhcp 的模板(不需要象 kickstart 那样去修改 / etc/dhcp/dhcpd.conf, 修改了也没用, 它会在后面做 cobbler sync 时把 / etc/cobbler/dhcp.template 拷过去覆盖 / etc/dhcp/dhcpd.conf 文件, 并启动 dhcp)
只修改下面这一段, 改成你自己对应的IP和网段就可以了
# vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 { ----- 改你分配的网段, 掩码
option routers 192.168.1.2; ---- 改你分配的网关
option domain-name-servers 192.168.1.2; ----- 改你分配的 DNS 指向
option subnet-mask 255.255.255.0; ----- 改你分配的 IP 的掩码
range dynamic-bootp 192.168.1.200 192.168.1.254; ----- 改你分配的 IP 的范围
- default-lease-time 21600;
- max-lease-time 43200;
- next-server $next_server;
- class "pxeclients" {
- match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
- if option pxe-system-type = 00:02 {
- filename "ia64/elilo.efi";
- } else if option pxe-system-type = 00:06 {
- filename "grub/grub-x86.efi";
- } else if option pxe-system-type = 00:07 {
- filename "grub/grub-x86_64.efi";
- } else {
- filename "pxelinux.0";
- }
- }
- }
- # vim /etc/cobbler/settings ---- 再去修改这个配置文件, 改成 dhcp 服务由 cobbler 来管理
- # vim /etc/cobbler/settings ---- 再去修改这个配置文件, 改成 dhcp 服务由 cobbler 来管理
242 manage_dhcp: 1 ---- 把 0 改为 1
- # /etc/init.d/cobblerd restart ---- 保存后, 再重启此服务
- # cobbler sync ---- 同步 cobbler 配置, 并初始化, 帮你启动 dhcp 等
- ......
- *** TASK COMPLETE ***
- # /etc/init.d/xinetd restart ---- 把 xinetd 服务重启一下
第五大步:
测试验证: 新建一个 vmnet1 网段 (因为我前面配置的是这个网段) 的虚拟机, 然后启动, 会出现 cobbler 的引导安装界面, 选择并自动安装(这里自动安装的系统没有图形界面, 默认只安装 417 个包而已)
=================================================================================
自定义 ks 文件的方法
1, 如果你很熟悉此文件, 直接拷别人的模版修改或者直接使用 / root/anaconda-ks.cfg 来修改
2, 使用一个图形工具 system-config-kickstart 来帮助你配置(下面我就是使用这种方法)
- # vim /etc/yum.repos.d/rhel-source.repo -- 把 kickstart server 服务器的 yum 配置文件, 做成 rhel6 的完整配置
- [base]
- name=server
- baseurl=file:///yum/
- enabled=1
- gpgcheck=0
- [server]
- name=server
- baseurl=file:///yum/Server
- enabled=1
- gpgcheck=0
- [loadbalancer]
- name=loadbalancer
- baseurl=file:///yum/LoadBalancer
- enabled=1
- gpgcheck=0
- [HighAvailability]
- name=HighAvailability
- baseurl=file:///yum/HighAvailability
- enabled=1
- gpgcheck=0
- [ScalableFileSystem]
- name=ScalableFileSystem
- baseurl=file:///yum/ScalableFileSystem
- enabled=1
- gpgcheck=0
- [ResilientStorage]
- name=ResilientStorage
- baseurl=file:///yum/ResilientStorage
- enabled=1
- gpgcheck=0
- # yum install system-config-kickstart -y
- # system-config-kickstart ---- 使用此命令打开图形界面, 进行自定义的 ks.cfg 文件配置
- (默认是保存到 / root/ks.cfg)
ks 文件:
- #platform=x86, AMD64, or Intel EM64T
- #version=DEVEL
- # Firewall configuration
- firewall --disabled
key --skip ---- 在这里加上 key --skip 跳过输入安装码
- # Install OS instead of upgrade
- install
- # Use network installation
- url --url="http://192.168.1.2/cobbler/ks_mirror/rhel6.5-x86-64/" http://192.168.1.2/cobbler/ks_mirror/rhel6.5-x86-64/
- # Root password
- rootpw --iscrypted $1$8hemoA6d$r7S06nYv/GVVbVfWOpK.6/
- # 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 --isUtc Asia/Shanghai
- # Network information
- network --bootproto=dhcp --device=eth0 --onboot=on
- # System bootloader configuration
- bootloader --append="rhgb quiet" --location=mbr
- # Clear the Master Boot Record
- zerombr
- # Partition clearing information
- clearpart --all --initlabel
- # Disk partitioning information
- part /boot --asprimary --fstype="ext4" --size=200
- part swap --asprimary --fstype="swap" --size=2000
- part / --asprimary --fstype="ext4" --grow --size=1
- %post
- touch /root/123
- touch /tmp/123
- %end
- %packages
- @additional-devel
- @basic-desktop
- @chinese-support
- @desktop-debugging
- @desktop-platform
- @desktop-platform-devel
- @development
- @eclipse
- @fonts
- @general-desktop
- @graphical-admin-tools
- @input-methods
- @kde-desktop
- @legacy-x
- @remote-desktop-clients
- @server-platform-devel
- @x11
- %end
- =============================================================
- # cobbler profile help ----- 查看帮助
- # cobbler profile list ----- 查看有哪些 profile
- rhel6.5-64-x86_64
- # cobbler profile report --name=rhel6.5-64-x86_64 |grep -i kickstart
Kickstar :var/lib/cobbler/kickstarts/sample_end.ks ---- 这就是这个安装方案的 kickstart 文件
- Kickstart Metadata : {}
- # mv /root/ks.cfg /var/lib/cobbler/kickstarts/myks1.ks ----- 这里我把做好的 ks 文件, mv 到 cobbler 默认的 ks 文件存放目录(只是为了管理方便, 所以才都放在同一个目录下), 并自定义一个名字
然后把这个 ks 文件和 profile 对应起来
- # cobbler profile add --name=my_profile1 --distro=rhel6.5-64-x86_64 --kickstart=/var/lib/cobbler/kickstarts/myks1.ks
- # cobbler profile list ----- 在原来基础上就多了自定义的安装方案
- my_profile1
- rhel6.5-64-x86_64
然后就可以新建一个客户端虚拟机, 使用上面的 my_profile1 安装名字来测试了
对上面操作的扩展(仅供参考)
- # cobbler profile edit --name=my_profile1 --kickstart=/var/lib/cobbler/kickstarts/myks2.ks ----- 将 myks2.ks 这个 profile 修改一个新的 ks 文件
- # cobbler profile remove --name=my_profile1 ----- 删除 my_profile1 这个 profile
- # 写完 ks 文件之后, 先通过 validateks 测试一下有没有语法错误
- # cobbler validateks
- # 通过下面这个命令查看 ks 文件, 发现一些逻辑上的问题 # cobbler system getks --name=test
测试: 再新开一个虚拟机, 使用上面新建的 my_profile1 来进行自动安装
安装要注意几点:
1, 虚拟机的安装路径尽量选择空间较多的分区的挂载目录(尽量不要使用默认的 / root/vmware 目录)
2, 安装完后没有图形界面, 是安装了图形相关软件包 (前面 ks 文件里选择了) 但没默认进的是 3 级别导致的.
解决: 修改 /etc/inittab 里把 3 改为 5 . 然后使用 init 5 切换到图形级别
3, 把 yum 源做好, 我这里是虚拟机光驱加载宿主机上的 iso 镜像, 然后
- mkdir /yum
- mount /dev/cdrom /yum
4, 上面的做 ok 后, 做一个快照, 方便以后实验使用
5, 针对这台多克隆几台(使用完全克隆, 不要使用链接克隆), 但要注意克隆后的机器是没有快照的, 所以需要重新再做(还有一个问题, 网卡 eth0 克隆后会变成 eth1, 你可以自己修改一下, 也可以无所谓)
======================================================================
cobbler 补充一:
客户端使用 koan 与服务器的 cobbler 联系, 实现自动重装系统
在客户端安装 koan-2.6.9-1.el6.noarch.rpm 软件包
- # yum install koan-2.6.9-1.el6.noarch.rpm ----- 因为 cobbler 可以自动帮你解决 yum 的配置, 所以依赖性可以直接帮你解决
- # koan --server=192.168.1.2 --list=profiles -----192.168.1.2 为 cobbler 服务器 IP, 得到的结果和在 cobbler 服务器上 cobbler profile list 命令得到的结果一样
- my_profile1
- rhel6.5-64-x86_64
# koan --replace-self --server=192.168.1.2 --profile=my_profile1 ----- 指定本客户端按照名为 my_profile1 的 profile 重装系统
# reboot ----- 敲完上面的命令, 使用 reboot, 就会重装了(没敲上面的命令那 reboot 就是重启)
cobbler 补充二:
cobbler 的 web 管理
web 管理路径
# /etc/init.d/ https://i.cnblogs.com/httpd restart ----- 先最好重启一下 httpd 服务 https://i.cnblogs.com/httpd服务
然后通过 firefox 访问下面的路径
- http://IP/cobbler_web -- 默认用户名 cobbler, 密码 cobbler http://ip/cobbler_web
- # htdigest /etc/cobbler/users.digest "Cobbler" abc -- 增加一个 abc 用户
Adding user abc in realm Cobbler
- New password:
- Re-type new password:
- # cat /etc/cobbler/users.digest
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
abc:Cobbler:de5b9d396aa51c6710e62e555a2986ec
####################################################################
使用此 iso 用虚拟机图形安装 centos7.3
安装完后, 做一些基本优化
1, 主机名
centos7 有一个新的修改主机名的命令 hostnatctl
- # hostnamectl set-hostname --static vm1.cluster.com
- # vim /etc/hosts ----- 最后加上你的 IP 与主机名的绑定
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 镜像挂载:
- # 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, 重启系统, 确认上面的基本修改没问题后, 就可以对这个虚拟机做一个快照了(以后做实验需要干净的系统, 就可以直接恢复此快照再做实验)
来源: http://www.bubuko.com/infodetail-2651050.html