無人值守安裝(自動按定制的需求來批量安裝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端口。
要求的技術和服務:
2 t
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,把下面這些組件服務也確認安裝上
擴展問題:
如果你要下載並安裝一些rpm包時,如果缺少依賴性包,但官方又沒有提供(這種事很常見),你操作系統的iso鏡像里也沒有,你如何去找這些依賴包?
答案:
方法一:去一些第三方的yum倉庫里去找,如:
epel源,163源(mirrors.163.com),centos源
方法二:
如果上面的yum還是找不到,則去
www.rpmfind.net或rpm.pbone.net網站去搜
第二大步:基本配置
# 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 : 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管理路徑
然后通過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,重啟系統,確認上面的基本修改沒問題后,就可以對這個虛擬機做一個快照了(以后做實驗需要干凈的系統,就可以直接恢復此快照再做實驗)