无人值守安装

无人值守安装(自动按定制的需求来批量安装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 ftp
(trival file tranfer protocol) 协议下载一个启动软件包到客户端内存中执行。
PXE(preboot execute environment,预启动执行环境)是由 Intel公司 开发的最新技术,工作于Client/Server的网络模式,支持 工作站 通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用 TFTP (trivial file transfer protocol)或 MTFTP (multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端(客户端)基本软件设置,从而引导预先安装在服务器中的终端操作系统。
t ftp
简单文件传输协议,提供简单的,不可靠的文件传输。基于UDP的69端口。
要求的技术和服务:
1 nfs服务器或者用 http,ftp三种协议之一 (共享安装光盘目录文件)
-----共享启动相关文件
3 dhcp服务器
-----客户端获取IP,网关,DNS指向,主机名,NIS域,NTP
4 kickstart程序生成的ks.cfg配置文件(此文件就定义了安装系统如何分区,如何格式化,root密码等等) 取一个安装名字,可以由客户端自动选择是否用此安装名安装
满足上面的1,2,3三点,就是安装服务器(类似第一天来学习时的安装系统的网络服务器),客户端(支持pxe的网卡)选择网络启动----通过dhcp获取IP可以和服务器通迅----通过t 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 ftp* rsync xinetd http* syslinux dhcp* pykickstart
扩展问题:
如果你要下载并安装一些rpm包时,如果缺少依赖性包,但官方又没有提供(这种事很常见),你操作系统的iso镜像里也没有,你如何去找这些依赖包?
答案:
方法一:去一些第三方的yum仓库里去找,如:
epel源,163源(mirrors.163.com),centos源
方法二:
如果上面的yum还是找不到,则去 www.rpmfind.net或rpm.pbone.net网站去搜
第二大步:基本配置
# cobbler check
--查看cobbler潜在的需要修改的选项(有可能因为你的 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
# 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/ httpd restart -----先最好重启一下 httpd服务
然后通过firefox访问下面的路径
# 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
# 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/
# 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,重启系统,确认上面的基本修改没问题后,就可以对这个虚拟机做一个快照了(以后做实验需要干净的系统,就可以直接恢复此快照再做实验)

猜你喜欢

转载自www.cnblogs.com/skyzy/p/9201239.html